close ad
Install the LAtest Updates to Work with CC 2017 and CC 2018
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

rating

Disount Code from a recordset

Thread began 7/01/2013 11:24 am by jon392819 | Last modified 7/01/2013 3:30 pm by jon392819 | 391 views | 5 replies |

jon392819

Disount Code from a recordset

Hi Guys, I amended the discount code to look up a discount voucher value via recordset. I get an undefined variable error.
The code is below. Before I amended the code the voucher was hard coded and checked against a session created when person put in a valid code. Worked fine. To enable the site owner to change these codes on a whim I set up a dataabse table to hold the voucher. I then created a recordset in eCart1_PHP.php and changed the below. I know the variable $discountcode gets the correct value but On the cart page its says undefined. Any help really appreaciated. I have put 3 # sybols in front of and at the end of the code I inserted to help you see what I changed.

function WAEC_eCart1_discountRule() {
$totalDiscount = 0;
#####$discountcode = $row_Recordset1['voucher'];####
if (true && ((sizeof($this->Items) > 0) && ((isset($_SESSION['coupon'])?$_SESSION['coupon']:"") == ###$discountcode###))) {
$totalDiscount += ($this->ConditionalTotal("TotalPrice", "sale", "no") * 0.20);//Result

Sign in to reply to this post

Jason ByrnesWebAssist

instead of doing it this way, store the recordset value in a session variable, and use the session variable in the discount rule.

Sign in to reply to this post

jon392819

Genius, I think I have it. Thanks a million Jason.

Sign in to reply to this post

jon392819

Hi Jason, one final question, Is it possible to have the precentage (discount) dynamicly set by the user in much the same way they are setting the voucher code (via a recordset which sets a session). I attach a screen shot of the discount rules currently in play. I have it set to 20% but would like to give the user the option to change this via a simple CMS. I can do this but am unsure if I can setup the discount rules to look to a session for the precentage to take off.

Thanks a Million Jason

Jon

Sign in to reply to this post

Jason ByrnesWebAssist

yup, you could set the percentage in the database using a decimal:
0.20

for 20%

store that in a session and use the session in the calculation, where you have entered 0.20 use:

$_SESSION['percentage']

Assuming the session is named "percentage" ,instead.

Sign in to reply to this post

jon392819

That easy!!! Thanks again Jason, thats was the fastest response ever. Slow day at webassist? :)

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