【问题标题】:Can't set 0% tax rate不能设置 0% 的税率
【发布时间】:2014-01-17 10:30:30
【问题描述】:

我使用的是相当新的 Magento 1.8.0.0 安装,核心没有任何变化。当尝试将税率设为 0% 时,Magento 在保存时返回以下错误:Rate Percent 应该是一个正数。

这只是 Magento 1.8 中的一个错误,让我无法将税率设置为 0%,还是我遗漏了什么?

【问题讨论】:

    标签: php magento-1.8


    【解决方案1】:

    您需要覆盖 app\code\core\Mage\Tax\Model\Calculation\Rate.php

    <config>
    <global>
        <models>
            <mypackage_mymodule>
                <class>MyPackage_MyModule_Model</class>
            </mypackage_mymodule>
            <tax>
                <rewrite>
               <calculation_rate>MyPackage_MyModule_Model_Calculation_Rate</calculation_rate>  
                </rewrite>
            </tax>
        </models>
    </global>
    

    创建一个新的 rate.php 并从 app\code\core\Mage\Tax\Model\Calculation\Rate.php

    重写你的代码。

    我就是这样做的。 :) :) 希望这会有所帮助。

    【讨论】:

      【解决方案2】:

      因此,这种行为(在 CE 1.8.0.0 中引入 - 它在 CE 1.7.0.2 中按预期工作)似乎将被删除。

      与此同时,您可以尝试重写 app/code/core/Mage/Tax/Model/Calculation/Rate.php 并删除这些行:

      if (!is_numeric($this->getRate()) || $this->getRate() <= 0) {
              Mage::throwException(Mage::helper('tax')->__('Rate Percent should be a positive number.'));
          }
      

      相反,您也可以更改代码以测试 $this-&gt;getRate() &lt; 0 而不是 $this-&gt;getRate() &lt;= 0.

      它正在工作。

      【讨论】:

      • 重写一个核心类是一个巨大的禁忌。您应该扩展类并覆盖适用的方法。
      猜你喜欢
      • 2018-10-18
      • 1970-01-01
      • 2017-06-30
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-05-06
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多