Aug
04
Shopping Cart : Product Quantity
Read the rest of this entry »
I found a few reason why using drop-down menu for product quantity instead of text field could be better (product_info.php and shopping_cart.php files):
- With tracking inventory, it’s possible to setup a max number of products that could be added to the shopping cart
- It’s easy to set a default value other than 1. For the parts store there is always required number of parts per assembly
function tep_select_quantity(
$name = 'quantity',
$start = '1', $end = MAX_QTY_IN_CART,
$selected = 0, $param ='' ) {
for( $i = $start; $i <= $end; ++$i ) {
$quantity[] = array('id' => $i, 'text' => ' ' . $i . ' ');
}
return tep_draw_pull_down_menu (
$name, $quantity, $selected, "class=\"{$name}\" {$param}");
}
- The method could be used with default values for most cases.
- For the shopping cart page, as a parameter, we can pass a JavaScript as follows: onchange=”document.forms['cart_quantity'].submit ();”
With adding an additional link Remove, we don’t need Update’ button any longer. Check the web site to see this modification in action