Which code will get the tax amount on a page in Magento?

  • Mage::helper(‘checkout’)->getQuote()->getShippingAddress()->getData(‘tax_amount’);

  • $totalItemsInCart = Mage::helper(‘checkout/cart’)->getItemsCount();
    $totals = Mage::getSingleton(‘checkout/session’)->getQuote()->getTotals();
    $subtotal = round($totals[«subtotal»]->getValue());
    $grandtotal = round($totals[«grand_total»]->getValue());
    if(isset($totals[‘discount’]) && $totals[‘discount’]->getValue()) {
    $discount = round($totals[‘discount’]->getValue());
    } else {
    $discount = ‘’;
    }
    if (isset($totals[‘tax’]) && $totals[‘tax’]->getValue()) {
    $tax = round($totals[‘tax’]->getValue());
    } else {
    $tax = ‘’;
    }

  • $order = Mage::getModel(‘sales/order’)->load($order_id);
    $items = $order->getAllItems();
    $subtotals = array();
    foreach ($items as $_item) {
    if (array_key_exists($subtotals[$_item->getTaxClassId()])) {
    $subtotals[$_item->getTaxClassId()] += $_item->getRowTotal();
    } else {
    $subtotals[$_item->getTaxClassId()] = $_item->getRowTotal();
    }
    }

  • $order = Mage::getModel(‘sales/order’)->loadByIncrementId($this->getOrderId());
    $data = $order->getData();

stackoverflow.com/questions/16219824