Announcement

Collapse
No announcement yet.

Hide delivery choice based on date & time

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Hide delivery choice based on date & time

    Afternoon lovely people.

    Very quick question - Is it possible to hide/omit a delivery choice based on the day of week and time of day?

    The question comes from a member of our sales team, after a customer placed an order for Saturday delivery, after 3PM on a Friday - meaning our team were unable to offer this service.

    I'm aware that it's possible to filter out options using JS/jQuery, just wondering if it's possible to filter based on a date/time criteria.

    Many thanks in advance

    Matt - SMR Bathrooms
    Matt. M - SMR Enterprises Ltd.

    #2
    We explicitly say as the shipping option for Saturday delivery, "Saturday by 1pm order by 3pm Fri" with similar for next working day by 9am. We also have a link to the Shipping page at the checkout.
    Reusable Snore Earplugs : Sample Earplugs - Wax Earplugs - Women's Earplugs - Children's Earplugs - Music Earplugs - Sleep Masks

    Comment


      #3
      Sure. That shouldn't be too hard. You can use JavaScript to test if after 3.00pm on Friday OR Saturday then hide the Saturday delivery option (or maybe add "After 3pm Friday - Now Saturday <next Saturday date>" to the Saturday delivery option description.)
      -----------------------------------------

      First Tackle - Fly Fishing and Game Angling

      -----------------------------------------

      Comment


        #4
        This will operate on Checkout Page 1 and remove any shipping options with "Saturday" in their description if it's after 3pm on a Friday.

        Add to bottom of layout Standard JavaScript Header Functions
        Code:
        <actinic:block if="%3cactinic%3avariable%20name%3d%22PageType%22%20%2f%3e%20%3d%3d%20%27Checkout%20Page%201%27" >
            <script type="text/javascript">
                $(document).ready(function(){
                    var now = new Date();
                    var nowDayofWeek = now.getDay();
                    var nowHour = now.getHours();
                    if ( (nowDayofWeek == 5) && (nowHour >= 15) )
                        {
                        $( "select[name='ShippingClass'] option:contains('Saturday')" ).remove();
                        }
                });
            </script>
        </actinic:block>
        N.b. Untested!
        Norman - www.drillpine.biz
        Edinburgh, U K / Bitez, Turkey

        Comment


          #5
          Sometimes I look at some of Norman's coding and find it just as striking as looking at a beautiful picture.

          I can't decide if this makes me odd or just someone who recognises the elegance in his coding versus my own attempts.
          -----------------------------------------

          First Tackle - Fly Fishing and Game Angling

          -----------------------------------------

          Comment


            #6
            Originally posted by NormanRouxel View Post
            This will operate on Checkout Page 1 and remove any shipping options with "Saturday" in their description if it's after 3pm on a Friday
            That's marvellous NOrman. Thank you. Will test.
            Reusable Snore Earplugs : Sample Earplugs - Wax Earplugs - Women's Earplugs - Children's Earplugs - Music Earplugs - Sleep Masks

            Comment


              #7
              OK so Norman's code works well, and I've tested it fully. What is the opposite word for "remove" in case at a later point in that day, say at 9pm, I wanted to reinstate a shipping option?
              $( "select[name='ShippingClass'] option:contains('Saturday')" ).remove();
              Reusable Snore Earplugs : Sample Earplugs - Wax Earplugs - Women's Earplugs - Children's Earplugs - Music Earplugs - Sleep Masks

              Comment


                #8
                In thar case I would just change the IF condition so that later in the day (for example) the remove option is no longer triggered.
                -----------------------------------------

                First Tackle - Fly Fishing and Game Angling

                -----------------------------------------

                Comment


                  #9
                  Remove "Saturday" if between 3pm and 9pm:
                  Code:
                               if ( (nowDayofWeek == 5) && (nowHour >= 15) && (nowHour < 21) )
                  Norman - www.drillpine.biz
                  Edinburgh, U K / Bitez, Turkey

                  Comment


                    #10
                    Many thanks, Norman.
                    Reusable Snore Earplugs : Sample Earplugs - Wax Earplugs - Women's Earplugs - Children's Earplugs - Music Earplugs - Sleep Masks

                    Comment


                      #11
                      Norman, you're a superstar - yet to test it but I can see the logic and code behind this working wonderfully

                      Many thanks

                      Matt.
                      Matt. M - SMR Enterprises Ltd.

                      Comment

                      Working...
                      X