B-219 Sec-55 Noida, India
+918010221733

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 = ”;
}
(Visited 68 times, 1 visits today)

Leave a reply

You must be logged in to post a comment.