Results 1 to 3 of 3
  1. #1
    Join Date
    Aug 2012
    Posts
    5
    Plugin Contributions
    0

    Default While editing product, Product Qty Units displays as 1 if it is 0 on the database

    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') . '&nbsp;' . 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).

  2. #2
    Join Date
    Jan 2004
    Posts
    66,373
    Blog Entries
    7
    Plugin Contributions
    274

    Default Re: While editing product, Product Qty Units displays as 1 if it is 0 on the database

    Quote Originally Posted by Mohirl View Post
    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
    By what process did you arrive at a situation where the field is set to zero for an existing product?
    .

    Zen Cart - putting the dream of business ownership within reach of anyone!
    Donate to: DrByte directly or to the Zen Cart team as a whole

    Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
    Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

  3. #3
    Join Date
    Aug 2012
    Posts
    5
    Plugin Contributions
    0

    Default Re: While editing product, Product Qty Units displays as 1 if it is 0 on the database

    Initially, by not having a clue what I was doing when populating the fields for a product import with EasyPopulate


    But it's also possible to do it through the admin - simply change the field from 1 to 0 when creating or editing a product.

 

 

Similar Threads

  1. Is it possible to hide the product preview while adding and editing them?
    By scaleachiocciola in forum Customization from the Admin
    Replies: 0
    Last Post: 3 May 2012, 02:54 PM
  2. how to mass edit Product qty Min & Max & product qty units?
    By SheenaMad in forum Setting Up Categories, Products, Attributes
    Replies: 3
    Last Post: 17 Oct 2011, 01:46 AM
  3. Doubling Product Qty Units
    By Brendan M. in forum Discounts/Coupons, Gift Certificates, Newsletters, Ads
    Replies: 0
    Last Post: 26 Mar 2010, 07:00 PM
  4. How do I remove Qty 'units in stock' from the product details?
    By newb1234 in forum Basic Configuration
    Replies: 1
    Last Post: 18 Sep 2009, 10:35 PM
  5. Product Qty Units: question
    By RC_Cola in forum Setting Up Categories, Products, Attributes
    Replies: 1
    Last Post: 17 Feb 2009, 09:59 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
disjunctive-egg
Zen-Cart, Internet Selling Services, Klamath Falls, OR