Paypal add to cart multiple items form with discount

guipromalic

New Member
I'm trying to offer a discount based on the purchase amount of the buyer using a paypal Add to Cart form. Basically I'm giving out for discount codes Disc1, Disc2, Disc3, Disc4, which will discount $5, $10, $20, $50. But each can work only if the purchase amount exceeds the $25, $50, $100, $250 respectively. I'm trying to do this by calling a Javascript file which will apply the discount if the minimum price conditions are met.The PROBLEM is that the form is for multiple items. So the variable for "amount" is not there, but there's different amounts for each option, so option_amount0, option_amount1, option_amount2.... etc. I can make the code work if there was one "amount", but not like here with multiple items/prices. The HTML code looks like this: \[code\] <head><script language="JavaScript" type="text/javascript" src="http://stackoverflow.com/questions/7840611/coupon.js"></script></head> <form target="_blank" action="https://www.paypal.com/cgi-bin/webscr" method="post"> <input type="hidden" name="cmd" value="http://stackoverflow.com/questions/7840611/_cart"> <input type="hidden" name="business" value="http://stackoverflow.com/questions/7840611/[email protected]"> <input type="hidden" name="lc" value="http://stackoverflow.com/questions/7840611/US"> <input type="hidden" name="item_name" value="http://stackoverflow.com/questions/7840611/Products"> <input type="hidden" name="button_subtype" value=""> <input type="hidden" name="no_shipping" value="http://stackoverflow.com/questions/7840611/1"> <input type="hidden" name="undefined_quantity" value="http://stackoverflow.com/questions/7840611/1"> <input type="hidden" name="rm" value="http://stackoverflow.com/questions/7840611/1"> <input type="hidden" name="return" value="http://stackoverflow.com/questions/7840611/www.website.com"> <input type="hidden" name="cancel_return" value="http://stackoverflow.com/questions/7840611/www.website.com"> <input type="hidden" name="currency_code" value="http://stackoverflow.com/questions/7840611/USD"> <input type="hidden" name="tax_rate" value="http://stackoverflow.com/questions/7840611/0.000"> <input type="hidden" name="shipping" value="http://stackoverflow.com/questions/7840611/0.00"> <input type="hidden" name="add" value="http://stackoverflow.com/questions/7840611/1"> <input type="hidden" name="bn" value="http://stackoverflow.com/questions/7840611/PP-ShopCartBF:btn_cart_LG.gif:NonHosted"> <table> <tr><td><br /><h4> <center><input type="hidden" name="on0" value="http://stackoverflow.com/questions/7840611/Products">Choose a Product</center></h4></td></tr><tr><td><center> <select name="os0" style="width: 230px"></center> <option value="http://stackoverflow.com/questions/7840611/item1">Product 1 : $15</option> <option value="http://stackoverflow.com/questions/7840611/item2">Product 2 : $25</option> <option value="http://stackoverflow.com/questions/7840611/item3">Product 3 : $75</option> <option value="http://stackoverflow.com/questions/7840611/item4">Product 4 : $150</option> <option value="http://stackoverflow.com/questions/7840611/item5">Product 5 : $300</option> </select> </td></tr> </table> <input type="hidden" name="currency_code" value="http://stackoverflow.com/questions/7840611/USD"> <input type="hidden" name="option_select0" value="http://stackoverflow.com/questions/7840611/item1"> <input type="hidden" name="option_amount0" value="http://stackoverflow.com/questions/7840611/15.00"> <input type="hidden" name="option_select1" value="http://stackoverflow.com/questions/7840611/item2"> <input type="hidden" name="option_amount1" value="http://stackoverflow.com/questions/7840611/25.00"> <input type="hidden" name="option_select2" value="http://stackoverflow.com/questions/7840611/item3"> <input type="hidden" name="option_amount2" value="http://stackoverflow.com/questions/7840611/75.00"> <input type="hidden" name="option_select3" value="http://stackoverflow.com/questions/7840611/item4"> <input type="hidden" name="option_amount3" value="http://stackoverflow.com/questions/7840611/150.00"> <input type="hidden" name="option_select4" value="http://stackoverflow.com/questions/7840611/item4"> <input type="hidden" name="option_amount4" value="http://stackoverflow.com/questions/7840611/300.00"> <input type="hidden" name="option_index" value="http://stackoverflow.com/questions/7840611/0"> <input type="hidden" name="discount_amount"> <br /> <!-- Enter Coupon --> <center>Coupon Code:</span> <br /> <input type="text" name="text1" /> </center> <br /> <!-- End Coupon --> <input type="image" src="http://stackoverflow.com/questions/7840611/images/btn_cart.gif" border="0" onclick=CalculateOrder(this.form) name="submit" alt="PayPal - The safer, easier way to pay online!"> <img alt="" border="0" src="http://stackoverflow.com/questions/7840611/images/btn_cart.gif" width="1" height="1"> </form>\[/code\]The Javascript file is: \[code\]var coup1="Disc1";var coup2="Disc2";var coup3="Disc3";var coup4="Disc4";function CalculateOrder(form) {if (form.text1.value =http://stackoverflow.com/questions/7840611/= coup1 && ((form.option_amount.value>=25))){form.discount_amount.value ="5";}if (form.text1.value =http://stackoverflow.com/questions/7840611/= coup2 && ((form.option_amount.value>=50))){form.discount_amount.value ="10";}if (form.text1.value =http://stackoverflow.com/questions/7840611/= coup3 && ((form.option_amount.value>=100))){form.discount_amount.value ="20";}if (form.text1.value =http://stackoverflow.com/questions/7840611/= coup4) && ((form.option_amount.value>=250))){form.discount_amount.value ="50";}}\[/code\]How can I make the script account for the option_amount from the HTML form? Any help would be greatly appreciated!
 
Top