Knowledgebase: Specific Products > ShopCart
Quantity Discounts for ShopCart
Posted by Doug Sherman (Import), Last modified by Doug Sherman on 18 Mar 14 12:22 PM

While our ShopCart supports item price or shipping discounts based on quantity by using coupons, if you dont want to use coupons you can alternatively add this functionality 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 discounts in action here.

Here are the steps to follow:

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

<script language="Javascript" src="http://www.auctioninc.com/js/quantity_discount.js"></script>

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

  1. Add two additional form fields to our html for each item:
    <input type="hidden" name="baseamt" value="10.00">
    <input type="hidden" name="basedes" value="Test Item">
    (the $10.00 is the base value of the item for one unit)
    ('Test Item' is the name of your item)

  2. Set the value of the following form fields to "":
    <INPUT TYPE="hidden" NAME="item_name" VALUE="">
    <INPUT TYPE="hidden" NAME="amount" VALUE="" >

  3. Expose our quantity field, changing it from 'hidden' to 'text' so that it appears on your product page and your customers can enter their preferred quantity:
    <input type="text" name="quantity" size="3" value="1">

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

  4. Finally, modify our form tag for each item to call the Javascript and set the discounted pricing for each item. You will be adding the onsubmit attribute, and setting the values in it.

    An example:

    <FORM ACTION="http://www.auctioninc.com/cart/" ENCTYPE="application/x-www-form-urlencoded" METHOD="post" onsubmit="SetAmt(1, 10, 5, 9, 10, 8); return ReadForm(this)">

    For each item, use either a call to SetAmt() or SetPer(). Populate the call with pairs of values. In each pair, the first item sets the quantity, and the second sets either the price-per0item or the percentage discount.  

    SetAmt() discounts based on fixed amounts. The values set in the example above reflect this pricing:

    1 - 4 $10 each
    5 - 9 $9 each
    10 up $8 each

    SetPer() discounts based on percentage. An example of SetPer would be SetPer (1, 0, 5, 9, 10, 13); which would set this pricing:

    1 - 4 $10 each
    5 - 9 9% off
    10 up 13% off

Here is a full example of an Add to Cart button that supports quantity discounts:

 

<FORM ACTION="http://www.auctioninc.com/cart/" ENCTYPE="application/x-www-form-urlencoded" METHOD="post" onsubmit="SetAmt(1, 10, 5, 9, 10, 8); return ReadForm(this)">

<input type="hidden" name="baseamt" value="10.00">
<input type="hidden" name="basedes" value="test item">

<INPUT TYPE="text" NAME="quantity" size="3"VALUE="1"><br>

<INPUT TYPE="hidden" NAME="cmd" VALUE="_cart">
<INPUT TYPE="hidden" NAME="business" VALUE="1264">

<!-- Item Information -->
<INPUT TYPE="hidden" NAME="item_name" VALUE="">
<INPUT TYPE="hidden" NAME="amount" VALUE="">

<INPUT TYPE="hidden" NAME="item_number" VALUE="123">
<INPUT TYPE="hidden" NAME="item_group" VALUE="">
<INPUT TYPE="hidden" NAME="taxable" VALUE="1">
<INPUT TYPE="hidden" NAME="undefined_quantity" VALUE="0">

<!-- Shipping Information -->
<INPUT TYPE="hidden" NAME="calc_method" VALUE="C">
<INPUT TYPE="hidden" NAME="lot_size" VALUE="1">
<INPUT TYPE="hidden" NAME="weight_lbs" VALUE="0">
<INPUT TYPE="hidden" NAME="weight_oz" VALUE="6">
<INPUT TYPE="hidden" NAME="length" VALUE="">
<INPUT TYPE="hidden" NAME="width" VALUE="">
<INPUT TYPE="hidden" NAME="height" VALUE="">
<INPUT TYPE="hidden" NAME="package" VALUE="T">
<INPUT TYPE="hidden" NAME="insure" VALUE="1">
<INPUT TYPE="hidden" NAME="supp_handling_fee" VALUE="0">

<!-- Carrier Special Services -->
<!-- Add To Cart Button -->
<INPUT TYPE="image" SRC="http://imagehost.auctioninc.com/1/buttons/limeadd.gif" BORDER="0" ALT="Add to Cart" NAME="cart_btn" VALUE="Add to Cart">
</FORM>

 

NOTE:  AuctionInc also supports setting minimum and/or maximum quantities, as described in this article. You can combine both functionalities by:

1) Adding another javascript include: <script language="Javascript" src="http://www.auctioninc.com/js/quantity_minmax.js"></script>

2) Adding an additional function call to this javascript in your Form onsubmit: "maxqty = 10;minqty = 3; if (!ChkQty (this))return false;"

An example of combining calls for both would be:

<FORM ACTION="http://www.auctioninc.com/cart/" 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)">

 

(543 vote(s))
Helpful
Not helpful

Comments (0)