Pages

Monday, August 19, 2013

How to get shipping and handling cost, tax, discount in magento on shopping cart page

We can simply use the following code

// To get the shipping and handling charge on shopping cart page

Mage::getSingleton('checkout/session')->getQuote()->getShippingAddress()->getShippingAmount();

 // To get discount and tax  on shopping cart page

$totals = Mage::getSingleton('checkout/session')->getQuote()->getTotals(); //Total object

 // To get the discount
if(isset($totals['discount']) && $totals['discount']->getValue()) {
echo 'Discount :'. $discount = $totals['discount']->getValue(); //Discount value if applied
} else {
$discount = '';
}

 // To get tax
if(isset($totals['tax']) && $totals['tax']->getValue()) {
echo 'Tax :'.$tax = $totals['tax']->getValue(); //Tax value if present
} else {
$tax = '';
}

No comments:

Post a Comment