cancel
Showing results for 
Search instead for 
Did you mean: 

How to set maximum quantity for Buy Now button

How to set maximum quantity for Buy Now button

Hello I am a PayPal Standard user and am creating a new Buy Now button.  I need to limit the quantity of the item I am selling to 7 per customer.  I have done a lot of searching online and think this is possible with some custom code.  I don't think Inventory Tracking will help me because I want to limit the quantity per customer, not per item.  

 

Thank you in advance for any help!

 

Juliette

2 REPLIES
Highlighted
Volunteer Advisor

Re: How to set maximum quantity for Buy Now button

Yes, what you have in mind is possible however, you have to manually create the item button code as it requires a script to manage the logic. 

 

Below is a Buy Now example, you can do the same with an Add to Cart - the script works with either. 

 

<!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 -->


<SCRIPT type=text/javascript>
<!--
var maxqty = 9999;
var minqty = 0;
function ChkQty (obj1) {  // check any qty limits on items
var qty;
  qty = obj1.quantity.value;
  if (isNaN (qty)) {
    alert ("Enter a valid number for quantity!");
    ClrQty ();            // always clear the values!
    return false;
  }
  if (qty > maxqty) {
    alert ("You cannot order more than " + maxqty + " items!");
    ClrQty ();
    return false;
  }
  if (qty < minqty) {
    alert ("You must order at least " + minqty + " items!");
    ClrQty ();
    return false;
  }
  ClrQty ();
  return true;
}function ClrQty () {  // Clear out the limits
  maxqty = 9999;
  minqty = 0;
}
//-->
</SCRIPT>


</head>

<body>

<!-- START SAMPLE CODE SECTION -->


<!-- PARAGRAPH 1 -->
Required Fields Script Examples

<br><br>

This example sets a minimum value of 3 and a maximum value of 10 items that may be ordered.&nbsp;&nbsp; You may set either, neither, or both limits.&nbsp;&nbsp; The example also uses the shipping override variables, <i>shipping</i> for 1 book is $3.00 and <i>shipping2</i> for each additional book is $2.00.

<br><br>

Widget Book - $10 each

<br><br>

<!-- Start of Form -->
<FORM 
onsubmit="this.target = 'paypal';&#10; maxqty = 10;&#10; minqty = 3;&#10; if (!ChkQty (this))&#10; return false;" 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="_xclick">
<!-- 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 Book">
<input type="hidden" name="item_number" value="WB-001">
<input type="hidden" name="no_shipping" value="2">
<input type="hidden" name="amount" value="10.00">
<input type="hidden" name="shipping" value="3.00">
<input type="hidden" name="shipping2" value="1.00">
<!-- 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="country" 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-BuyNowBF:btn_buynow_LG.gif:NonHosted">
Quantity:&nbsp;&nbsp;
<input type="text" name="quantity" size="3"> 
<br><br>
<input type="reset" name="reset" value="Reset">
<br><br>
<input type="image" src="https://www.paypalobjects.com/en_US/i/btn/btn_buynow_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 -->



<!-- 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>

 

Re: How to set maximum quantity for Buy Now button

Thank you so much for your speedy reply!  I will give this code a shot and let you know!

 

Thanks again,

Juliette