6

Whenever you try to change quantity from the cart and that quantity is not available in the inventory, unit price is wrong.

Example: I add Product A in the cart (simple product), first time I choose a quantity 1 from product detail page.

After that, I decide to change cart quantity to 3 and press Update button in the cart. In my inventory there are only 2 stock units of Product A.

Magento throw correctly a notice that is not possible to add 3 stock units in the cart for Product A but if you see under the unit price column, its price has been changed.

With a quantity of 2, unit price is 41,50 Euro, with a quantity of 3 unit price become 18,59 Euro. If I change quantity to 4, unit price become 9,37 Euro. So every time quantity is changed, it seems that unit price has been recalculated for some reason.

Is there a logical explanation to this strange behaviour?

Magento installed version: 1.9.3.1

1
3

Same issue, I've overridden the block in order to add a condition when the items has error and perform my logic inside

On Magento 1.9.2.3 I have this code in _initItem() method :

if ($quoteItem->getParentItem() && $quoteItem->isChildrenCalculated()) {
        $finalPrice = $quoteItem->getParentItem()->getProduct()->getPriceModel()->getChildFinalPrice(
           $quoteItem->getParentItem()->getProduct(),
           $quoteItem->getParentItem()->getQty(),
           $quoteItem->getProduct(),
           $quoteItem->getQty()
        );
        $item->setPrice($finalPrice)
            ->setBaseOriginalPrice($finalPrice);
        $item->calcRowTotal();
    } else if (!$quoteItem->getParentItem()) {
        $finalPrice = $product->getFinalPrice($quoteItem->getQty());
        $item->setPrice($finalPrice)
            ->setBaseOriginalPrice($finalPrice);
        $item->calcRowTotal();
        $this->_addAmount($item->getRowTotal());
        $this->_addBaseAmount($item->getBaseRowTotal());
        $address->setTotalQty($address->getTotalQty() + $item->getQty());
    }

And on Magento 1.9.3.2 they changed the else if:

if ($quoteItem->getParentItem() && $quoteItem->isChildrenCalculated()) {
        $finalPrice = $quoteItem->getParentItem()->getProduct()->getPriceModel()->getChildFinalPrice(
           $quoteItem->getParentItem()->getProduct(),
           $quoteItem->getParentItem()->getQty(),
           $quoteItem->getProduct(),
           $quoteItem->getQty()
        );
        $item->setPrice($finalPrice)
            ->setBaseOriginalPrice($finalPrice);
        $item->calcRowTotal();
    } else if (!$quoteItem->getParentItem() && !$item->getHasError()) {
        $finalPrice = $product->getFinalPrice($quoteItem->getQty());
        $item->setPrice($finalPrice)
            ->setBaseOriginalPrice($finalPrice);
        $item->calcRowTotal();
        $this->_addAmount($item->getRowTotal());
        $this->_addBaseAmount($item->getBaseRowTotal());
        $address->setTotalQty($address->getTotalQty() + $item->getQty());
    }
3
  • 1
    This behavior was introduced in Magento CE 1.9.3.0 (see github.com/OpenMage/magento-mirror/commit/…) and only occurs if System->Config->Inventory->Product Stock Options->Backorders is set to "No Backorders" Aug 10 '17 at 7:41
  • "I've overridden the block in order to add a condition when the items has error and perform my logic inside": Could you share your solution?
    – Simon
    Mar 26 '18 at 8:43
  • I kept the Magento 1.9.2.3 logic Mar 27 '18 at 9:16
0

The issue and a possible solution is described in the Magento Forums:

+++ app/code/core/Mage/Sales/Model/Quote/Address/Total/Subtotal.php 2017-03-15 10:53:47.000000000 +0000
@@ -110,16 +110,17 @@
             );
             $item->setPrice($finalPrice)
                 ->setBaseOriginalPrice($finalPrice);
-            $item->calcRowTotal();
+//            $item->calcRowTotal();
         } else if (!$quoteItem->getParentItem() && !$item->getHasError()) {
             $finalPrice = $product->getFinalPrice($quoteItem->getQty());
             $item->setPrice($finalPrice)
                 ->setBaseOriginalPrice($finalPrice);
-            $item->calcRowTotal();
+//            $item->calcRowTotal();
             $this->_addAmount($item->getRowTotal());
             $this->_addBaseAmount($item->getBaseRowTotal());
             $address->setTotalQty($address->getTotalQty() + $item->getQty());
         }
+        $item->calcRowTotal();

         return true;
     }

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