close ad
WARNING: Do Not Install the DREAMWEAVER CC 2017 Update »
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

rating

cannot get the "if today is after....if today is before.." working

Thread began 2/12/2013 5:54 am by Christopher West | Last modified 2/13/2013 11:49 am by Jason Byrnes | 645 views | 11 replies |

Christopher WestCommunity Expert

cannot get the "if today is after....if today is before.." working

Hi there I have set up a coupon system on the checkout page. There will be many variations of rules governing the type of coupon. However as soon as I give a rule the following triggers, the coupon wont work.
"If today is after CouponValidFrom"
"If today is before CouponValidTo"

I will provide a screen shot og the rules, Im using. and the checkout page in the zip file.

In the database table the fields that store the dates From/To are DATE (should it be DATETIME? for this rule to function?) In the admin I am storing the data as DATE

I have setup a recordset to filter the coupon code and I have set all the sessions.

Any idea why it wotn work once I use the "if today..." rules??

Chris

Attached Files
checkout.zip
Sign in to reply to this post

Jason ByrnesWebAssist

are you sure the sessions have a value?

add the following code to write the sessions to the page:

php:
<?php

@session_start();
echo(
"FormCouponValidFrom: ".$_SESSION["FormCouponValidFrom"]."<br />");
echo(
"FormCouponValidTo: ".$_SESSION["FormCouponValidTo"]."<br />");
?>
Sign in to reply to this post

Christopher WestCommunity Expert

I just rewrote the rule and I get this error:

Parse error: syntax error, unexpected '"', expecting T_STRING or T_VARIABLE or T_NUM_STRING in C:\Server\www\dinky\WA_eCart\DinkyCart_PHP.php on line 102

in the ecart rule this is what I am putting:

AND if today is after a certain day
if today is after $_SESSION["FormCouponValidFrom"]

AND if today is before a certain day
if today is before $_SESSION["FormCouponValidTo"]

Ive attached the file in question

Chris

Attached Files
DinkyCart_PHP.zip
Sign in to reply to this post

Jason ByrnesWebAssist

use single quotes instead of double quotes:
$_SESSION['FormCouponValidFrom']

Sign in to reply to this post

Christopher WestCommunity Expert

Hi Jason, I tried that..I still get the error. here is the line that the error is corrisponding to in the php file:

if (true && ((sizeof($this->Items) > 0) && (isset($_SESSION['FormCouponValue'])) && (isset($_SESSION['FormCouponValidFrom'])) && (isset($_SESSION['FormCouponValidTo'])) && (time() >= strtotime("$_SESSION['FormCouponValidFrom']")) && (time() <= strtotime("$_SESSION['FormCouponValidTo']")))) {
$totalDiscount += $_SESSION["FormCouponValue"];//Result

and this is the error message I get: Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in C:\Server\www\dinky\WA_eCart\DinkyCart_PHP.php on line 102

(line 102 is the first line of the code above)

Chris

Sign in to reply to this post

Jason ByrnesWebAssist

you still have double quotes in place:
$totalDiscount += $_SESSION["FormCouponValue"];//Result

Sign in to reply to this post

Christopher WestCommunity Expert

ok i removed the double quotes but i get a syntax error on the first line:

if (true && ((sizeof($this->Items) > 0) && (isset($_SESSION['FormCouponValue'])) && (isset($_SESSION['FormCouponValidFrom'])) && (isset($_SESSION['FormCouponValidTo'])) && (time() >= strtotime('$_SESSION['FormCouponValidFrom']')) && (time() <= strtotime('$_SESSION['FormCouponValidTo']')))) {
$totalDiscount += $_SESSION['FormCouponValue'];//Result

Sign in to reply to this post

Jason ByrnesWebAssist

the following 2 sections in the if statement:

strtotime('$_SESSION['FormCouponValidFrom']')

strtotime('$_SESSION['FormCouponValidTo']')

should b not have the single quotes:
strtotime($_SESSION['FormCouponValidFrom'])

strtotime($_SESSION['FormCouponValidTo'])

Sign in to reply to this post

Christopher WestCommunity Expert

ok I corrected those in the actual DinkyCary_PHP.PHP file manually. When I go back to the eCart Merchandising Rule screen. the 2 date rules show as "Custom condition" ...Im attaching a screenshot - so this would make it confusing to edit (if need be from this screen). Would this be a bug since creating the rule from the eCart Merchanding Rule screen those quotes are automatically created in the rule.

Chris

Sign in to reply to this post

Jason ByrnesWebAssist

yes, this is bug when using dynamic values for the date, I will log it in our system so it can be corrected in the next update.

Sign in to reply to this post
loading

Build websites with a little help from your friends

Your friends over here at WebAssist! These Dreamweaver extensions will assist you in building unlimited, custom websites.

Build websites from already-built web applications

These out-of-the-box solutions provide you proven, tested applications that can be up and running now.  Build a store, a gallery, or a web-based email solution.

Want your website pre-built and hosted?

Close Windowclose

Rate your experience or provide feedback on this page

Account or customer service questions?
Please user our contact form.

Need technical support?
Please visit support to ask a question

Content

rating

Layout

rating

Ease of use

rating

security code refresh image

We do not respond to comments submitted from this page directly, but we do read and analyze any feedback and will use it to help make your experience better in the future.

Close Windowclose

We were unable to retrieve the attached file

Close Windowclose

Attach and remove files

add attachmentAdd attachment
Close Windowclose

Enter the URL you would like to link to in your post

Close Windowclose

This is how you use right click RTF editing

Enable right click RTF editing option allows you to add html markup into your tutorial such as images, bulleted lists, files and more...

-- click to close --

Uploading file...