|
| |
|
|
Joe Kauffman
Posts: 211 Joined: 6/9/2004 From: Arizona, USA Status: offline
|
Javascript Paypal discount codes - 9/1/2009 15:58:55
I have been able to figure out how to integrate some code in a Paypal add to cart form to allow customers to enter a discount coupon which will validate on click and test the value against the info in a .js file. It works great, but I have a couple issues that I'm hoping to get figured out. Here is the code for the form:
<form target="_self" action="https://www.paypal.com/cgi-bin/webscr" method="post">
<!-- Enter Coupon -->
Enter Promo Coupon (optional):
<br>
<input type="text" name="text1">
<!-- End Coupon -->
<br><br>
<input type="image" id="img1" src="images/buynow.png" border="0" onclick=CalculateOrder(this.form) name="submit" width="239" height="68" onmouseout="FP_swapImgRestore()" onmouseover="FP_swapImg(1,1,/*id*/'img1',/*url*/'images/buynowover.png')" >
<img alt="" border="0" src="https://www.paypal.com/en_US/i/scr/pixel.gif" width="1" height="1">
<input type="hidden" name="add" value="1">
<input type="hidden" name="cmd" value="_cart">
<input type="hidden" name="business" value="">
<input type="hidden" name="item_name" value="">
<input type="hidden" name="item_number" value="AZGB-2010">
<input type="hidden" name="amount" value="39.95">
<input type="hidden" name="shipping" value="1.95">
<input type="hidden" name="tax_rate" value="8.3">
<input type="hidden" name="tax" value="8.3">
<input type="hidden" name="discount_rate">
<input type="hidden" name="discount_rate2">
<input type="hidden" name="on0">
<input type="hidden" name="os0">
<input type="hidden" name="shopping_url" value="/products.html">
<input type="hidden" name="return" value=".com">
<input type="hidden" name="cancel_return" value=".com">
<input type="hidden" name="currency_code" value="USD">
<input type="hidden" name="lc" value="US">
<input type="hidden" name="bn" value="PP-ShopCartBF:btn_cart_SM.gif:NonHosted">
</form>
and here is a small chunk of the .js page:
var coup1="sed77";
function CalculateOrder(form) {
if (form.text1.value == coup1)
{
form.discount_rate.value = "30.66";
form.discount_rate2.value = "30.66";
form.on0.value = "Code";
form.os0.value = " - 25% SED77";
}
}
This code works great if there is only one or two coupon codes, but since they work with non-profit orgs they're now up to 37 codes so the above .js code is getting extremely long and is an administrative pain each time they need to add/remove a code (they have to email me to do it). So what I'm trying to figure out is: 1. Is if there is a way to have this code pull it's information from another source that I can setup where they can add/remove codes themselves 2. It's currently case sensitive so I need to figure out how to either make them all caps or all lowercase on submit - or somehow make it so the case does not matter 3. If a user enters in a code, tax is automatically withheld on the purchase (since non-profits will be the only ones with codes) Anyone have any advice on either of these issues? Thanks in advace for any help!
_____________________________
Regards, Joe Kauffman
|
|
New Messages |
No New Messages |
Hot Topic w/ New Messages |
Hot Topic w/o New Messages |
Locked w/ New Messages |
Locked w/o New Messages |
|
Post New Thread
Reply to Message
Post New Poll
Submit Vote
Delete My Own Post
Delete My Own Thread
Rate Posts
|
|
|