+ Reply to Thread
Results 1 to 2 of 2

Thread: Promo Codes with Paypal Buttons

  1. #1
    driveflexfuel is offline x10 Sophmore driveflexfuel is an unknown quantity at this point
    Join Date
    Jul 2008
    Posts
    159

    Promo Codes with Paypal Buttons

    I like paypal cart over google cart and now you can make your own promotion codes for paypal cart. I use the code below and it works great. If you are worried about security you can place the script in a .js file and secure the include folder. I hope this helps out some of you useing paypal carts.

    Code:
    <script type="text/javascript">
    <!--
    var discnt = 0;   // no default percent discount
    
    var coupons = new Array (  // place to put coupon codes
      "coup1",                 // 1st coupon value - comma seperated
      "coup2",                 // 2nd coupon value - add all you want
      "coup3"                  // 3rd coupon value
    );
    var coupdc  = new Array (  // place to put discounts for coupon vals
      5,
      10,
      15
    );
    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 Dollar (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.baseamt.value*1.0;       // base amount
      des = obj1.basedes.value;           // base description
    
      if (discnt > 0) {                   // only if discount is active
        amt = Dollar (amt - discnt);
        des = des + ", " + "$" + discnt + "dis, COUP = " + coupval;
      }
    
      obj1.amount.value = Dollar (amt);
      obj1.item_name.value = des;
    }
    //-->
    </script>
    </head>
    <body>
    
    <form action="https://www.paypal.com/cgi-bin/webscr" method="post" onsubmit="this.target = 'paypal';
              return ReadForm (this);">
    <p>
    <input type="hidden" name="cmd" value="_cart" />
    <input type="hidden" name="add" value="1" />
    <input type="hidden" name="business" value="Emailaddress.com" />
    <input type="hidden" name="item_name" value="Item Name" />
    <input type="hidden" name="amount" value="000.00" />
    <input type="hidden" name="currency_code" value="USD" />
    <input type="hidden" name="no_shipping" value="2" />
    <input type="hidden" name="no_note" value="1" />
    <input type="hidden" name="lc" value="US">
    <input type="hidden" name="bn" value="PP-ShopCartBF">
    
    <!-- Base Price -->
    <input type="hidden" name="baseamt" value="0.00" />
    <!-- Base Discription -->
    <input type="hidden" name="basedes" value="4VAB-EV1 @369.99" />
    
    Enter Coupon code:
    <input type     = "text" 
           size     = "10"
           name     = "coupcode"; /> 
     &nbsp; &nbsp; 
    
    
    <input type="button" value="Varify Promo" 
    onclick="coupval = this.form.coupcode.value;
             ChkCoup();" />
    <br /><br />
    
       <!--Page Contents-->
    
    Input quantity &gt;  
    <input type="text" name="quantity" value="1" size="4" />
    &nbsp; &nbsp; 
    
    <input type="image" src="addcart.gif" name="submit" alt="cart add" />
    
    </p>
    </form>

  2. #2
    markarkark is offline x10Hosting Member markarkark is an unknown quantity at this point
    Join Date
    Nov 2010
    Posts
    1

    Re: Promo Codes with Paypal Buttons

    I have tried to use this and can't figure out how to have it affect my buttons I created in paypal. Do you have instructions on how to do this?

+ Reply to Thread

Similar Threads

  1. image bufferring
    By kbjradmin in forum Programming Help
    Replies: 3
    Last Post: 09-24-2008, 01:45 PM
  2. Soljas Revenge
    By koopa in forum Review My Site
    Replies: 4
    Last Post: 09-21-2008, 10:04 PM
  3. My custom forum.
    By compwhizii in forum Review My Site
    Replies: 2
    Last Post: 09-21-2008, 04:42 PM
  4. NoPayPal
    By AdView in forum Computers & Technology
    Replies: 10
    Last Post: 05-01-2008, 01:45 AM
  5. Mobile phone Codes
    By greeting in forum Computers & Technology
    Replies: 10
    Last Post: 03-28-2008, 07:08 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
x10hosting free hosting for the masses
dedicated servers