从订单对象中获取品红运输税率


Get magento shipping tax rate from order object

我需要知道如何获得订单的税率。目前我用

计算这个值
$order->getShippingTaxAmount() and $order->getShippingAmount()

它真的,真的很丑,但到目前为止它是有效的。但是如果没有运费,我就不知道税率了。我需要erp系统做其他任务的速率。

我尝试使用"var_dump()"作为订单对象,并通过搜索税率来查找我的值,但找不到任何东西。另一个想法是"get_class_methods",但也没有运气。

我知道,还有另一个线程(#6940246),但解决方案是"全球"的-我需要特定订单的税率,这取决于国家或客户-应该是历史的。

您可以使用$tax_info = $order->getFullTaxInfo();这个方法直接来自订单模型。它将为您提供一个数组,其中包含该订单的详细税务信息,包括金额、税号、标题、税号、百分比。

要接收例如以百分比表示的税率,您可以使用$tax_rate = $tax_info[0]['percent'];

如果你是在'quote'的情况下

$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));