[英]Magento: Is Tablerate Shipping based on the cart sum with or without taxes?
我有一家商店,产品的税率不同。 有些有0%,有些有19%,等等。
对于使用即时汇率的即时贴,例如:
最高2000€= 10€运费
最高2400€= 15€运费
现在刚开始我只是想了解一下,所以这里没有真正要修复的错误。 我只需要知道如何相应地计划我的餐桌费。
我的订单总额超过2400€(含税),但客户仍然可以得到10€的运费。 仅当系统使用“不含税价格”对照表费率检查时才可以。 因为只有这样,价格才会在较低费率的Tablerate范围内。 是的,我仔细检查了Tablerates设置(不是我的第一个Magento安装)。
1)这种假设是否正确,就是对照不含税的总额来检查餐桌价格?
2)是否可以设置餐桌费率来检查购物车总额(含税)?
任何人都知道它在后台如何工作的任何信息? 我找不到任何东西,因为当您搜索主题时,您通常会获得有关如何设置餐桌费率的教程。
非常感谢任何小费或其他线程或地方,我可以检查有关其工作方式的详细信息。
注意:我使用Magento 1.9.2.1
它似乎没有税。
Mage_Shipping_Model_Shipping :: collectRatesByAddress调用setPackageValue来设置费率请求的包裹值。 这将传递给Mage_Shipping_Model_Carrier_Tablerate :: collectRates 。 collectRates从包裹价值中扣除免费送货。
然后调用Mage_Shipping_Model_Carrier_Tablerate :: getRate
$result = Mage::getModel('shipping/rate_result');
$rate = $this->getRate($request);
...
public function getRate(Mage_Shipping_Model_Rate_Request $request)
{
return Mage::getResourceModel('shipping/carrier_tablerate')->getRate($request);
}
这将调用Mage_Shipping_Model_Resource_Carrier_Tablerate :: getRate ,它将条件值绑定到查询。 (在您的情况下,条件名称应为package_value)。
// Render condition by condition name
if (is_array($request->getConditionName())) {
$orWhere = array();
$i = 0;
foreach ($request->getConditionName() as $conditionName) {
$bindNameKey = sprintf(':condition_name_%d', $i);
$bindValueKey = sprintf(':condition_value_%d', $i);
$orWhere[] = "(condition_name = {$bindNameKey} AND condition_value <= {$bindValueKey})";
$bind[$bindNameKey] = $conditionName;
$bind[$bindValueKey] = $request->getData($conditionName);
$i++;
}
if ($orWhere) {
$select->where(implode(' OR ', $orWhere));
}
} else {
$bind[':condition_name'] = $request->getConditionName();
$bind[':condition_value'] = $request->getData($request->getConditionName());
$select->where('condition_name = :condition_name');
$select->where('condition_value <= :condition_value');
}
虽然可以修改订单,但是baseSubtotal应该在税前。 参见collectRatesByAddress :
$request->setBaseSubtotalInclTax($address->getBaseSubtotalInclTax()
+ $address->getBaseExtraTaxAmount());
如上所述,我们在请求中有数据,但是没有简单的接触点。
一个建议是重写Mage_Shipping_Model_Carrier_Tablerate和覆盖的getRate。 您将要做的是将BaseSubtotal设置为BaseSubtotalInclTax ,调用父级,然后重置请求。
public function getRate(Mage_Shipping_Model_Rate_Request $request)
{
// TODO: wrap in try catch, to reset the value ??
// TODO: clone the request ??
// TODO: Test This
$oldPackageValue = $request->getPackageValue();
$request->setPackageValue($request->getBaseSubtotalInclTax());
$returnvalue = Mage::getResourceModel('shipping/carrier_tablerate')->getRate($request);
$request->setPackageValue($oldPackageValue);
return $returnvalue;
}
这很hacky,但干扰最小。 它应承受不相关的更改,而不会强迫您修改代码。
另一种方法涉及重写和修改Mage_Shipping_Model_Resource_Carrier_Tablerate :: getRate以使用所需的值。
注意:这两种方法均未测试。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.