How to define a different weight for each drop down option

numpdog
Contributor
Contributor

With a price/option drop down button, I only see how you can define the same weight for whichever option is chosen.  How do you define a different weight for each option in the drop down?

Login to Me Too
1 ACCEPTED SOLUTION

Accepted Solutions
Solved

snowshoe
Frequent Advisor
Frequent Advisor

Sometimes you need take a different approach to your item button coding as the online button creator does have it's limitations.  Below is one example which uses a script to define different weights with different prices.  Feel free to 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 CalculateOrder(form)
{

if (form.os0.value == "Small")
 {
 form.amount.value = 4.00;
 form.item_number.value = "1001-S";
 form.weight.value = ".25";
 }
 
if (form.os0.value == "Medium")
 {
 form.amount.value = 5.00;
 form.item_number.value = "1001-M";
 form.weight.value = ".75";
 }

if (form.os0.value == "Large")
 {
 form.amount.value = 6.00;
 form.item_number.value = "1001-L";
 form.weight.value = ".85";
 }
}  
</SCRIPT>
<!-- End of Script -->


</head>

<body>

<!-- START SAMPLE CODE SECTION -->


<!-- PARAGRAPH 1 -->
Shipping &amp; Delivery Examples

<br><br>

Add to Cart - how to use the Weight Variables in the Script.

<br><br>


Notes:<br>
In order to see shipping rates, you would setup your Profile Shipping Method based on weight.


<br><br><br>


<!-- START CONTENTS -->

<!-- START BUTTON EXAMPLES -->

Widget Candles

<br><br>

<!-- Start of Add to Cart Form -->
<!-- Note: target="paypal" 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://www.yourwebsite.com/logo.jpg"> 
<!--  -->
<input type="hidden" name="on0" value="Size">Select Candle Size:&nbsp;&nbsp;
<SELECT name="os0">
<OPTION value="Small" selected>Small Candle - $4.00 - Weight .25 lb</OPTION>
<OPTION value="Medium">Medium Candle - $5.00 - Weight .75 lb</OPTION>
<OPTION value="Large">Large Candle - $6.00 - Weight .85 lb</OPTION>
</SELECT>
<br><br>
<input type="hidden" name="on1" value="Scent">Select Scent:&nbsp;&nbsp;
<SELECT name="os1">
<OPTION value="Vanilla" selected>Vanilla</OPTION>
<OPTION value="Lavender">Lavender</OPTION>
<OPTION value="Apple Pie">Apple Pie</OPTION>
</SELECT>
<br><br>
<INPUT onclick=CalculateOrder(this.form) type="image" alt="Make payments with PayPal - it's fast, free and secure!" 
src="https://www.paypalobjects.com/en_US/i/btn/btn_cart_LG.gif" border=0 name="submit">
<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 Candle">
<input type="hidden" name="amount">
<input type="hidden" name="item_number">
<input type="hidden" name="no_shipping" value="2">
<input type="hidden" name="weight">
<input type="hidden" name="weight_unit" value="lbs">
<!-- Replace value with the web page you want the customer to return to -->
<input type="hidden" name="shopping_url" value="http://www.yourwebsite.com/Shipping_Delivery_09.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 of Form -->

<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://www.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/Shipping_Delivery_09.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>
<hr align="left" width="50%" noshade>
<br><br>
NOTES:
<br>
In order to test the code, you must replace the &quot;business&quot; value variable with your PayPal Email Address or Account ID.

</body>
</html>

 

View solution in original post

Login to Me Too
5 REPLIES 5
Solved

snowshoe
Frequent Advisor
Frequent Advisor

Sometimes you need take a different approach to your item button coding as the online button creator does have it's limitations.  Below is one example which uses a script to define different weights with different prices.  Feel free to 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 CalculateOrder(form)
{

if (form.os0.value == "Small")
 {
 form.amount.value = 4.00;
 form.item_number.value = "1001-S";
 form.weight.value = ".25";
 }
 
if (form.os0.value == "Medium")
 {
 form.amount.value = 5.00;
 form.item_number.value = "1001-M";
 form.weight.value = ".75";
 }

if (form.os0.value == "Large")
 {
 form.amount.value = 6.00;
 form.item_number.value = "1001-L";
 form.weight.value = ".85";
 }
}  
</SCRIPT>
<!-- End of Script -->


</head>

<body>

<!-- START SAMPLE CODE SECTION -->


<!-- PARAGRAPH 1 -->
Shipping &amp; Delivery Examples

<br><br>

Add to Cart - how to use the Weight Variables in the Script.

<br><br>


Notes:<br>
In order to see shipping rates, you would setup your Profile Shipping Method based on weight.


<br><br><br>


<!-- START CONTENTS -->

<!-- START BUTTON EXAMPLES -->

Widget Candles

<br><br>

<!-- Start of Add to Cart Form -->
<!-- Note: target="paypal" 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://www.yourwebsite.com/logo.jpg"> 
<!--  -->
<input type="hidden" name="on0" value="Size">Select Candle Size:&nbsp;&nbsp;
<SELECT name="os0">
<OPTION value="Small" selected>Small Candle - $4.00 - Weight .25 lb</OPTION>
<OPTION value="Medium">Medium Candle - $5.00 - Weight .75 lb</OPTION>
<OPTION value="Large">Large Candle - $6.00 - Weight .85 lb</OPTION>
</SELECT>
<br><br>
<input type="hidden" name="on1" value="Scent">Select Scent:&nbsp;&nbsp;
<SELECT name="os1">
<OPTION value="Vanilla" selected>Vanilla</OPTION>
<OPTION value="Lavender">Lavender</OPTION>
<OPTION value="Apple Pie">Apple Pie</OPTION>
</SELECT>
<br><br>
<INPUT onclick=CalculateOrder(this.form) type="image" alt="Make payments with PayPal - it's fast, free and secure!" 
src="https://www.paypalobjects.com/en_US/i/btn/btn_cart_LG.gif" border=0 name="submit">
<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 Candle">
<input type="hidden" name="amount">
<input type="hidden" name="item_number">
<input type="hidden" name="no_shipping" value="2">
<input type="hidden" name="weight">
<input type="hidden" name="weight_unit" value="lbs">
<!-- Replace value with the web page you want the customer to return to -->
<input type="hidden" name="shopping_url" value="http://www.yourwebsite.com/Shipping_Delivery_09.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 of Form -->

<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://www.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/Shipping_Delivery_09.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>
<hr align="left" width="50%" noshade>
<br><br>
NOTES:
<br>
In order to test the code, you must replace the &quot;business&quot; value variable with your PayPal Email Address or Account ID.

</body>
</html>

 

Login to Me Too

numpdog
Contributor
Contributor

That looks reasonable, but I haven't been able to get it to work.  The View Cart button works fine, but the Add to Cart button generates a paypal error.  Here is the web page I used to test it: http://www.regardingbooks.com/button_example_code.html

 

Thanks for your help!

Login to Me Too

snowshoe
Frequent Advisor
Frequent Advisor

Look for this line of code:

 

<input type="hidden" name="business" value="your email address">

 

 

You need to replace the "value" with your PayPal Account email address.

 

Do this for both the Add to Cart item button and the View Cart button.

Login to Me Too

numpdog
Contributor
Contributor

Oops, I overlooked that one, thanks!

Login to Me Too

snowshoe
Frequent Advisor
Frequent Advisor

Haven't Found your Answer?

It happens. Hit the "Login to Ask the community" button to create a question for the PayPal community.