How do I get the Shopping cart discounts? For a payment integration I need to sent all items in cart. For products that is easy, but how do I get the following for all applied discounts:
- amount with and without tax
- name
- vat%
Hi you can get this details using cart session
$totals = Mage::getSingleton('checkout/session')->getQuote()->getTotals(); //Total object
$subtotal = $totals["subtotal"]->getValue(); //Subtotal value
$grandtotal = $totals["grand_total"]->getValue(); //Grandtotal value
if(isset($totals['discount']) && $totals['discount']->getValue()) {
$discount = Mage::helper('core')->currency($totals['discount']->getValue()); //Discount value if applied
} else {
$discount = '';
}
if(isset($totals['tax']) && $totals['tax']->getValue()) {
$tax = $totals['tax']->getValue(); //Tax value if present
} else {
$tax = '';
}
$quote = Mage::getSingleton('checkout/session')->getQuote();
$cartItems = $quote->getAllVisibleItems();
foreach ($cartItems as $item) {
echo $item->getQty();
$item->getPrice();
$item->getDiscountAmount();
}
For getting coupon code try this Mage::getSingleton('checkout/session')->getQuote()getCouponCode();
more details to check table sales_flat_quote_item
in your magento system