Forums / Bug Reports / [Done v1.3.7] Error when setting fractional quantity.

[Done v1.3.7] Error when setting fractional quantity.

Locked

Views: 3,306

Results 1 to 6 of 6
This thread is locked. New replies are disabled.
4 Nov 2006, 4:29 PM
#1
millo_magno avatar

millo_magno

New Zenner

Join Date:
Nov 2006
Posts:
25
Plugin Contributions:
0

[Done v1.3.7] Error when setting fractional quantity.

Hi,

I have an issue with fractional quantities. I'm selling fabric so need to sell by 0.5 metre lengths. The installation version is Zen-Cart v1.3.6.

I go into Admin > Config > Stock and change the 'product quantity decimals' to 1 decimal place (which should allow the sale of fabric by 0.5 metre lengths).

When I'm on the front end and attempt to add a product item to my cart I get a yellow warning/error. The error displays like such:

Quantity Error Adjustment
Product A - 1 => 1

This seems to happen regardless of whether I set the 'Product Qty Minimum' and 'Product Qty Units' to a fraction or a whole number in the actual product item itself.

Does anyone know why this error appears and what can be done to rectify so that it doesn't appear?

Many thanks in advance,

4 Nov 2006, 10:50 PM
#2
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: [Done v1.3.7] Error when setting fractional quantity.

For now, comment out 2 of the messages at the bottom of the file around lines 1847 - 1873:
/includes/classes/shopping_cart.php

The routine is used 2 ways and is passing the messages when it should not ...

  function adjust_quantity($check_qty, $products, $message=false) {
    global $messageStack;
      $old_quantity = $check_qty;
        if (QUANTITY_DECIMALS != 0) {
          //          $new_qty = round($new_qty, QUANTITY_DECIMALS);

          $fix_qty = $check_qty;
          switch (true) {
            case (!strstr($fix_qty, '.')):
            $new_qty = $fix_qty;
//            $messageStack->add_session('shopping_cart', ERROR_QUANTITY_ADJUSTED . ' - ' . zen_get_products_name($products) . ' - ' . $old_quantity . ' => ' . $new_qty, 'caution');
            break;
            default:
            $new_qty = preg_replace('/[0]+$/','', $check_qty);
//            $messageStack->add_session('shopping_cart', ERROR_QUANTITY_ADJUSTED . ' - ' . zen_get_products_name($products) . ' - ' . $old_quantity . ' => ' . $new_qty, 'caution');
            break;
          }
        } else {
          if ($check_qty != round($check_qty, QUANTITY_DECIMALS)) {
            $new_qty = round($check_qty, QUANTITY_DECIMALS);
            $messageStack->add_session('shopping_cart', ERROR_QUANTITY_ADJUSTED . ' - ' . zen_get_products_name($products) . ' - ' . $old_quantity . ' => ' . $new_qty, 'caution');
          } else {
            $new_qty = $check_qty;
          }
        }
     return $new_qty;
  }

Linda McGrath
If you have to think ... you haven't been zenned ...

**Did YOU buy the Zen Cart Team a cup of coffee and a donut today? Just click here to support the Zen Cart Team!!**

Are you using the latest? Perhaps you've a problem that's fixed in the latest version: [Upgrade today!]
Officially PayPal-Certified! Just click here

Try our Zen Cart Recommended Services - Hosting, Payment and more ...
Signup for our Announcements Forums to stay up to date on important changes and updates!

5 Nov 2006, 8:04 PM
#3
millo_magno avatar

millo_magno

New Zenner

Join Date:
Nov 2006
Posts:
25
Plugin Contributions:
0

Re: [Done v1.3.7] Error when setting fractional quantity.

Thanks! Works fine now.

7 Nov 2006, 1:29 AM
#4
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: [Done v1.3.7] Error when setting fractional quantity.

Thanks for the update that when using decimals in your quantities that this was able to fix the errant error messages ... :smile:

Moved to Bug Reports ...

Linda McGrath
If you have to think ... you haven't been zenned ...

**Did YOU buy the Zen Cart Team a cup of coffee and a donut today? Just click here to support the Zen Cart Team!!**

Are you using the latest? Perhaps you've a problem that's fixed in the latest version: [Upgrade today!]
Officially PayPal-Certified! Just click here

Try our Zen Cart Recommended Services - Hosting, Payment and more ...
Signup for our Announcements Forums to stay up to date on important changes and updates!

7 Mar 2007, 3:39 PM
#5
eddie_d_2000 avatar

eddie_d_2000

New Zenner

Join Date:
Oct 2006
Posts:
9
Plugin Contributions:
0

Re: [Done v1.3.7] Error when setting fractional quantity.

I couldn't find the lines that were mentioned here but in my version of ZenCart (1.3.5), I did find these two lines and commented them out for fractional quantities and all is well now.

lines 1137 and 1138

$_SESSION['valid_to_checkout'] = false;
$_SESSION['cart_errors'] .= ERROR_PRODUCT . $products->fields['products_name'] . ERROR_PRODUCT_QUANTITY_UNITS_SHOPPING_CART . ERROR_PRODUCT_QUANTITY_ORDERED . $check_quantity . ' <span class="alertBlack">' . zen_get_products_quantity_min_units_display((int)$prid, false, true) . '</span> ' . '<br />';

7 Mar 2007, 4:55 PM
#6
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: [Done v1.3.7] Error when setting fractional quantity.

There are a number of bugs in v1.3.5 and it is advised to upgrade to v1.3.7 plus add the current patch at:
http://www.zen-cart.com/forum/showthread.php?t=56216

Linda McGrath
If you have to think ... you haven't been zenned ...

**Did YOU buy the Zen Cart Team a cup of coffee and a donut today? Just click here to support the Zen Cart Team!!**

Are you using the latest? Perhaps you've a problem that's fixed in the latest version: [Upgrade today!]
Officially PayPal-Certified! Just click here

Try our Zen Cart Recommended Services - Hosting, Payment and more ...
Signup for our Announcements Forums to stay up to date on important changes and updates!