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
Magento Stack Exchange is a question and answer site for users of the Magento e-Commerce platform. It only takes a minute to sign up.
Sign up to join this communityam 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
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
$price-$specialprice
simple
– Keyul Shah
Nov 11 '14 at 8:33
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.
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;?>