- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I've done some forum searches for ways to do a coupon or discount code. Near as I could find it is possible to do with the discount variables offering a certain amount or percentage off an item, is there a way to code that portion possible based on information entered in the "text field".
So my site http://www.intervacbagsandmore.com sells a handful of parts. We are thinking of running an ad campaign and want to have a coupon code associated with a discount on dust bags to give us an idea of whether or not this ad is working.
My thought was to change the add to cart button to offer a text area where you would normally put say engraving information in and instead it would be a predesignated coupon code, then through some nifty coding in the advanced variables reduce the price of the item by "X %/$"
Anyone have any experience with this?
Solved! Go to Solution.
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Yes, this can be done using either the "discount" variables with some custom scripting or just some custom scripting.
See this info:
http://ccaples.com/index.php/basic-scripts/examples-i/coupon-codes
And this info:
http://ccaples.com/index.php/basic-scripts/examples-i/coupons-using-paypal-s-discount-variables
Note, the online button creator does have it limitations meaning you can't use the Advanced Variables in Step 3 of the button creation process. The code has to be manually written but, with a bit of scripting and the use of the "discount" variables to manage the logic, you can get creative.
Last, here's an Add to Cart example you can tweak:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <title>Button Example Code</title> <!-- START META TAG SECTION --> <meta charset="utf-8"> <meta http-equiv="Content-Type" content="text/html;charset=utf-8"> <meta http-equiv="Content-Language" content="en"> <!-- END META TAG SECTION --> <!-- Start of Script --> <script language = "javascript"> <!-- function validate(text1,text2) { if (text1 == text2) { window.alert("Nice, you get a 10% Discount!"); } if (text1 !== text2) { window.alert("Sorry, No Discount!"); } } function CalculateOrder(form) { if (form.text1.value == "GOLD10") { form.discount_rate.value = "10"; form.discount_rate2.value = "10"; form.on3.value = "Coupon Entered"; form.os3.value = "GOLD10"; } } //--> </script> <!-- End of Script --> </head> <body> <!-- START SAMPLE CODE SECTION --> <!-- PARAGRAPH 1 --> Discount & Coupon Examples <br><br> Add to Cart - Enter the Promo Coupon Code, Get a 10% Discount, on Screen Validation. <br><br> Notes:<br> This example uses a script to verify the Promo Coupon Code and then applies the associated Discount Rate using the the "discount_rate" and the "discount_rate2" variables. <br><br> Give it a try, the Promo Coupon Code is: GOLD10 <br><br> <!-- START CONTENTS --> <!-- START BUTTON EXAMPLES --> Widgets in Space <br><br> Widget Cupcakes <br><br> <!-- Start of Add to Cart Form --> <!-- Note: target="_self" was replaced with the variable target="_self" --> <!-- Note: shopping_url also added to code --> <!-- These two changes allow better functionality with IE and Firefox --> <form target="_self" action="https://www.paypal.com/cgi-bin/webscr" method="post"> <!-- If using a Business or Company Logo Graphic, include the "cpp_header_image" variable in your View Cart code. --> <input type="hidden" name="cpp_header_image" value="https://yourwebsite.com/logo.jpg"> Please Choose:   <input type="hidden" name="on0" value="Choice"> <select name="os0"> <option value="Standard, 6 each per Box" selected>Standard, 6 each per Box - $9.95</option> <option value="Standard, 12 each per Box">Standard, 12 each per Box - $16.95</option> <option value="Deluxe, 6 each per Box">Deluxe, 6 each per Box - $12.95</option> <option value="Deluxe, 12 each per Box">Deluxe, 12 each per Box - $22.95</option> </select> <!-- option_index value=0 is associated with variable on0 --> <!-- option_index value=1 is associated with variable on1 --> <input type="hidden" name="option_index" value="0"> <!-- --> <input type="hidden" name="option_select0" value="Standard, 6 each per Box"> <input type="hidden" name="option_amount0" value="9.95"> <input type="hidden" name="option_item_number0" value="S-6-BOX"> <!-- --> <input type="hidden" name="option_select1" value="Standard, 12 each per Box"> <input type="hidden" name="option_amount1" value="16.95"> <input type="hidden" name="option_item_number1" value="S-12-BOX"> <!-- --> <input type="hidden" name="option_select2" value="Deluxe, 6 each per Box"> <input type="hidden" name="option_amount2" value="12.95"> <input type="hidden" name="option_item_number2" value="D-6-BOX"> <!-- --> <input type="hidden" name="option_select3" value="Deluxe, 12 each per Box"> <input type="hidden" name="option_amount3" value="22.95"> <input type="hidden" name="option_item_number3" value="D-12-BOX"> <!-- --> <br><br> Cupcake Flavors:   <input type="hidden" name="on1" value="Flavor"> <select name="os1"> <option value="Vanilla Dream" selected>Vanilla Dream</option> <option value="Berry Burst">Berry Burst</option> <option value="Chocolicious">Chocolicious</option> <option value="Carrot Passion">Carrot Passion</option> <option value="Banana Karma">Banana Karma</option> <option value="Mocha-Chococcino">Mocha-Chococcino</option> </select> <br><br> Optional Gift Message:   <input type="hidden" name="on2" value="Optional Gift Message"> <input type="text" name="os2" maxlength="60"> <br><br> <!-- Start Coupon Validate --> Enter Promo Coupon - Get 10% Off:     <input type="text" name="text1"> <input type="button" value="Check It" name="Submit" onclick=javascript:validate(text1.value,"GOLD10") > <!-- End Coupon Validate --> <br><br><br> <input type="image" src="https://www.paypalobjects.com/en_US/i/btn/btn_cart_LG.gif" border="0" onclick=CalculateOrder(this.form) name="submit" alt="Make payments with PayPal - it's fast, free and secure!"> <img alt="" border="0" src="https://www.paypalobjects.com/en_US/i/scr/pixel.gif" width="1" height="1"> <input type="hidden" name="add" value="1"> <input type="hidden" name="cmd" value="_cart"> <!-- Replace "business" value with your PayPal Email Address or Account ID --> <input type="hidden" name="business" value="your email address"> <input type="hidden" name="item_name" value="Widget Cupcakes"> <input type="hidden" name="no_shipping" value="2"> <input type="hidden" name="discount_rate"> <input type="hidden" name="discount_rate2"> <input type="hidden" name="on3"> <input type="hidden" name="os3"> <!-- Replace value with the web page you want the customer to return to --> <input type="hidden" name="shopping_url" value="http://www.yourwebsite.com/Shop.html"> <!-- Replace value with the web page you want the customer to return to after a successful transaction --> <input type="hidden" name="return" value="http://www.yourwebsite.com/ThankYou.html"> <!-- Replace value with the web page you want the customer to return to after item cancellation --> <input type="hidden" name="cancel_return" value="http://www.yourwebsite.com/Cancel.html"> <input type="hidden" name="currency_code" value="USD"> <input type="hidden" name="lc" value="US"> <input type="hidden" name="button_subtype" value="products"> <input type="hidden" name="no_note" value="0"> <input type="hidden" name="cn" value="Add special instructions to the seller:"> <input type="hidden" name="bn" value="PP-ShopCartBF:btn_cart_LG.gif:NonHosted"> </form> <!-- End Add to Cart Button Code --> <br> <!-- Start of View Cart Button Code --> <form target="_self" action="https://www.paypal.com/cgi-bin/webscr" method="post"> <!-- If using a Business or Company Logo Graphic, include the "cpp_header_image" variable in your View Cart code. --> <input type="hidden" name="cpp_header_image" value="https://yourwebsite.com/logo.jpg"> <input type="hidden" name="cmd" value="_cart"> <input type="hidden" name="display" value="1"> <!-- Replace "business" value with your PayPal Email Address or Account ID --> <input type="hidden" name="business" value="your email address"> <!-- Replace value with the web page you want the customer to return to --> <input type="hidden" name="shopping_url" value="http://www.yourwebsite.com/Shop.html"> <input type="image" src="https://www.paypalobjects.com/en_US/i/btn/btn_viewcart_LG.gif" border="0" name="submit" alt="PayPal - The safer, easier way to pay online!"> <img alt="" border="0" src="https://www.paypalobjects.com/en_US/i/scr/pixel.gif" width="1" height="1"> </form> <!-- End of View Cart Button Code --> <!-- END BUTTON EXAMPLES --> <!-- END SAMPLE CODE SECTION --> <br><br> <br><br><br><br> <hr align="left" width="50%" noshade> <br><br> NOTES: <br> In order to test the code, you must replace the "business" value variable with your PayPal Email Address or Account ID. </body> </html>
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Yes, this can be done using either the "discount" variables with some custom scripting or just some custom scripting.
See this info:
http://ccaples.com/index.php/basic-scripts/examples-i/coupon-codes
And this info:
http://ccaples.com/index.php/basic-scripts/examples-i/coupons-using-paypal-s-discount-variables
Note, the online button creator does have it limitations meaning you can't use the Advanced Variables in Step 3 of the button creation process. The code has to be manually written but, with a bit of scripting and the use of the "discount" variables to manage the logic, you can get creative.
Last, here's an Add to Cart example you can tweak:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <title>Button Example Code</title> <!-- START META TAG SECTION --> <meta charset="utf-8"> <meta http-equiv="Content-Type" content="text/html;charset=utf-8"> <meta http-equiv="Content-Language" content="en"> <!-- END META TAG SECTION --> <!-- Start of Script --> <script language = "javascript"> <!-- function validate(text1,text2) { if (text1 == text2) { window.alert("Nice, you get a 10% Discount!"); } if (text1 !== text2) { window.alert("Sorry, No Discount!"); } } function CalculateOrder(form) { if (form.text1.value == "GOLD10") { form.discount_rate.value = "10"; form.discount_rate2.value = "10"; form.on3.value = "Coupon Entered"; form.os3.value = "GOLD10"; } } //--> </script> <!-- End of Script --> </head> <body> <!-- START SAMPLE CODE SECTION --> <!-- PARAGRAPH 1 --> Discount & Coupon Examples <br><br> Add to Cart - Enter the Promo Coupon Code, Get a 10% Discount, on Screen Validation. <br><br> Notes:<br> This example uses a script to verify the Promo Coupon Code and then applies the associated Discount Rate using the the "discount_rate" and the "discount_rate2" variables. <br><br> Give it a try, the Promo Coupon Code is: GOLD10 <br><br> <!-- START CONTENTS --> <!-- START BUTTON EXAMPLES --> Widgets in Space <br><br> Widget Cupcakes <br><br> <!-- Start of Add to Cart Form --> <!-- Note: target="_self" was replaced with the variable target="_self" --> <!-- Note: shopping_url also added to code --> <!-- These two changes allow better functionality with IE and Firefox --> <form target="_self" action="https://www.paypal.com/cgi-bin/webscr" method="post"> <!-- If using a Business or Company Logo Graphic, include the "cpp_header_image" variable in your View Cart code. --> <input type="hidden" name="cpp_header_image" value="https://yourwebsite.com/logo.jpg"> Please Choose:   <input type="hidden" name="on0" value="Choice"> <select name="os0"> <option value="Standard, 6 each per Box" selected>Standard, 6 each per Box - $9.95</option> <option value="Standard, 12 each per Box">Standard, 12 each per Box - $16.95</option> <option value="Deluxe, 6 each per Box">Deluxe, 6 each per Box - $12.95</option> <option value="Deluxe, 12 each per Box">Deluxe, 12 each per Box - $22.95</option> </select> <!-- option_index value=0 is associated with variable on0 --> <!-- option_index value=1 is associated with variable on1 --> <input type="hidden" name="option_index" value="0"> <!-- --> <input type="hidden" name="option_select0" value="Standard, 6 each per Box"> <input type="hidden" name="option_amount0" value="9.95"> <input type="hidden" name="option_item_number0" value="S-6-BOX"> <!-- --> <input type="hidden" name="option_select1" value="Standard, 12 each per Box"> <input type="hidden" name="option_amount1" value="16.95"> <input type="hidden" name="option_item_number1" value="S-12-BOX"> <!-- --> <input type="hidden" name="option_select2" value="Deluxe, 6 each per Box"> <input type="hidden" name="option_amount2" value="12.95"> <input type="hidden" name="option_item_number2" value="D-6-BOX"> <!-- --> <input type="hidden" name="option_select3" value="Deluxe, 12 each per Box"> <input type="hidden" name="option_amount3" value="22.95"> <input type="hidden" name="option_item_number3" value="D-12-BOX"> <!-- --> <br><br> Cupcake Flavors:   <input type="hidden" name="on1" value="Flavor"> <select name="os1"> <option value="Vanilla Dream" selected>Vanilla Dream</option> <option value="Berry Burst">Berry Burst</option> <option value="Chocolicious">Chocolicious</option> <option value="Carrot Passion">Carrot Passion</option> <option value="Banana Karma">Banana Karma</option> <option value="Mocha-Chococcino">Mocha-Chococcino</option> </select> <br><br> Optional Gift Message:   <input type="hidden" name="on2" value="Optional Gift Message"> <input type="text" name="os2" maxlength="60"> <br><br> <!-- Start Coupon Validate --> Enter Promo Coupon - Get 10% Off:     <input type="text" name="text1"> <input type="button" value="Check It" name="Submit" onclick=javascript:validate(text1.value,"GOLD10") > <!-- End Coupon Validate --> <br><br><br> <input type="image" src="https://www.paypalobjects.com/en_US/i/btn/btn_cart_LG.gif" border="0" onclick=CalculateOrder(this.form) name="submit" alt="Make payments with PayPal - it's fast, free and secure!"> <img alt="" border="0" src="https://www.paypalobjects.com/en_US/i/scr/pixel.gif" width="1" height="1"> <input type="hidden" name="add" value="1"> <input type="hidden" name="cmd" value="_cart"> <!-- Replace "business" value with your PayPal Email Address or Account ID --> <input type="hidden" name="business" value="your email address"> <input type="hidden" name="item_name" value="Widget Cupcakes"> <input type="hidden" name="no_shipping" value="2"> <input type="hidden" name="discount_rate"> <input type="hidden" name="discount_rate2"> <input type="hidden" name="on3"> <input type="hidden" name="os3"> <!-- Replace value with the web page you want the customer to return to --> <input type="hidden" name="shopping_url" value="http://www.yourwebsite.com/Shop.html"> <!-- Replace value with the web page you want the customer to return to after a successful transaction --> <input type="hidden" name="return" value="http://www.yourwebsite.com/ThankYou.html"> <!-- Replace value with the web page you want the customer to return to after item cancellation --> <input type="hidden" name="cancel_return" value="http://www.yourwebsite.com/Cancel.html"> <input type="hidden" name="currency_code" value="USD"> <input type="hidden" name="lc" value="US"> <input type="hidden" name="button_subtype" value="products"> <input type="hidden" name="no_note" value="0"> <input type="hidden" name="cn" value="Add special instructions to the seller:"> <input type="hidden" name="bn" value="PP-ShopCartBF:btn_cart_LG.gif:NonHosted"> </form> <!-- End Add to Cart Button Code --> <br> <!-- Start of View Cart Button Code --> <form target="_self" action="https://www.paypal.com/cgi-bin/webscr" method="post"> <!-- If using a Business or Company Logo Graphic, include the "cpp_header_image" variable in your View Cart code. --> <input type="hidden" name="cpp_header_image" value="https://yourwebsite.com/logo.jpg"> <input type="hidden" name="cmd" value="_cart"> <input type="hidden" name="display" value="1"> <!-- Replace "business" value with your PayPal Email Address or Account ID --> <input type="hidden" name="business" value="your email address"> <!-- Replace value with the web page you want the customer to return to --> <input type="hidden" name="shopping_url" value="http://www.yourwebsite.com/Shop.html"> <input type="image" src="https://www.paypalobjects.com/en_US/i/btn/btn_viewcart_LG.gif" border="0" name="submit" alt="PayPal - The safer, easier way to pay online!"> <img alt="" border="0" src="https://www.paypalobjects.com/en_US/i/scr/pixel.gif" width="1" height="1"> </form> <!-- End of View Cart Button Code --> <!-- END BUTTON EXAMPLES --> <!-- END SAMPLE CODE SECTION --> <br><br> <br><br><br><br> <hr align="left" width="50%" noshade> <br><br> NOTES: <br> In order to test the code, you must replace the "business" value variable with your PayPal Email Address or Account ID. </body> </html>
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thank you! Can I give you double kudos?! Thank you very much, I'll work on this tomorrow when there is coffee again!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Haven't Found your Answer?
It happens. Hit the "Login to Ask the community" button to create a question for the PayPal community.
- Advanced Variables - multiple shipping options - add to cart button in About Payments (Archive)
- insufficient funds on recurring subscription with trial period in About Payments (Archive)
- Trouble Adding Discount Variable to a Button in About Business (Archive)
- Buy Now Button Variables Help in About Business (Archive)
- Donate button in About Business (Archive)