Perlshop 4 - The QTY_MIN and QTY_MAX Tags

Overview

The QTY_MIN and QTY_MAX tags were introduced with limited functionality in Perlshop 4.2.07, with full functionality introduced with Perlshop 4.2.08. Unless otherwise noted, this document describes the complete function set for these new tags.

Under normal circumstances, the quantity value for a given item in your store can be any number at all. These tags can be used to place limits on the quantity value, allowing you to enforce rules like "Only one per customer".


Examples

The following example shows a catalog item with an enforced quantity range of 2..5:
<form name="demo" method=post action="!MYURL!">

<input type=hidden name="order_id" value="!ORDERID!">
<input type=hidden name="item_id" value="item_001">
<input type=hidden name="item_name" value="Widget 1">
<input type=hidden name="item_price" value="4.50">
<input type=hidden name="qty_min" value="2">
<input type=hidden name="qty_min" value="5">
<input type=text   name="qty" value="0" size=4 maxlength=4>
<input type=submit name="action" value="Order">

</form>


Using the tags

The qty_min an qty_max tags are both optional. If either is used, the value of the tag must be an integer value greater than 1. If both are used, the value of the qty_max tag should be greater than the value of the qty_min tag. Perlshop does no error checking to ensure that you have set these values correctly.


How these tags are used by Perlshop

There are two circumstances under which Perlshop 4 will use these tag values. The first case is adding new items to a shopping cart. The second case is when the update button on the shopping cart screen is used to alter an item quantity.

When adding new items to a shopping cart, Perlshop will check for the presense of qty_min and qty_max tags. If the item quantity falls outside the limits specified by these tags, the quantity will be altered so that the limits are respected. If the quantity falls below the specified minimum, Perlshop will set the item quantity to the specified minimum. If the quantity falls above the specified maximum, Perlshop will set the item quantity to the specified maximum. If either of these conditions occurs, an error message will be displayed above the shopping cart display that informs the customer of the adjusted quantity value.

Similar behavior will occur when using the quantity update button on the shopping cart display screen.

A special case exists for the quantity update button when the qty_min and qty_max values are set to the same value. In this case, the quantity value will be displayed without using a quantity box for that item. This is useful for situations in which a fixed quantity must be used for a given item.


More Examples

This example shows a catalog item with an enforced upper quantity limit of 10:
<form name="demo" method=post action="!MYURL!">

<input type=hidden name="order_id" value="!ORDERID!">
<input type=hidden name="item_id" value="item_002">
<input type=hidden name="item_name" value="Widget 2">
<input type=hidden name="item_price" value="4.50">
<input type=hidden name="qty_max" value="10">
<input type=text   name="qty" value="0" size=4 maxlength=4>
<input type=submit name="action" value="Order">

</form>

This example shows a catalog item with an enforced lower quantity limit of 5:

<form name="demo" method=post action="!MYURL!">

<input type=hidden name="order_id" value="!ORDERID!">
<input type=hidden name="item_id" value="item_003">
<input type=hidden name="item_name" value="Widget 3">
<input type=hidden name="item_price" value="4.50">
<input type=hidden name="qty_min" value="5">
<input type=text   name="qty" value="0" size=4 maxlength=4>
<input type=submit name="action" value="Order">

</form>

This example shows a catalog item with an enforced quantity value of 1:

<form name="demo" method=post action="!MYURL!">

<input type=hidden name="order_id" value="!ORDERID!">
<input type=hidden name="item_id" value="item_003">
<input type=hidden name="item_name" value="Widget 3">
<input type=hidden name="item_price" value="4.50">
<input type=hidden name="qty_min" value="1">
<input type=hidden name="qty_max" value="1">
<input type=hidden name="qty" value="1">
<input type=submit name="action" value="Order">

</form>