Magento - Get products price with tax and discounts in cart/order (Criteo tags) -
for implementation of criteo tags, i'm trying price (among other things) of products in cart (and success page) tax , discounts. i'm doing this, displays price discount , without tax :
$cartallitems = mage::getmodel('checkout/cart')->getitems(); foreach ($cartallitems $item){ $price = mage::helper('tax')->getprice($item->getproduct(), $item->getproduct()->getfinalprice()); // other things }
i've been testing around lot of things , can't make work. thx help
i think can use,
mage::helper('checkout')->getquote()->getshippingaddress()->getdata('tax_amount')
this return total tax amount. or can use
$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 = ''; }
modified guess requirement
foreach ($productids $productid) { $_product = mage::getmodel('catalog/product')->load($productid); $productsprice = floatval($_product->getdata("price")); // product's tax class' id $taxclassid = $_product->getdata("tax_class_id"); echo 'tax class id '.$taxclassid.' '; // tax rates of each tax class in associative array $taxclasses = mage::helper("core")->jsondecode( mage::helper("tax")- >getallratesbyproductclass() ); echo 'tax classes '.$taxclasses.' '; // extract tax rate array $taxrate = $taxclasses["value_".$taxclassid]; echo 'tax rate '.$taxrate.' '; } ?>
Comments
Post a Comment