2016-07-10 111 views
0

我想顯示Magento中的單一產品的無稅和單一產品的稅額。顯示Magento中的單一產品的無稅和稅額的產品價格

我已經加載的項目:

$qty     =$item->getData('qty_ordered'); 
$sku     =$item->getSku(); 
$name    =$item->getName(); 
$tax     =$item->getTaxAmount()/$qty; 
$price_incl_tax  =$item->getPriceInclTax(); 
$price_excl_tax  =$price_incl_tax-$tax; 

這是工作,但我不認爲這是一個很好的解決方案。沒有我自己計算PHP的價格有沒有更簡單的方法?

在此先感謝!

編輯:我需要這樣的:

$_product = $item->getProduct(); 
$finalPriceExcludingTax = 
Mage::helper('tax') ->getPrice($_product, $_product->getFinalPrice(), false); 

可用上訂購的商品,具有價格的客戶已經納了。

回答

0

嘗試使用稅幫手:

$_product = $item->getProduct() 
$finalPriceExcludingTax = $this->helper('tax') 
    ->getPrice($_product, $_product->getFinalPrice(), false); 
+0

我收到「致命錯誤:使用$這個時候不是在對象」,並您的解決方案是指順序,或者產品? – Vidarrus

+0

你在哪裏添加了這段代碼? – amr

+0

請嘗試將其更改爲: $ finalPriceExcludingTax = Mage :: helper('tax') - > getPrice($ _ product,$ _product-> getFinalPrice(),false); – amr