Search the Community
Showing results for tags 'discount'.
-
so I have a custom store built off of PHP, JS and CSS and it sells virtual coins for a game and the coins are sent automatically by the script however I want to start offering discounts to customers via discounts codes and I currently came across this script that I have put together: Javascript <!-- var discnt = 0; // no default percent discount var coupons = new Array ( // place to put coupon codes "MavrkHD", "TheFUTBucks", "TOTW", "Mega", "LL" ); var coupdc = new Array ( // place to put discounts for coupon vals "10", "15", "7", "10", "20" ); var coupval = "(blanket)"; // what user entered as coupon code function ChkCoup () { // check user coupon entry var i; discnt = 0; // assume the worst for (i=0; i<coupons.length; i++) { if (coupval == coupons[i]) { discnt = coupdc[i]; // remember the discount amt alert ("This is a valid promo code! \n\n" + discnt + "%" + " discount now in effect."); return; } } alert ("'" + coupval + "' is not a valid promo code!"); } function Sterling (val) { // force to valid dollar amount var str,pos,rnd=0; if (val < .995) rnd = 1; // for old Netscape browsers str = escape (val*1.0 + 0.005001 + rnd); // float, round, escape pos = str.indexOf ("."); if (pos > 0) str = str.substring (rnd, pos + 3); return str; } function ReadForm (obj1) { // apply the discount var amt,des; amt = obj1.amount.value*1.0; // base amount des = obj1.basedes.value; // base description if (discnt > 0) { // only if discount is active amt = Sterling (amt - (amt * discnt/100.0)); des = des + " - " + discnt + "% off - COUP = " + coupval; } obj1.baseamt.value = Sterling (amt); obj1.item_name.value = des; } //--> </script> PayPal Form Details <form action="https://www.paypal.com/cgi-bin/webscr" method="post" onsubmit="this.target = 'paypal'; return ReadForm (this);"> <input type="hidden" name="cmd" value="_xclick" /> <input type="hidden" name="add" value="1" /> <input type="hidden" name="business" value="<?=$functions->getPayPal();?>" /> <input type="hidden" name="item_name" value="Online Coin Currency" /> <input type="hidden" name="amount" id="amount" value="0.00" /> <input type="hidden" name="currency_code" value="GBP" /> <input type="hidden" name="baseamt" id="amount" value="0.00" /> <input type="hidden" name="basedes" value="Online Coin Currency (FUT)" /> <input type="hidden" name="custom" id="custom" value=""> <input type="hidden" name="return" value="RETURN LINK HERE";?> <input type="hidden" name="notify_url" value="<?=HOST.'files/payments/paypal.php';?>"> <input type="hidden" name="cancel_return" value="<?=HOST.'cancelled';?>"> Enter Coupon code <input type = "text" size = "10" name = "coupcode"; /> <input type="button" value="Apply code" onclick="coupval =this.form.coupcode.value; ChkCoup();" /><br/><br/> <input type="image" id="xx" src="https://www.paypalobjects.com/WEBSCR-640-20110306-1/en_US/i/btn/btn_buynowCC_LG.gif" border="0" name="submit" onclick="CalculateOrder(this.form)" alt="PayPal - The safer, easier way to pay online!"> <img alt="" border="0" src="https://www.paypalobjects.com/WEBSCR-640-20110306-1/en_US/i/scr/pixel.gif" width="1" height="1"> </form> So, it all works like sending information to PayPal I have one issue about PayPal displaying the calculated prices. For example: if I take out the id of amount and baseamt and just leave value and put a value of 12.99 and then go on my store and go through the process of buying the virtual coins and then get to the discount code area and proceed to paypal I will get a discount price to pay at paypal but when I use the id="amount" which is a variable for depending on how many coins the customer to buy it'll send that price to paypal, it doesn't discount the price and I have been trying endlessly to fix this! help? Thanks.
-
Hi, I am having a problem that I was hoping someone here would be able to assist me with. Basically its for an online shop. Some of the products have special offers on them when the number of customer reach up to a perticaulal number.I have two tables in my database. One to hold the information about the product, and one to hold the information about user price quote table. 1.Product table(retailer table) price | no.of customers | Offer1 |no.of custmers | offer2 $200 | 10 | $100 | 5 | $90 2.Quote(User table) Price | High | Low $200 | $400 | $80 The number of users who have registered for a product reaches the number limit set by the retailer, i.e. 10, then the new offer is $100, i need to sent out this new offer to the users. I have to get the count of customers whos price range of the product is equal to the product price in the product table.Then i need to comapre this count to no.of customers and if it matches i need to set the offer. Any help would be appreciated. Thank you.