Magento:Tablerate Shipping是根据购物车金额加税还是不加税?

时间:2016-05-10 14:49:34

标签: magento magento-1.9

我有一个商店,其产品含有不同的税率。有些人有0%,有些人有19%等......

对于使用Tablerates运输,例如:

高达2000€= 10€运费

高达或超过2400€= 15€运费

现在我想了解一下,所以这里没有真正的错误。我只需要知道如何相应地计划我的表格。

我的订单总额超过2400欧元(含税),但客户仍然获得10欧元的运费。这只能在系统使用不含税的价格来检查表费率的情况下。因为只有这样,价格才会在较低费率的Tablerate范围内。是的,我仔细检查了Tablerates安装程序(不是我的第一个Magento安装程序)。

1)这个假设是否正确,表税率是否与不含税的总额相比较?

2)有没有办法设置包装箱以检查购物车总额,包括税金?

任何人都有关于它如何在后台工作的任何信息?我找不到任何东西,因为当你搜索主题时,你大多得到如何设置表格率的教程。

非常感谢任何tipps或其他线程或地方我可以检查有关其工作原理的详细信息。

注意:我使用的是Magento 1.9.2.1

1 个答案:

答案 0 :(得分:1)

问题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());

关于你的问题2。

如上所述,我们在请求中有数据,但我们没有简单的接触点。

一个建议是重写 Mage_Shipping_Model_Carrier_Tablerate 并覆盖 getRate 。您要做的是将 BaseSubtotal 设置为 BaseSubtotalInclTax ,调用parent,然后重置请求。

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 以使用您想要的值。

注意:这两种方法都没有经过测试。

相关问题