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

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

rating

bug found in eCart_PHP recarding discount rules

Thread began 9/04/2016 7:35 pm by Christopher West | Last modified 9/08/2016 1:41 pm by Ray Borduin | 398 views | 4 replies |

Christopher WestCommunity Expert

bug found in eCart_PHP recarding discount rules

Hi there, I just finished creating some discount rules in the eCart object. and on uploading to localhost I have the following error:

Parse error: syntax error, unexpected '' (T_ENCAPSED_AND_WHITESPACE), expecting identifier (T_STRING) or variable (T_VARIABLE) or number (T_NUM_STRING) in C:\xampp\htdocs\armadillo\WA_eCart\eCart_PHP.php on line 108

I am attaching the file, I assume the error will also return on my other discount rules.

I assume its a bug since I didnt use any custom coding, I just used the eCart object and my session variables.

How do I fix?

php:
//eCart Rule

//eCart Rule
function WAEC_eCart_AllProductsPercentageDiscount()  {
  $totalDiscount = 0;
  if (true && ((sizeof($this->Items) > 0) && (isset($_SESSION['CouponDiscount'])) && ((isset($_SESSION['CouponType'])?$_SESSION['CouponType']:"") == "1") && ((isset($_SESSION['CouponGroup'])?$_SESSION['CouponGroup']:"") == "1") && (time() >= strtotime("".$_SESSION['CouponValidFrom']  ."")) && (time() <= strtotime("".$_SESSION['CouponValidTo']  ."")))) {
    $totalDiscount += ($this->TotalColumn("TotalPrice") * ".$_SESSION['CouponDiscount']  .");//Result
  }
  return WA_eCart_FormatNumber($totalDiscount, $this->ForceDecimalsC, $this->DecimalPlacesC);
}





.....update...I have found removing some code generated by the eCart Object discount tool to the below works:

php:
[php]

//eCart Rule
//eCart Rule
function WAEC_eCart_AllProductsPercentageDiscount()  {
  $totalDiscount = 0;
  if (true && ((sizeof($this->Items) > 0) && (isset($_SESSION['CouponDiscount'])) && ((isset($_SESSION['CouponType'])?$_SESSION['CouponType']:"") == "1") && ((isset($_SESSION['CouponGroup'])?$_SESSION['CouponGroup']:"") == "1") && (time() >= strtotime($_SESSION['CouponValidFrom']  ."")) && (time() <= strtotime($_SESSION['CouponValidTo']  ."")))) {
    $totalDiscount += ($this->TotalColumn("TotalPrice") * $_SESSION['CouponDiscount']);//Result
  }
  return WA_eCart_FormatNumber($totalDiscount, $this->ForceDecimalsC, $this->DecimalPlacesC);
}
[/php]




NOTES: I have removed the following parts:
strtotime("".$_SESSION['CouponValidFrom'] ."") TO strtotime($_SESSION['CouponValidFrom'] ."")
strtotime("".$_SESSION['CouponValidTo'] ."") TO strtotime($_SESSION['CouponValidTo'] ."")
".$_SESSION['CouponDiscount'] ."); TO $_SESSION['CouponDiscount']);




Chris

Attached Files
eCart_PHP.php
Sign in to reply to this post

Ray BorduinWebAssist

The issue was with the discount amount... your original code had:
$totalDiscount += ($this->TotalColumn("TotalPrice") * ".$_SESSION['CouponDiscount'] .");//Result

The updated code had:
$totalDiscount += ($this->TotalColumn("TotalPrice") * $_SESSION['CouponDiscount']);//Result

It shouldn't have been based on the other code you removed... that code appears correct.

Does it all work now? Do you still need help?

Sign in to reply to this post

Christopher WestCommunity Expert

Hi Ray, after I modified the code it seems to work. But I just wanted to confirm with you the modifications were correct (or if there is some unseen issue that may arise). from the attached .php file I sent the other day, that file includes the original (non modified code). And its this code thats auto generated by the webassist ecart object when creating the rules. I just want to clarify it all?

Chris

Sign in to reply to this post

Ray BorduinWebAssist

The rule was expecting a number to be entered and you had entered: <?php echo($_SESSION['CouponDiscount']); ?>

I think it would have worked properly if you just had entered: $_SESSION['CouponDiscount'] and that is the difference between the two code chunks.

Sign in to reply to this post

Christopher WestCommunity Expert

Hi I am almost sure that I tried it without <?php echo( .... ); ?> part of the code. I could be wrong. I could test that theory I guess :)

Sign in to reply to this post

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...