Announcement

Collapse
No announcement yet.

Specifying a Delivery Cut-Off Time for Orders

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

    Specifying a Delivery Cut-Off Time for Orders

    I recently implemented the above code (AUG Page 94).
    On testing it seems that the time is taken from the user's computer, which defeats the purpose - if I specify a delivery cut-off of 1pm, the warning message will appear after that time to UK users (provided their system clock is set to the correct time), but for overseas users, the message will only appear when their machine time reaches 1pm. So a user in New York, for example, will only see the warning after 1pm New York time, which is 6pm GMT.

    Does anyone know of a way to amend the script so that it shows at the correct time regardless of the time on the user's computer?
    Brian
    www.flowergallery.co.uk
    Same day flower delivery to UK
    Same day flower delivery to Republic of Ireland
    International Flower Delivery

    Located in Argyll, Scotland, UK

    #2
    Originally posted by brian.mc
    Does anyone know of a way to amend the script so that it shows at the correct time regardless of the time on the user's computer?
    We do yes, but it is independent of the AUG. We use a cookie driven token system that relies on the clients 'server time' rather than the local time (PC).

    We will look into the AUG feature when time allows and let you have some feedback when completed.

    Regards
    Affordable solutions for busy professionals.
    Website Maintenance | UK Web Hosting

    Comment


      #3
      Got it to work!
      For anyone else interested, the code in the AUG needs to be amended.

      This is how it currently appears, which calculates the time on the user's computer. This means that a customer in New York, for example, would not see the message until 4pm New York time, which is 9pm UK Time, so would not realise that the cut-off time had passed. A customer in Amsterdam would see the message at 4pm Amsterdam time, which is 3pm UK time, so you could lose his order because he would think the cut-off time had passed.

      <script language=JavaScript>
      now = new Date();
      if ( now.getHours() >= 16 ) document.write('<span style="color:red;">Warning text here</span>');
      </script>
      The amended code is:-

      <script language=JavaScript>
      now = new Date();
      if ( now.getUTCHours() >= 16 ) document.write('<span style="color:red;">Warning text here</span>');
      </script>

      This calculates the time according to Universal Coordinated Time (UTC), and will display correctly on the user's computer provided it is set correctly for their time zone.

      You can expand on this further, by having different messages according to the day of the week as follows:-

      <script language=JavaScript>
      now = new Date();
      if ( now.getUTCHours() >= 16 )
      if ( now.getUTCDay() == 1)
      document.write('<span style="color:red;">Monday warning text here</span>');
      </script>

      <script language=JavaScript>
      now = new Date();
      if ( now.getUTCHours() >= 16 )
      if ( now.getUTCDay() == 2)
      document.write('<span style="color:red;">Tuesday warning text here</span>');
      </script>

      <script language=JavaScript>
      now = new Date();
      if ( now.getUTCHours() >= 16 )
      if ( now.getUTCDay() > 0)
      if ( now.getUTCDay() < 6)
      document.write('<span style="color:red;">Monday to Friday warning text here</span>');
      </script>

      <script language=JavaScript>
      now = new Date();
      if ( now.getUTCDay() == 0)
      document.write('<span style="color:red;">Sundaywarning text here</span>');
      </script>

      (The last one assumes that there is no delivery service on Sundays regardless of time, hence the absence of the time element)

      You can have as many of these as you want, and only those which meet the day and time criteria will be shown.

      This could even be used for marketing messages, so you could create a special offer which is only available on Fridays until 2pm for example.

      The Universal Coordinated Time (UTC) is the time set by the World Time Standard, and is equivalent to GMT. However, you would have to adjust the cut-off time during the summer months, when GMT is advanced an hour, so the above example would work ok in winter for a 4pm cut-off, but 16 would need to be changed to 15 during summer time.
      Brian
      www.flowergallery.co.uk
      Same day flower delivery to UK
      Same day flower delivery to Republic of Ireland
      International Flower Delivery

      Located in Argyll, Scotland, UK

      Comment


        #4
        Nice one Brian

        Maybe an update to the AUG

        D

        Comment


          #5
          Just to follow up on this, the code can be further amended to have the message appear on specific dates by using the following:-

          Date: 1 - 31
          Month: 0 - 11
          FullYear - 2007 (or whichever year you want)

          So, say you were going on holiday from 15th - 30th November and wanted to post a message to appear on the site during that period, the code would be
          Code:
          <script language=JavaScript>
            now = new Date();
             if ( now.getUTCDate() >= 15)
             if ( now.getUTCDate() <= 30)
             if ( now.getUTCMonth() == 10)	
             if ( now.getUTCFullYear() == 2007) document.write('<span style="color:RED;"><b>YOUR MESSAGE</b></span>');
          </script>
          Brian
          www.flowergallery.co.uk
          Same day flower delivery to UK
          Same day flower delivery to Republic of Ireland
          International Flower Delivery

          Located in Argyll, Scotland, UK

          Comment


            #6
            Ummm - Brian - isn't November the 11th Month?
            Bill
            www.egyptianwonders.co.uk
            Text directoryWorldwide Actinic(TM) shops
            BC Ness Solutions Support services, custom software
            Registered Microsoft™ Partner (ISV)
            VoIP UK: 0131 208 0605
            Located: Alexandria, EGYPT

            Comment


              #7
              except he's stated to use 0 - 11 for the months (I dunno why..that's beyond me LOL)...so working on that concept, 10 is November.
              Tracey

              Comment


                #8
                You know Tracey, I let that fly right over my head - you are right, the month is a zero based array. I wonder why?

                [edit]Javascript 1.5 standard - that's my new thing learned for today [/edit]
                Bill
                www.egyptianwonders.co.uk
                Text directoryWorldwide Actinic(TM) shops
                BC Ness Solutions Support services, custom software
                Registered Microsoft™ Partner (ISV)
                VoIP UK: 0131 208 0605
                Located: Alexandria, EGYPT

                Comment


                  #9
                  If you'd like to get your server time into some JavaScript variables, so you can trust the time, regardless of the users system time then:

                  Put the following into your Site folder, saved as jdatetime.php

                  Code:
                  <?php
                  $now = getdate();
                  header("content-type: application/x-javascript");
                  echo "var wday={$now['wday']}; var hours={$now['hours']}; var minutes={$now['minutes']};";
                  ?>
                  Add jdatetime.php to Options / Additional Files.

                  Now in your Overall Layouts put
                  Code:
                  <script language="JavaScript" type="text/javascript" src="jdatetime.php"></script>
                  And the server side php will return and set 3 JavaScript variables, e.g.

                  var wday=0; var hours=21; var minutes=43;

                  which you can now use on your site scripts.
                  Norman - www.drillpine.biz
                  Edinburgh, U K / Bitez, Turkey

                  Comment


                    #10
                    0 - 11 for the months
                    0 is january, 11 is december ?

                    Comment


                      #11
                      Originally posted by wjcampbe
                      Ummm - Brian - isn't November the 11th Month?
                      Got the code from this
                      http://www.w3schools.com/jsref/jsref_obj_date.asp
                      Brian
                      www.flowergallery.co.uk
                      Same day flower delivery to UK
                      Same day flower delivery to Republic of Ireland
                      International Flower Delivery

                      Located in Argyll, Scotland, UK

                      Comment

                      Working...
                      X