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

I need to add a coupon code and apply a discount for against only one item in cart

Thread began 11/09/2009 11:30 pm by david353947 | Last modified 11/12/2009 3:38 pm by Eric Mittman | 1358 views | 4 replies |

david353947

I need to add a coupon code and apply a discount for against only one item in cart

I need to be able to add a coupon code to my cart and have a discount applied only to only particular item's value in the cart....so if the customer adds two $10 widgets to the cart and enters a correct coupon code which is worth 50%, the value displayed and charged for that line item would be $10, one widget would be $5. I don't want to give a discount for the entire contents of the cart, only that one item number. I took a listen to the tutorial and looked at the recipe, but don't see how to implement for one item. Attached is what I have so far.

Sign in to reply to this post

Eric Mittman

You are very close with the discount that you are crafting, you just need to specify price rather than total price for the calculation portion. This way it will take the price of the item, and give a discount based on this value. For 50% off you would multiply by .5.

If you had it set this way and had two $10 widgets in the cart and the correct coupon code was entered you would give a discount of $10 * .5 which would be $5, so the total would be $15 after the discount.

Sign in to reply to this post

david353947

I need to add a coupon code and apply a discount for against only one item in cart

For whatever reason, when I create the session variable named "PromoCode", I'm following the recipe and it won't let me type in a session name and just grabs the last one listed. When I try to execute the promo code logic, nothing happens.

Sign in to reply to this post

david353947

I need to add a coupon code and apply a discount for against only one item in cart

Here is the code...

Cart.php session code...
<?php
if (!session_id()) session_start();
if((((isset($_FILES["Coupon"]))?$_FILES["Coupon"][""]:"") != "")) {
$_SESSION["Session_PromoCode"] = "".((isset($_FILES["Coupon"]))?$_FILES["Coupon"][""]:"") ."";
}
?>
..................................................................................................................
Coupon Code code in cart.php...
<form id="form1CouponCode" name="form1CouponCode" method="post" action="">
<label><span class="style10">Coupon Code</span>
<input name="Coupon Code" type="text" id="Coupon Code" size="8" maxlength="8" />
</label>
<label>
<div align="right">
<input type="submit" name="Submit" id="Submit" value="Submit" />
.............................................................................................................
Add to cart button code on the product page...
<input type="hidden" name="IsACart_3_ID_Add" value="100106" >
<span class="style1"> Style:</span>
<select name="IsACart_3_Style_Add">
<option value="Feathers" selected>Feathers</option>
<option value="Beads">Beads</option>
<option value="Gems">Gems</option>
</select>
</p>
<p align="left">
<input type="text" name="IsACart_3_Quantity_Add" value="1" size="4" >
<input type="image" src="../WA_eCart/Images/Poppy/Btn4_EN_addtocart.gif" border="0" value="Add to Cart" name="IsACart_3_ATC" />
</p>
</form>

..........................................................................................................
And in isACart_PHP.php...
//Discounts
$this->Discounts[] = new WA_eCart_Rule(urldecode("PromoCode"), true, "WAEC_IsACart_PromoCode");

Sign in to reply to this post

Eric Mittman

When you are saying that you cannot enter the name of the session variable are you referring to the set session variable interface or the eCart interface for the discount?

It looks like in your code you are setting the session variable promocode. It seems that you are binding this variable to an incorrect value. This variable should be bound to your coupon code text field. Also, you should not have a space in the name of your coupon code text field.

In the eCart discount it looks as though you are not making reference to the promo code session variable.

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