PLEASE NOTE: These forums are no longer utilized and are provided as an archive for informational purposes only. All support issues will be handled via email using our support ticket system. For more detailed information on this change, please see this blog post.

Another PayPal discount code request

  1. Team Gravity,

    I'm hoping to get some help on how to implement a percentage discount code hack using a javascript option that I found on PayPal's development site. While this is designed to use hidden os0 and os1 values passed through a custom payment button, I've got to think there would be a way to mimic the behavior, just not sure how to implement it.

    Here's the script:

    <script language="JavaScript" >
    var coup1="mydiscount";
    var coup2="GOLD15";//you can use this for other discount codes
    var coup3="GOLD20"; 
    
    function CalculateOrder(form) {
    
    if (form.text1.value == coup1)
    {
    form.discount_rate.value = "20";
    form.discount_rate2.value = "20";
    form.os1.value = "Discount 20%";
    }
    
    //determine the amount based on selection
    if (form.text1.value == coup2)
    {
    form.discount_rate.value = "15";
    form.discount_rate2.value = "15";
    form.os1.value = "Discount 20%";
    }
    if (form.text1.value == coup3)
    {
    form.discount_rate.value = "20";
    form.discount_rate2.value = "20";
    form.os1.value = "Discount 20%";
    }
    
    //determine amount and name of product
    if (form.baseoption.value == "23")
    {
    form.os0.value ="23 Day Diet (2 bottles)";
    form.amount.value = 155;
    }
    if (form.baseoption.value == "40")
    {
    form.os0.value ="40 Day Diet (3 bottles)";
    form.amount.value = 225;
    }
    if (form.baseoption.value == "1")
    {
    form.os0.value ="Single Bottle";
    form.amount.value = 80;
    }
    if (selIndex == 1)
    {
    form.amount.value = Dollar (option1);
    }
    
    }
    </script>

    and the corresponding buy now button code:

    <form action="https://www.paypal.com/cgi-bin/webscr" method="post">
    <input type="hidden" name="cmd" value="_xclick">
    <input type="hidden" name="business" value="xxxxxxxxxxxxxxxxxxxxxxxxxx"><<<<<<<business email addr or id
    <input type="hidden" name="discount_rate">
    <input type="hidden" name="discount_rate2">
    <input type="hidden" name="item_name" value="--need name of item--">
    <table>
    <tr><td><input type="hidden" name="on0" value="SkinnyUp! HCG Drops">SkinnyUp! HCG Drops</td></tr>
    <tr><td>
    <input type="hidden" name="os0">
    <select name="baseoption">
    <option value="23">23 Day Diet (2 bottles) $155.00</option>
    <option value="40">40 Day Diet (3 bottles) $225.00</option>
    <option value="1">Single Bottle $80.00</option>
    </select> </td></tr>
    <tr><td><input type="hidden" name="on1" value="Coupon Code">Coupon Code</td></tr>
    <tr><td><input type="text" name="text1" maxlength="60"><input type="hidden" name="os1"></td></tr>
    </table>
    <input type="hidden" name="amount" value="1.00">
    <input type="hidden" name="currency_code" value="USD">
    <input type="image" 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>

    BTW - I've spent the better part of today looking through the forum and the gf hooks suggested by Carl to accomplish this, but without guidance on where to insert new or modify exisitng code, I'm really at a loss.

    Posted 13 years ago on Friday September 16, 2011 | Permalink
  2. Gravity Forms does not use PayPal payment buttons so any PayPal related payment button hacks involving adding fields to the form are not going to work. The PayPal integration happens via an API and not via a form posted to PayPal.

    In order to integrate some sort of discount code yourself you would have to do it as a customization to Gravity Forms and not PayPal. So you would have to write custom code and interact with Gravity Forms to validate and apply the discount to the order.

    Posted 13 years ago on Monday September 19, 2011 | Permalink
  3. Here is a tutorial written by David Smith on how to add tax to an order form. You could do the reverse to apply discounts. It is a customization, as Carl explained, but it can be done.

    http://www.gravityhelp.com/documentation/page/Gravity_Forms_Pricing:_Adding_Tax

    Posted 13 years ago on Tuesday September 20, 2011 | Permalink
  4. Are there any plans to add a coupon function to the paypal plugin/gravity forms?

    Have an entire form built for a client - and they requested this at the last minute. Not a threat - as I've already purchased the Dev license and love the product- but may have to switch to something else because of it.

    Posted 13 years ago on Sunday September 25, 2011 | Permalink
  5. Ditto "theepiphany"... is a coupon function coming?

    Posted 13 years ago on Tuesday October 4, 2011 | Permalink