add to cart button..need second option to add 50% of first option dollar amount total to cart

BigTownSigns
Contributor
Contributor

Ok, so basically im wanting to sell decals on my website...

 

i have a button created and I have been having to tweak it because there were not enough options from the paypal creator ..

 

so i have added more colors to the drop down menu....

 

on the first menu its size=price...

i have added a second drop down below that one which says

 

"second color?

"yes"

"no"

 

if they select yes I would like 50% of the first dropdown to be added to cart...example

 

they choose an 8" decal at $10.66

want a second color

i want the cart to be updated with the 50% addition

so +5.33

 

I have 10 sizes and prices listed in the first menu....can someone explain how to do this to reflect the cart correctly?

 

thanks

David

Big Town Signs

Login to Me Too
1 REPLY 1

snowshoe
Frequent Advisor
Frequent Advisor

Suggest not multiple posting the same question - you just end up waisting time and efforts of others who may be interesting in providing some help.  If everything is one thread, then it's helpful to all.

 

As for what you have in mind, the online button creator does have it limitations as all it was intended for was generating basic HTML Button Code Forms.  What you're looking for has to be custom coded and requires a script to manage the logic. 

 

If you're not a coder yourself, then you're going to need the assistance of a Developer.  

 

If you're into coding your own projects, you first want to start with some of the examples here as they demonstrate how to use PayPal's "discount" variables:

http://ccaples.com/index.php/basic-scripts/examples-i/coupons-using-paypal-s-discount-variables

 

Next, you would need to see how one selection affects another - this is managed by some custom scripting.  Below is an example of how that can be done.   The challenge from there is to combine both the one selection affects another and the discount variables.   The scope of this forum is not intended to provide folks with free custom solutions but, more to give them a better general idea of what can be done.

 

<!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 type=text/javascript>
<!--
var unframed = new Array (  // unframed array
  "Summer Scape - Unframed",
  "Winter Scape - Unframed",
  "Fall Scape - Unframed",
  "Spring Scape - Unframed"
);
var framed = new Array (  // framed array
  "Summer Scape - Framed",
  "Winter Scape - Framed",
  "Fall Scape - Framed",
  "Spring Scape - Framed"
);

function Mod1 (obj) {  // write new data inbto select
var i,pos;
  obj.form.os0.options.length = 0;  // clear the old values
  pos = obj.selectedIndex;          // item selected

  if (pos == 1) {  // unframed prints
    for (i=0; i<unframed.length; i++) {
      var opt = new Option (unframed[i], unframed[i]);
      obj.form.os0.options[i] = opt;
	  obj.form.amount.value = 100.00;
	  obj.form.item_number.value = "WP-UF-0000";
	  obj.form.on1.value = "$100.00";
	  obj.form.os1.value = "ea";
	  obj.form.shipping.value = "15.00";
	  obj.form.shipping2.value = "0.00";
    }
  }
  if (pos == 2) {  // framed prints
    for (i=0; i<framed.length; i++) {
      var opt = new Option (framed[i], framed[i]);
      obj.form.os0.options[i] = opt;
	  obj.form.amount.value = 200.00;
	  obj.form.item_number.value = "WP-F-0000";
	  obj.form.on1.value = "$200.00";
	  obj.form.os1.value = "ea";
	  obj.form.shipping.value = "20.00";
	  obj.form.shipping2.value = "20.00";
    }
  }

}
//-->
</SCRIPT>
<!-- End of Script -->


</head>

<body>

<!-- START SAMPLE CODE SECTION -->


<!-- PARAGRAPH 1 -->
Script Examples

<br><br><br>

One Selection Affects Another.

<br><br>

Widget Prints

<br><br>
<!-- START CONTENTS -->

<!-- START BUTTON EXAMPLES -->

<!-- Start of Add to Cart Form -->
<!-- Note: target="paypal" was replaced with target="_self" -->
<!-- Note: shopping_url also added to code -->
<!-- These two changes allow better functionality with IE and Firefox --> 
<FORM onsubmit="this.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. -->
<input type="hidden" name="cpp_header_image" value="https://www.yourwebsite.com/logo.jpg">
<input type="hidden" name="add" value="1">
<input type="hidden" name="cmd" value="_cart">
<!-- Replace "business" value with your PayPal Email Address or your Merchant Account ID -->
<input type="hidden" name="business" value="your email address">
<input type="hidden" name="item_name" value="Widget Print">
<input type="hidden" name="item_number">
<input type="hidden" name="amount">
<input type="hidden" name="no_shipping" value="2">
<input type="hidden" name="shipping">
<input type="hidden" name="shipping2">
<input type="hidden" name="on1">
<input type="hidden" name="os1">
<!-- Replace value with the web page you want the customer to return to -->
<input type="hidden" name="shopping_url" value="http://www.yourwebsite.com/Script_15.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">
<SELECT onchange="Mod1 (this);">
<OPTION selected>- Please Select -</OPTION>
<OPTION>Unframed Print - $100 ea - Shipping $15 first item / $0 ea additional item</OPTION>
<OPTION>Framed Print - $200 ea - - Shipping $20 first item / $20 ea additional item</OPTION>
</SELECT>
<BR><BR>
<INPUT type="hidden" value="Selected Print" name="on0">
<SELECT name=os0>
<OPTION selected>------</OPTION>
</SELECT>
<BR><BR>
Enter number of Prints:&nbsp;&nbsp;<INPUT size="3" value="1" name="quantity">
<input type="reset" name="reset" value="Clear">
<BR><BR><BR>
<input type="image" src="https://www.paypalobjects.com/en_US/i/btn/btn_cart_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 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. -->
<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 your Merchant 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/Script_15.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 your Merchant Account ID.

</body>
</html>

 

 

 

 

Login to Me Too

Haven't Found your Answer?

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