2

我正在做一个扩展。在这个扩展中,我需要更新总计。

例如,如果subtotal=$4discount_amount=$1,授权总数将为$3。我的问题是,当我执行计算时,折扣价变成了两倍。

class PunchTab_Points_Model_Total_Calcdiscount extends Mage_Sales_Model_Quote_Address_Total_Abstract {
    public function collect(Mage_Sales_Model_Quote_Address $address) {
        $session = 2;
        //$session=   Mage::getSingleton('core/session')->getMyValue();
        if (isset($session)) {
            $total_discount = $session;
            //Mage::helper('core')->currency($total_discount, true, false);
            $address - > setCalcdiscountAmount((float) $total_discount);
            $address - > setGrandTotal(($address - > getGrandTotal() - $address - > getCalcdiscountAmount()));
            $address - > setBaseGrandTotal(($address - > getBaseGrandTotal() - $address - > getCalcdiscountAmount()));
            return $this;
        }
    }
    public function fetch(Mage_Sales_Model_Quote_Address $address) {
        $amt = $address - > getCalcdiscountAmount();
        if ($address - > getCalcdiscountAmount() > 0) {
            $address - > addTotal(array('code' => $this - > getCode(), 'title' => Mage :: helper('sales') - > __('Reward Discount'), 'value' => -$amt,));
        }
        return $this;
    }
}

此时,折扣/会话价值变为两倍。请帮忙。

4

1 回答 1

1

你不能做一个快速修复,例如;

$subtotal = 4
$discount_amount= 1

$temp_discount_amount = $discount_amount % 2

$discount_amount = $temp_discount_amount

输出将是您双倍金额的一半,这将是您的预期折扣。我知道这是一个简单的修复,但应该可以。

于 2013-05-21T09:51:47.403 回答