我正在做一个扩展。在这个扩展中,我需要更新总计。
例如,如果subtotal=$4
和discount_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;
}
}
此时,折扣/会话价值变为两倍。请帮忙。