1

(Further investigation showed that this bug was causing the quantity figure to be multiplied by itself which this question is updated with at the bottom as opposed to multipled by 10 as we initially thought when we raised this question).

Absolutely stumped on this one. Posting the quantity is multiplying the figure entered by 10 yet doesn't update the actual visible figure displayed in the field.

So if I updated the quantity on the checkout page from 10 to 50, Magento thinks that the quantity is 500 but still only shows 50. So this is resulting in lots of errors saying the product isn't available in the requested quantity... Therefore most customers cannot checkout.

Have spent an entire day testing this and trying to debug before I found this to be the problem.

I can't see any extensions overriding related functions or controllers. And the code for the qty input field and add to cart button appears to be the same as Magento's core. I've really got no idea where this is happening. It is multiplying by 10 every time, that figure doesn't vary.

We've also reverted to default theme and the same thing happens.

This is affecting both stores - I previously made a mistake in saying only store 2 was affected.

Please let me know any code you'd like to see or if you have any ideas to what might be causing this. Thanks in advance.

Edit 1: Adding sample / related code in use...

There is no checkout/cart overrides for the wholesale store so it falls back to what is in use for the retail (default) store.

/app/design/frontend/[package]/[theme]/template/checkout/cart.phtml

Quantity column:-

<th rowspan="<?php echo $mergedCells; ?>" class="a-center"><?php echo $this->__('Qty') ?></th>

Is inside the form:-

<form action="<?php echo $this->getUrl('checkout/cart/updatePost') ?>" method="post">

In...

/app/design/frontend/[package]/[theme]/template/checkout/cart/item/default.phtml

The quantity field:-

<td class="a-center">
    <input name="cart[<?php echo $_item->getId() ?>][qty]" value="<?php echo $this->getQty() ?>" size="4" title="<?php echo $this->__('Qty') ?>" class="span1" maxlength="12" />
</td>

I don't see anything unusual with the above, further on from this, I think it will only use Magento core functions to update the quantity field? And we've just replaced the entire /app/code/core/Mage from a fresh download of Magento 1.7.

From a product view page, you can update the quantity and it successfully adds to cart, it is only once you view cart at /checkout/cart that Magento then decides to multiply the quantity field by 10.

What is affected:-

  • Both stores are affected.
  • Configurable products only (where associated products are added to cart).

Image of problem below...

cart qty error

Edit 2: Don't know if the stack trace gives anything of use?

2013-08-01T11:08:06+00:00 ERR (3): 
exception 'Mage_Core_Exception' with message 'Not all products are available in the requested quantity' in /var/www/vhosts/[domain]/httpdocs/app/Mage.php:594
Stack trace:
#0 /var/www/vhosts/[domain]/httpdocs/app/code/core/Mage/CatalogInventory/Model/Stock.php(144): Mage::throwException('Not all product...')
#1 /var/www/vhosts/[domain]/httpdocs/app/code/core/Mage/CatalogInventory/Model/Observer.php(602): Mage_CatalogInventory_Model_Stock->registerProductsSale(Array)
#2 /var/www/vhosts/[domain]/httpdocs/app/code/core/Mage/Core/Model/App.php(1338): Mage_CatalogInventory_Model_Observer->subtractQuoteInventory(Object(Varien_Event_Observer))
#3 /var/www/vhosts/[domain]/httpdocs/app/code/core/Mage/Core/Model/App.php(1317): Mage_Core_Model_App->_callObserverMethod(Object(Fooman_AdvancedPromotions_Model_CatalogInventory_Observer), 'subtractQuoteIn...', Object(Varien_Event_Observer))
#4 /var/www/vhosts/[domain]/httpdocs/app/Mage.php(447): Mage_Core_Model_App->dispatchEvent('sales_model_ser...', Array)
#5 /var/www/vhosts/[domain]/httpdocs/app/code/core/Mage/Sales/Model/Service/Quote.php(187): Mage::dispatchEvent('sales_model_ser...', Array)
#6 /var/www/vhosts/[domain]/httpdocs/app/code/core/Mage/Sales/Model/Service/Quote.php(249): Mage_Sales_Model_Service_Quote->submitOrder()
#7 /var/www/vhosts/[domain]/httpdocs/app/code/core/Mage/Checkout/Model/Type/Onepage.php(774): Mage_Sales_Model_Service_Quote->submitAll()
#8 /var/www/vhosts/[domain]/httpdocs/app/code/core/Mage/Checkout/controllers/OnepageController.php(511): Mage_Checkout_Model_Type_Onepage->saveOrder()
#9 /var/www/vhosts/[domain]/httpdocs/app/code/core/Mage/Core/Controller/Varien/Action.php(419): Mage_Checkout_OnepageController->saveOrderAction()
#10 /var/www/vhosts/[domain]/httpdocs/app/code/core/Mage/Core/Controller/Varien/Router/Standard.php(250): Mage_Core_Controller_Varien_Action->dispatch('saveOrder')
#11 /var/www/vhosts/[domain]/httpdocs/app/code/core/Mage/Core/Controller/Varien/Front.php(176): Mage_Core_Controller_Varien_Router_Standard->match(Object(Mage_Core_Controller_Request_Http))
#12 /var/www/vhosts/[domain]/httpdocs/app/code/core/Mage/Core/Model/App.php(354): Mage_Core_Controller_Varien_Front->dispatch()
#13 /var/www/vhosts/[domain]/httpdocs/app/Mage.php(683): Mage_Core_Model_App->run(Array)
#14 /var/www/vhosts/[domain]/httpdocs/wholesale/index.php(89): Mage::run('wholesale', 'store')
#15 {main}

Edit 3: Extending Mage_CatalogInventory_Model_Stock_Item

Please see this issue which could be related to the cause of this one. Reverting this change though does not make the problem go away. All sessions, cache etc cleared. This is driving us nuts.

Edit 4: Multiplied by itself not by 10...

Further investigation uncovers that the quantity figure is actually getting multipled by itself (as opposed to by 10 as originally claimed).

For example:-

  • entering 6 takes 36 off stock (6x6)
  • entering 10 takes 100 off stock as (10x10)
  • entering 3 takes 9 off stock as (3x3)

Illustrated below:-

Magento quantity field working

Magento quantity field not working

Magento stock levels that show that the above quantity orders should work

Quantity of 6 works, quantity of 7 doesn’t. 38 in stock. (6x6=36 below 38) works / (7x7=49 above 38) fails.

(Updated title of question to reflect new findings)...

Edit 5: We've also raised this as an issue at Magento's bug tracker

It definitely seems like a core Magento bug, we've exhausted every possible option and scenario having ripped the website to pieces and re-pieced it bit by bit, testing throughout the process. Issue just appears out of nowhere once the site is put together but remains if you revert back to default Magento core everything! (not got much hair left at the moment)... Link to issue in Magento Bug Tracker.

Edit 6: Customer Accounts / Shipping Methods

Issue seems very closely related to customer accounts and shipping methods. Will provide more issue when I have it...

Edit 7: This is now fixed, we've identified the bug - answer to follow shortly.

  • Just shooting in the dark here, but maybe it has something to do with the locale of your store. Try changing it to en_US (if it's not that already) and see what happens. If the locale is already en_US then consider this just an other stupid comment passing through. – Marius Aug 1 '13 at 14:55
  • The locale default config is set to English (United Kingdom) and both stores are using this default config. Is this what you were referring to? Thanks for your suggestion. – zigojacko Aug 1 '13 at 15:03
  • I had a similar problem with a dropdown quantity multiplying by two. Can you post some code as I might be able to help... – user1704524 Aug 1 '13 at 15:11
  • Sure thing, that would be greatly appreciated. I'll extend my question with code in use shortly. Thanks. – zigojacko Aug 1 '13 at 15:28
  • Try quote_item_set_qty event debugging. Also can you reproduce the same issue on your development environment? – Ivan Chepurnyi Aug 1 '13 at 15:39
1

This sounds like a similar issue I had about a year ago.

The end result was the same as what you have: totals got doubled by qty (qty * qty)

The problem was tracked down to when customer address got added to the order object, it got added twice as delivery address. Thus the order object had 3 addresses:

  • 1 - Billing
  • 2 - Shipping
  • 3 - shipping (duplicate of #2)

I forget why this happened :( (I seem to recall an observer event doing something funky)

The same happened to the quote object (thus cart)

Since totals calculation hang directly off address objects, totals got doubled by qty.

An easy why to test if you are having the same issue, wipe out the sales_flat_order_address table, and enter checkout. Then check the table for address entries for your order. you should have 2 entries in there.

Additionally, since the issue is related to database entries, once the bug was fixed, it looked like the problem remained/was not fixed. It required removing the duplicates from the database for the problem to resolve for existing quote/order objects.

  • Thanks for your answer @Proxiblue. Seems like we've encountered the same bug as you did. Exactly the same frontend outcome with qty*qty yet we only appear to be getting two entries (x1 billing, x1 shipping) in the sales_flat_order_address table. Definitely seems related to customers, cookies / sessions or accounts / address records though. We've confirmed there is no issues with the code, theme, extensions as was able to replicate in Magento's base. I think you're very close to what is causing the issue with your answer - we'll continue to investigate. Thanks. – zigojacko Aug 6 '13 at 8:41
  • 1
    @GeoffJackson Have you tried putting a debugger breakpoint in the totals calculation part, especially where it iterates the addresses to build the totals? You should then at least see if the object internals are correctly populated on address data, and also if it gets called again, and trace back to where....thsi is how I tracked down my issue. Mage_Sales_Model_Quote::collectTotals() I do recall my issue ended up being a custom module, so my own fault :), it was not related to core functionality. – ProxiBlue Aug 6 '13 at 9:13
  • Currently installing Xdebug on the server where this live website is to debug. Will try your suggestion and hopefully will shed some light onto the issue. Will feedback with more info when I have it - thanks for your suggestions and help. – zigojacko Aug 6 '13 at 11:19
  • We have seen this issue on our checkout, we saw the multiplication of the cart total by 4 before shipping. Following reading this thread I reverted the test site to default theme and then selected "Checkout with Multiple Addresses" (hidden in our store theme). Selecting this option cleared the issue for this user / store. – Flipmedia Jun 4 '15 at 11:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.