0

am using this code to get Sub Total (Special Price)

$price=Mage::helper('checkout/cart')->getQuote()->getSubtotal();

How can i get the Original Price and Special Price

1

You can find the Price and special price via below code.

$cart = Mage::getModel('checkout/cart')->getQuote();
foreach ($cart->getAllItems() as $item) {
    $productName = $item->getProduct()->getName();
    $productPrice = $item->getProduct()->getPrice();
    $productSpecialPrice = $item->getProduct()->getSpecialPrice();
}

in $cart you got all collection of cart item and if you want to get product id,name you can can get from using foreach loop

6
  • How can i Get the total Getprice without the loop ?
    – Jijesh
    Nov 11 '14 at 6:57
  • means grand total or subtotal?
    – Keyul Shah
    Nov 11 '14 at 6:59
  • actually i wanted to show the total Savings on cart total page Based on Original Price and Special Price
    – Jijesh
    Nov 11 '14 at 7:17
  • if the item price is 200$ and Special Price is 150$ i wanted to show this in Cart Total Page like Sub Total : 150$ You Saved : 50$
    – Jijesh
    Nov 11 '14 at 8:21
  • you have to can display this thing using $price-$specialprice simple
    – Keyul Shah
    Nov 11 '14 at 8:33
0

I had the same issue and used a slightly different approach to get MSRP and Total Savings into the cart totals for all items.

Edit the following file: /app/design/frontend/{your theme}/{your layout}/template/tax/checkout

Add this to the top of the page:

<?php 
$cart = Mage::getModel('checkout/cart')->getQuote();
foreach ($cart->getAllItems() as $item) 
{
    $productPrice += $item->getProduct()->getPrice();
    $productSpecialPrice += $item->getProduct()->getSpecialPrice(); 
} 
$discountAmount = $productPrice - $productSpecialPrice;
?>

Then below this you will find the 2 areas where magento dispalys sub total. First one is for with and without tax, second is just without. Edit the one you use by adding the following code:

<!-- MSRP -->
<tr>
    <td style="<?php echo $this->getStyle() ?>" class="a-right" colspan="<?php echo $this->getColspan(); ?>">
        <?php echo 'MSRP' ?>
    </td>
    <td style="<?php echo $this->getStyle() ?>" class="a-right">
        <?php echo $this->helper('checkout')->formatPrice($productPrice); ?>
    </td>
</tr>

<!-- SAVINGS // MSRP - SUBTOTAL -->
<tr>
    <td style="<?php echo $this->getStyle() ?>" class="a-right" colspan="<?php echo $this->getColspan(); ?>">
        <?php echo 'SAVINGS' ?>
    </td>
    <td style="<?php echo $this->getStyle() ?>" class="a-right">
        <?php echo "-" . $this->helper('checkout')->formatPrice($discountAmount) ?>
    </td>
</tr>

<!-- SUBTOTAL -->
<tr>
    <td style="<?php echo $this->getStyle() ?>" class="a-right" colspan="<?php echo $this->getColspan(); ?>">
        <?php echo $this->getTotal()->getTitle() ?>
    </td>
    <td style="<?php echo $this->getStyle() ?>" class="a-right">
        <?php echo $this->helper('checkout')->formatPrice($this->getTotal()->getValue()) ?>
    </td>
</tr> 

This will display MSRP (before special price) with Savings above subtotal.

0

Add savings under grandtotal. file: ....../tax/checkout/grandtotal.phtml

<?php
/**
 * @var $this Mage_Tax_Block_Checkout_Grandtotal
 * @see Mage_Tax_Block_Checkout_Grandtotal
 */
?>
<?php
$cart = Mage::getModel('checkout/cart')->getQuote();
foreach ($cart->getAllItems() as $item)
{
    $productSpecialPrice;$productPrice;

    if($item->getProduct()->getSpecialPrice() > 0)
    {
        $productSpecialPrice += $item->getProduct()->getSpecialPrice();
        $productPrice += $item->getProduct()->getPrice();
    }

}
$discountAmount = $productPrice - $productSpecialPrice;
?>

<?php if ($this->includeTax() && $this->getTotalExclTax()>=0):?>
<tr>
    <td style="<?php echo $this->getStyle() ?>" class="a-right" colspan="<?php echo $this->getColspan(); ?>">
        <strong><?php echo $this->helper('tax')->__('Grand Total Excl. Tax')?></strong>
    </td>
    <td style="<?php echo $this->getStyle() ?>" class="a-right">
        <strong><?php echo $this->helper('checkout')->formatPrice($this->getTotalExclTax()) ?></strong>
    </td>
</tr>
<?php echo $this->renderTotals('taxes', $this->getColspan()); ?>
<tr>
    <td style="<?php echo $this->getStyle() ?>" class="a-right" colspan="<?php echo $this->getColspan(); ?>">
        <strong><?php echo $this->helper('tax')->__('Grand Total Incl. Tax')?></strong>
    </td>
    <td style="<?php echo $this->getStyle() ?>" class="a-right">
        <strong><?php echo $this->helper('checkout')->formatPrice($this->getTotal()->getValue()) ?></strong>
    </td>
</tr>
<?php else:?>
<tr>
    <td style="<?php echo $this->getStyle() ?>" class="a-right" colspan="<?php echo $this->getColspan(); ?>">
        <strong><?php echo $this->getTotal()->getTitle() ?></strong>
    </td>
    <td style="<?php echo $this->getStyle() ?>" class="a-right">
        <strong><?php echo $this->helper('checkout')->formatPrice($this->getTotal()->getValue()) ?></strong>
    </td>
</tr>
<?php endif;?>

<?php if ($discountAmount >0) : ?>
<!-- SAVINGS  -->
<tr class="checkout_save">
    <td style="<?php echo $this->getStyle() ?>" class="a-right" colspan="<?php echo $this->getColspan(); ?>">
        <?php echo $this->__('Savings'); ?>
    </td>
    <td style="<?php echo $this->getStyle() ?>" class="a-right">
        <?php echo $this->helper('checkout')->formatPrice($discountAmount); ?>
    </td>
</tr>
<?php endif;?>

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.