Magento定制附加费导致错误的购物车计算

时间:2015-04-07 11:29:09

标签: php magento

对于我们的一位客户,如果设置了特殊属性,我会编写自定义送货延期,包括特定附加费。一旦我通过模块的config.xml文件激活附加费等级,计算就错了。即使我不覆盖任何代码,只需访问父implmetation。如果我在运行相同版本1.9.1.0的空白Magento商店上安装我的自定义模块,它可以工作。所以我也尝试在System>的管理面板中设置相同的配置参数。配置>销售>税

这是应该的计算。我的购物车里有一篇文章,含税。

Subtotal (without Tax)  3,69 €
Subtotal (incl. Tax)    3,95 €
Grandtotal without Tax  3,69 €
Tax                     0,26 €
Grandtotal inkl. Tax    3,95 €

当我在配置文件中包含附加费节点

时会发生这种情况
Subtotal (without Tax)  3,95 €
Subtotal (incl. Tax)    3,95 €
Surcharge               4,00 €
Grandtotal without Tax  7,95 €
Tax                     0,26 €
Grandtotal incl. Tax    8,21 €

config xml中的节点包含如下:

    <config>
    <global>
    <sales>
        <quote>
            <totals>
                <surcharge>
                    <class>***_***_Model_Total_Quote</class>
                </surcharge>
            </totals>
        </quote>
    </sales>
    </global>
    </config>

这是实际的实施。如前所述,如果我实际实现了collect或fetch,或者我只是调用了父实现,那就没什么区别了。

<?php
class ***_***_Model_Total_Quote extends Mage_Sales_Model_Quote_Address_Total_Abstract
{
public function collect(Mage_Sales_Model_Quote_Address $address)
{
    parent::collect($address);

    if (($address->getAddressType() == 'billing')) {
        return $this;
    }

        $surcharge = $this->_getSurcharge();
        $this->_addAmount(Mage::app()->getStore()->convertPrice($surcharge));
        $this->_addBaseAmount($surcharge);

    return $this;
}
public function fetch(Mage_Sales_Model_Quote_Address $address)
{
    if (($address->getAddressType() == 'billing')) {

            $address->addTotal(array(
                'code' => 'surcharge',
                'title' => $this->_getTitle(),
                'value' => $this->_getSurcharge()
            ));
    }
    return $this;
}

private function _getSurcharge()
{
    return Mage::getStoreConfig('carriers/***/***');
}

private function _getTitle()
{
    return Mage::getStoreConfig('carriers/***/title');
}
}

0 个答案:

没有答案
相关问题