Knowledgebase: Specific Products > ShopCart
Setting Minimum or Maximum Item Quantities for ShopCart
Posted by Doug Sherman (Import), Last modified by Doug Sherman on 04 Mar 14 10:57 AM

You can set minimum and/or maximum item quanties per item by adding some javascript to your product pages and tinkering a bit with our Add to Cart HTML to work with this Javascript.

You can see quantity min/max control in action here.

Here are the steps to follow:

First, add this javascript include to your product page/s:

<script language="Javascript" src=""></script>

Next, in order to adapt our existing HTML to use this javascript, you will need to do each of the following:

1.Modify our current opening form tag for each item you want to limit, and set the min and/or max limit in the onsubmit code, ie, change:

<FORM ACTION="" ENCTYPE="application/x-www-form-urlencoded" METHOD="post">


<FORM ACTION="" ENCTYPE="application/x-www-form-urlencoded" METHOD="post" onsubmit="maxqty = 10;minqty = 3;if (!ChkQty (this))return false;" >

(set the maxqty and minqty values to the appropriate values)

2.  Second, you must expose our quantity field, so that your customer can enter the quantity on your product page rather than in our cart. This is a simple matter of changing the "TYPE" our "quantity" form field in your Add to Cart html from "hidden" to "text", ie, from:

<INPUT TYPE="hidden" NAME="quantity" VALUE="1">


<INPUT TYPE="text" name="quantity" size="3" value="1">

That will "expose" a text box on your product page next to the Add to Cart button. You should add a label to it so that your customer knows what it is for.

Also, to prevent quantity from being editable in the cart, change the value of the "undefined_quantity" form field from "1" to "0":
<INPUT TYPE="hidden" NAME="undefined_quantity" VALUE="0">

That's it!


NOTE:  AuctionInc also supports setting quantity discounts, as described in this article. You can combine both functionalities by:

1) Adding another javascript include: <script language="Javascript" src=""></script>

2) Tweaking the other form fields as described in the article;

3) Adding an additional function call to this javascript in your Form onsubmit (refer to article for description of SetAmt): "onsubmit="SetAmt(1, 10, 5, 9, 10, 8); return ReadForm(this)""

An example of combining calls for both would be:

<FORM ACTION="" ENCTYPE="application/x-www-form-urlencoded" METHOD="post" onsubmit="SetAmt(1, 10, 5, 9, 10, 8); maxqty = 10;minqty = 3; if (!ChkQty (this))return false; return ReadForm(this)">

(747 vote(s))
Not helpful

Comments (0)