Magento – How to get total price for product with qty before adding to cart in Magento

grand-totalmagento-1.9pricerules

I have shopping cart promotion rules which gives discount for buying 4 products. This works fine on shopping cart page. I mean it applies discount and shows discounted price in TOTAL row. I want to show customer this discounted price on another page before he adds product to cart. How can I do it? Basically it is calculating price where product id and qty is given applying shopping cart price rules.

Best Answer

Try something like code below, it should work correctly for tier prices and catalog price rules.

    /* @var $item Mage_Sales_Model_Quote_Item */
    $item = Mage::getModel('sales/quote_item');
    $qty = 3;
    $product = /* load product you want to get price for */;
    $item->setProduct($product);
    $item->setQty($qty);
    $item->setQuote(/* get quote from checkout session */);
    $finalPrice = $product->getFinalPrice($item->getQty());
    $item->setPrice($finalPrice)
        ->setBaseOriginalPrice($finalPrice);
    $item->calcRowTotal();                

    $item->getRowTotal();
Related Topic