3

Scenario: There is a product in the cart but it only has limited stock. This one has only 1 item in stock. cart view

We exceed the quantity of the product. I set the quantity to 2. cart view extra quantity

The price changes to less than half of the original price.

I searched everywhere for a solution including editing the codes for the price to changing settings in the backend.

Then I found this in the magento forums:

https://community.magento.com/t5/Version-Upgrades/Cart-displays-wrong-price-after-exceeding-stock-value-Version-1/td-p/54002

Does anyone know where this error is stemming from?

  • Check your shopping cart rules to see if you have a promotion that is affecting the price for that item. – SR_Magento Mar 16 '17 at 9:34
  • @SR_Magento there are no shopping cart rules (waves hand like a force user). Or is there a hidden shopping cart rule I don't know about. – fja3omega Mar 17 '17 at 0:17
2

This "bug" was introduced in Magento CE 1.9.3.0 by the following modification in app/code/core/Mage/Sales/Model/Quote/Address/Total/Subtotal.php:

             $item->setPrice($finalPrice)
                 ->setBaseOriginalPrice($finalPrice);
             $item->calcRowTotal();
-        } else if (!$quoteItem->getParentItem()) {
+        } else if (!$quoteItem->getParentItem() && !$item->getHasError()) {
             $finalPrice = $product->getFinalPrice($quoteItem->getQty());
             $item->setPrice($finalPrice)
                 ->setBaseOriginalPrice($finalPrice);

Because of this the quote calculation isn't done correctly anymore. I don't find a reasonable notification for this in the CE 1.9.3.0 release notes.

I fixed this problem by rewriting this modification back to the CE 1.9.2.x behaviour.

    <models>
        ...
        <sales>
            <rewrite>
                <quote_address_total_subtotal>Mypackage_Mymodule_Model_Sales_Quote_Address_Total_Subtotal</quote_address_total_subtotal>
            </rewrite>
        </sales>
    </models>

and Mypackage_Mymodule_Model_Sales_Quote_Address_Total_Subtotal

<?php
class Mypackage_Mymodule_Model_Sales_Quote_Address_Total_Subtotal extends Mage_Sales_Model_Quote_Address_Total_Subtotal
{
    /**
     * Address item initialization
     *
     * @param  $item
     * @return bool
     */
    protected function _initItem($address, $item)
    {
        ...
        } else if (!$quoteItem->getParentItem()) {
            $finalPrice = $product->getFinalPrice($quoteItem->getQty());
        ...
}
  • I will try this and test it out – fja3omega Aug 10 '17 at 8:30
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;
     }
0

Removing following from the Mage_Sales_Model_Quote_Address_Total_Subtotal _initItem() method solved it for me:

&& !$item->getHasError()

I have checked this and it is working fine for me

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.