If the 'Product Qty Units:' field (database field products.products_quantity_order_units) is set to zero for a product, an error is displayed when adding the product to the cart :
Please update your order.
The item: <item name here> ... Quantity Units errors -
You ordered a total of: 1 Units: 0
While editing an existing product, if the field value is 0, it will be displayed as 1.
(line 378 in admin/includes/modules/product/collect_info.php, and other versions of collect_info.php for other product types).
Code:
<td class="main"><?php echo TEXT_PRODUCTS_QUANTITY_UNITS_RETAIL; ?></td>
<td class="main"><?php echo zen_draw_separator('pixel_trans.gif', '24', '15') . ' ' . zen_draw_input_field('products_quantity_order_units', ($pInfo->products_quantity_order_units == 0 ? 1 : $pInfo->products_quantity_order_units)); ?></td>
This is presumably because the same code is used when setting up new products, and it's desirable to default the field to 1 to prevent this issue happening.
It might also make sense, whenever existing products are edited, to set the field to 1 if it's 0 when the product is saved, to prevent the cart error happening.
But the way it works at the moment, it's masking the issue by displaying different data to what's in the database:
if you do somehow end up with this field set to 0 for some products, and are getting the cart error, checking the product details in admin would lead you to believe that the problem must lie elsewhere.
The code is somewhat incorrect as it is: $pInfo->products_quantity_order_units is a string, not an integer. For new products, it will be an empty string at this point, so evaluates as 0, and hence the field gets set to 1.
If it's an existing product with zero value, the same happens, which is where the problem lies.
It would make more sense to change this line to handle 3 conditions:
if $pInfo->products_quantity_order_units = "" (new product), default the field to 1
if $pInfo->products_quantity_order_units = "0", display as 0, with a warning message that it should always be at least 1
Otherwise display the current value.
Either that or change the value from 0 to 1, but when actually writing the record, not when displaying it.
The same also applies to 'Product Qty Minimum:', but this doesn't cause an issue, since it doesn't matter whether the minimum quantity is 0 or 1 (although it does allow you to add 0 items to your cart).
Bookmarks