Looking for some confirmation on this, but was looking at ZC 1.5.5 code (which appears similar in other/older versions) in includes/classes/shopping_cart.php for the function actionUpdateProduct as a way to try to follow the course of action that was observed for the following product setup. When I pressed the reset/reload button, the quantity selected in the cart was modified unexpectedly. I haven't yet figured out how to work around it in a big scope/be able to "predict" the condition to exist.
So here's the setup that was in place when discovered:
Product has a quantity of 10 available.
Product is set to have a maximum of 9.
Product is not mixed quantity.
Configuration->My Cart
Allow checkout when product is out-of-stock is set to false.
Display the cart after add product is set to false. (After adding to cart, screen refreshes with product page and cart quantity is increased. Doesn't seem like this is a factor, but already have a lot of variables so testing each variation is becoming "difficult".)
Initially from the product page, add a quantity of 9 products of the single product.
Attempt to add a 10th and am (expectedly) taken to the shopping cart page where the quantity has been adjusted to 9 products in my cart and have been notified.
Attempt the refresh button with no changes in quantity made and now the quantity in my cart is 1 (this number can change depending on the quantity entered on the page at the time of refresh and the quantity of product in the cart.
As a challenge, try setting up a second product the same way. Now, add the first product, then refresh (get 1 in the cart), now go and add the second product to get the 9 quantity. Cart will show quantity of 1 for the first product and 9 for the second. Change the quantity of the first to 9 and refresh. Now... Look what you get. 9 on the first product and 1 on the second. Update the 2nd product to show 9, refresh and back to what was originally seen... Only way found to get around this circle was to either refresh while a 9 and 1 pair were onscreen so that would be 1 and 1, then update both to 9 at one time and refresh and tada, stable. (until the next refresh/reload of the page)
Looking more at the code, it doesn't matter whether the product is limited by maximum or not, anytime the page is "refreshed using the update cart button" where the quantity that is on the page plus the quantity in the shopping cart exceeds the available quantity of the product, then the quantity to be applied is altered unless the quantity on the page and in the cart is half or less of the quantity available before the refresh button is pressed. This appears to first be caused by this portion of code in the actionUpdateProduct function (note same code is in the actionAddProduct and actionMultipleAddProduct functions, but those have not (yet) shown to be a problem) that modifies $new_qty (supposedly the amount that has been entered on the page) where $new_qty is then used in subsequent acceptance review:
I'll likely continue to troubleshoot this, though I am also trying to get some code working in spite of this issue and actually see that the other code is working fine in particular if this "area" or aspect were corrected, though I have more changes to make for improvements.Code:// bof: adjust new quantity to be same as current in stock if (STOCK_ALLOW_CHECKOUT == 'false' && ($new_qty + $cart_qty > $chk_current_qty)) { $adjust_new_qty = 'true'; $alter_qty = $chk_current_qty - $cart_qty; $new_qty = ($alter_qty > 0 ? $alter_qty : 0); $messageStack->add_session('shopping_cart', ($this->display_debug_messages ? 'FUNCTION ' . __FUNCTION__ . ': ' : '') . WARNING_PRODUCT_QUANTITY_ADJUSTED . zen_get_products_name($_POST['products_id'][$i]), 'caution'); } // eof: adjust new quantity to be same as current in stock


Reply With Quote
