close ad
Databridge V2 with MySQLi support IS Now Available!
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

rating

Promotional Codes not working

Thread began 11/17/2009 10:25 am by larsentim278054 | Last modified 11/17/2009 5:13 pm by Jason Byrnes | 1054 views | 5 replies |

larsentim278054

Promotional Codes not working

I followed the tutorial you have for creating a promotional code - and uploaded the revised cart.php as well as the WA_Store_cart.php file that the ecart program modifies but the promotional code doesn't work. It seems to not be triggering with the button (it doesn't do anything). However, it DOES work when I hit [ENTER] after typing in the coupon code, so it seems to be setup correctly, except for the button trigger. It doesn't do anything. I've copied all the code that was added to my cart pages below. I assume it's a problem with my form and something not identified correctly? Thanks!

Oh - and also, is there a way to have this promotional code only work on CERTAIN products? Instead of on the entire order? Thanks!

This is on my cart.php:

<?php
if (!session_id()) session_start();
if((((isset($_POST["txtPromoCode"]))?$_POST["txtPromoCode"]:"") != "")) {
$_SESSION["PromoCode"] = "".((isset($_POST["txtPromoCode"]))?$_POST["txtPromoCode"]:"") ."";
}
?>



And this is the form I added to the cart.php:

<form action="" method="post" name="PromoCode">
<table>
<tr>
<th><label for="txtPromoCode">Coupon Code:</label></th>
<td><input name="txtPromoCode" type="text" id="txtPromoCode" /></td>
<td><input id="couponCodebtn" name="txtPromoCode" type="button" value="" /></td>
</tr>
</table>
</form>



And this is the code that was added on my wa_store_cart_PHP.php:

//Discounts
$this->Discounts[] = new WA_eCart_Rule(urldecode("Promotional%20Discount"), true, "WAEC_WA_Store_Cart_PromotionalDiscount");


and

//eCart Rule
function WAEC_WA_Store_Cart_PromotionalDiscount() {
$totalDiscount = 0;
if (true && ((sizeof($this->Items) > 0) && ((isset($_SESSION['PromoCode'])?$_SESSION['PromoCode']:"") == "WebAssist"))) {
$totalDiscount += ($this->TotalColumn("TotalPrice") * 0.10);//Result
}
return WA_eCart_FormatNumber($totalDiscount, $this->ForceDecimalsC, $this->DecimalPlacesC);
}
Sign in to reply to this post

Jason ByrnesWebAssist

your text field and submit button are both named txtPromoCode:

<input name="txtPromoCode" type="text" id="txtPromoCode" /></td>
<input id="couponCodebtn" name="txtPromoCode" type="button" value="" />


you must us unique names for each form element.


try changing the submit button to:
<input id="couponCodebtn" name="couponCodebtn" type="submit" value="Submit" />




see this thread:
showthread.php?t=7503

for info on applying the discount only to certain items.

Sign in to reply to this post

larsentim278054

I knew it was something stupid like that. Thank you very much for pointing that out.

About the individual items discounted - I read that thread, and replied on that thread with my questions. But should I reply on this one? Or keep it there. Not sure what would be preferred.

Sign in to reply to this post

larsentim278054

I was just about to test this, so I went on my site. I'm not logged in, and there's nothing in my cart. So I added something to the cart. But when it went to the cart, there was already a discount showing on the product and I didn't add any coupon code! I assume it was there because I was playing with this earlier, but I don't understand this. I've since removed the coupon code (by making it inactive) - and then I fixed the form, made the discount active, uploaded the files, and proceeded to go to the site, and it's showing the discount already? Without any coupon code being added. So I assume the session variable is still in my browser or whatever... Why wasn't it removed? Why would it stick like that? How do I prevent this from happening? Is there a code I need to put on the cart.php page to remove the session variable or something? I just added this item to the cart... didn't add a coupon code...

Sign in to reply to this post

larsentim278054

It seems to do this no matter when I enter a coupon code. If it's entered (which by the way, it still won't work with the button - I have to enter it and hit [enter] for the coupon code to work) -- I can clear my cart, add a different item to the cart, and the discount shows up again without me entering any code.

EDIT: I got the button to work. It had to be "submit" type. In your video tutorial, it says it should be type="button". When I switched it to submit, it works fine now.

Regarding the discount showing up - the only way I can get rid of it is by clearing my cookies. Is it supposed to act like this?

Sign in to reply to this post

Jason ByrnesWebAssist

Yes, the discount code is stored in a session variable. A session variable will exist until the browser is closed completely or the cookie is deleted.

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