Announcement

Collapse
No announcement yet.

Date Required Default Date

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

    Date Required Default Date

    I would like to have a date required field in the quanity on confirmation page. I have the field now and it defaults to the current date of the order. What I would like is for it to default a date 3-5 weekdays ahead. Purpose is I run a trophy website. www.sdtrophy.comand when people order, I need time to engrave and ship out. I don't want a customer to feel they can get it shipped the same day. Any help would be appreciated.

    Cheers and Happy New Year

    Niels

    #2
    Hi Niels,

    To do that:

    - browse to your 'site' folder (usually 'c:\program files\actinic v8\sites\Site1' and open 'ShoppingCart.pl' in a text editor such as notepad
    - search for:

    Code:
    $Date[0] = $now[3];
    and replace it with:

    Code:
    $Date[0] = $now[3] + 1;
    This will give you today plus 1 (ie tomorrow's date). Change the '+ 1' to the required number of days ahead that you want it to default to.

    - save the file and update your site.

    Note that this will only work with the 'Quantity on confirmation page' shopping mode as you want.
    ********************
    Tracey
    SellerDeck

    Comment


      #3
      Thank you,

      That worked, one more question, is there a way to change it if it falls over the weekend. I.E. I want a minimum of + 3 working days, If they order on a Thursday with this method it defaults to a Sunday Date, I would like it to default to a Tuesday date (3 working days ahead).

      Thank you again

      Niels

      Comment


        #4
        Hi Niels,

        I will have to ask our development team if that is possible as there is probably some complicated perl code that needs to be worked out.
        ********************
        Tracey
        SellerDeck

        Comment


          #5
          OK, keep me posted.

          Happy New Year!
          Niels

          Comment


            #6
            That would require some Perl programming. You'd have to work out what day of the week it is then set the new date accordingly. The following will set $dayofweek to be 0 through 6 (sunday through saturday).

            my $dayofweek = (localtime)[6];

            and this will return an delivery day offset depending on the day of the week (sunday,...saturday).

            my $deliverydays = (4,3,3,3,5,4,3)[(localtime)[6]];

            so you could use

            $Date[0] = $now[3] + (4,3,3,3,5,4,3)[(localtime)[6]];

            You should adjust that list of numbers to suit your own requirements. And forget public holidays, etc - way too complex to add in.
            Norman - www.drillpine.biz
            Edinburgh, U K / Bitez, Turkey

            Comment


              #7
              The Great Norman!

              I feel honored, after reading so many of your suggestions! Let me take a moment to say thank you for all the help you have given me in the past through this forum.

              So it looks like what i will need to do is the following:
              open up the shoppingcart.pl and post the my $dayofweek = (localtime)[6];
              my $deliverydays = (4,3,3,3,5,4,3)[(localtime)[6]];
              and then
              $Date[0] = $now[3] + (4,3,3,3,5,4,3)[(localtime)[6]];

              Is that correct?

              Niels

              Comment


                #8
                You just need the one line

                $Date[0] = $now[3] + (4,3,3,3,5,4,3)[(localtime)[6]];

                My post above shows two methods. Firstly, how to get the day of week in case you wanted to write your own code. The final one is what to use instead of Tracy's post #2.
                Norman - www.drillpine.biz
                Edinburgh, U K / Bitez, Turkey

                Comment


                  #9
                  Hang on. I've just looked at Tracy's #2 suggestion. This adds one to the day and will fail if you're on the last day of the month. So will my suggestion as the 33rd of December is no use to anyone.
                  Norman - www.drillpine.biz
                  Edinburgh, U K / Bitez, Turkey

                  Comment


                    #10
                    OK try this. Back up ShoppingCart.pl first.

                    Go to Design / Library / Variables. Right-click Other and choose New Variable.
                    Set the following

                    Name: DeliveryDays
                    Description: List of comma separated number of days that delivery will take. One per day starting with Sunday,,,,,,Saturday.
                    Prompt: DeliveryDays
                    Group: Other
                    Place of Setting: Site
                    Tab Name: Properties
                    Type: Text
                    Allow Empty Value: Unchecked
                    Inital Value: Use Parent
                    Top Level Value: 5,4,4,4,6,5,4

                    OK Out

                    Look in ShoppingCart.pl for the block
                    Code:
                    		my $now = time;
                    		my @now = gmtime($now);
                    Immediately below this add the lines
                    Code:
                    		my $deliverydays = (<actinic:variable name="DeliveryDays" encoding="perl" selectable="false" />)[$now[6]];		# get our delivery no of days
                    		$now = $now + ($deliverydays * 86400);			# multiply by seconds to create new date
                    		my @now = gmtime($now);
                    so the whole block looks like
                    Code:
                    		my $now = time;
                    		my @now = gmtime($now);
                    		my $deliverydays = (<actinic:variable name="DeliveryDays" encoding="perl" selectable="false" />)[$now[6]];		# get our delivery no of days
                    		$now = $now + ($deliverydays * 86400);			# multiply by seconds to create new date
                    		my @now = gmtime($now);
                    		$Date[0] = $now[3];
                    		$Date[1] = $now[4] + 1;
                    		$Date[2] = $now[5] + 1900;
                    When you need to alter your delivery days, go to Settings / Site Options / Proprerties / Other
                    and change to contain your delivery days for (Sunday,,,,,,Saturday).
                    Make sure you have 7 comma separated numbers.
                    Norman - www.drillpine.biz
                    Edinburgh, U K / Bitez, Turkey

                    Comment


                      #11
                      Norman,

                      That did not seem to work, it gave me an internal error and bounced me to a google search page.

                      Comment


                        #12
                        OK. I've fixed it and amended post #10 above.
                        Norman - www.drillpine.biz
                        Edinburgh, U K / Bitez, Turkey

                        Comment


                          #13
                          OK,

                          It seemed to fix the internal error, but when I increased the delievery days by one to check, it came up with a Saturday date.

                          this is what I posted and uploaded:
                          Code:
                          my $now = time;
                          		my @now = gmtime($now);
                          		my $deliverydays = (5,4,4,4,6,5,4)[$now[6]];		# get our delivery no of days
                          		$now = $now + ($deliverydays * 86400);			# multiply by seconds to create new date
                          		my @now = gmtime($now);
                          		$Date[0] = $now[3];
                          		$Date[1] = $now[4] + 1;
                          		$Date[2] = $now[5] + 1900;

                          Comment


                            #14
                            It is up to you to set these offsets correctly. They are the offsets to use depending on what the present day is (Sunday,,,,,,Saturday).
                            Norman - www.drillpine.biz
                            Edinburgh, U K / Bitez, Turkey

                            Comment


                              #15
                              I've amended post #10 above to allow you to keep these offsets in a Variable. This way you won't have to alter the Perl when you need to change days.
                              Norman - www.drillpine.biz
                              Edinburgh, U K / Bitez, Turkey

                              Comment

                              Working...
                              X