Jump to content
  • Checkout
  • Login
  • Get in touch


The e-commerce.

How do I edit an existing web page coupon javascript, to work remotely with a coupon.js


Recommended Posts

I have a coupon javascript for a Paypal formatted check out, that I stopped using for a few reasons. The first problem I consider a major one. The script is written for each item separately. That means, if you have 400 items that you sell, you need to go into each item to remove or change the coupon code (Daily, weekly, monthly etc). The other problem is that the script was written in such a way, that it exposes the coupon code within the javascript on the page. That means anyone who knows anything about web pages, could go in and read the page source to find the coupon code.

Is there any way to separate this script into a two part javascript? One part would be on the web page and the other part would be accessed as a coupon.js file. I would also like to get rid if the "  alert('Processing Your Order . . .');  form.submit();" popup alert section of the script. I tried to remove it but the script will no longer work. I would also like to know, if there is any way to modify this script to offer an option for one to several coupon codes at one time?

Thank you in advance for any help or scripting changes you can offer.



Here is a version of the script as a sample:


function validate( text1, text2 ) {

  if ( text1 == text2 ) {
    window.alert( "Your 10% Discount For This Item Has Been Applied!" );
  if ( text1 !== text2 ) {
    window.alert( "Sorry, No Discount Currently Available For That Code!" );

function CalculateOrder( form ) {

  if ( form.text1.value == "STAR10" ) {
    form.discount_rate.value = "10";
    form.discount_rate2.value = "10";
    form.on3.value = "Coupon Entered";
    form.os3.value = "STAR10";
  alert('Processing Your Order . . .');



<form target="_new" action="https://www.paypal.com/cgi-bin/webscr" method="post">
<input type="hidden" name="cmd" value="_cart"/>
<input type="hidden" name="add" value="1"/>
<input type="hidden" name="business" value="[email protected]"/>
<input type="hidden" name="item_name" value="Crystal Casket"/>
<input type="hidden" name="amount" value="50.00"/>
<input type="hidden" name="currency_code" value="USD"/>
<input type="hidden" name="no_shipping" value="2">
<input type="hidden" name="weight_unit" value="lbs">
<input type="hidden" name="baseamt" value="50.00"/>
<input type="hidden" name="item_number" value="15432">
<input type="hidden" name="discount_rate" value="">
<input type="hidden" name="discount_rate2" value="">
<input type="hidden" name="on3" value="">
<input type="hidden" name="os3" value="">


<font face="arial" size="2">Enter Coupon Code Below</font>
<input type="text" name="text1">
<input type="button" value="Check It" name="Submit" onclick='javascript&colon;validate(form.text1.value, "STAR10")'>
<input type="button" alt="Add to Cart" src="add_to.png" value="add to cart" onclick='CalculateOrder(form)'/>
<font face="arial" size="2" color="red"><b><i>(See pop-up at top of page to confirm activation)</i></b></font>


Link to comment
Share on other sites


This topic is now archived and is closed to further replies.

  • Create New...