2013-05-16 79 views
3

我需要知道我如何獲得訂單的稅率。目前我正在計算這個值與從訂單對象獲取magento運輸稅率

$order->getShippingTaxAmount() and $order->getShippingAmount() 

這真的,真的很醜,但這個工程到目前爲止。但如果沒有運輸成本,我沒有得到稅率。我需要ERP系統執行其他任務的速度。

我試着使用「var_dump()」作爲訂單對象,並通過搜索稅率來查找我的價值,但找不到任何東西。另一個想法是「get_class_methods」,但也沒有運氣。

我知道,還有另一個線程(#6940246),但解決方案的工作原理是「全球化」 - 我需要特定訂單的稅率,這取決於國家或客戶 - 並且應該是歷史性的。

回答

9

您可以使用$tax_info = $order->getFullTaxInfo();該方法直接來自訂購型號。它會爲您提供一個包含該訂單的詳細稅務信息的數組,包括金額,稅碼,標題,稅號,百分比。

爲了得到例如以百分比表示的稅率,則可以使用$tax_rate = $tax_info[0]['percent'];

+0

謝謝!聽起來不錯:)我會嘗試=) –

+0

如何從報價對象獲得運輸稅信息 – 2013-08-26 13:41:06

+0

其不適用於報價對象 – 2013-08-29 06:07:26

3

如果您處於「報價」狀態。

$store = $quote->getStore() 
$taxCalculation = Mage::getModel('tax/calculation'); 
$request = $taxCalculation->getRateRequest(null, null, null, $store); 
$taxRateId = Mage::getStoreConfig('tax/classes/shipping_tax_class', $store); 

//taxRateId is the same model id as product tax classes, so you can do this: 
$percent = $taxCalculation->getRate($request->setProductClassId($taxRateId)); 
+1

請注意,這可能不適用於較新的Magento版本,因爲它們另外提供動態運輸稅率。 – quafzi

相關問題