我正在开展一个项目,我们正在使用后续电子邮件通过电子邮件在购物车中重新定位客户。我们正在做的是发送带有用户购物车和10%折扣的电子邮件。
因此,当用户点击链接时,我们会以10%的折扣激活用户丰富的购物车。如果用户使用优惠券代码,我们会在优惠券中添加10%的金额。
我们想要显示折扣,但我们想要在新行中显示额外10%的额外费用。是什么意思
优惠券折扣金额 额外10%的折扣金额
这意味着折扣分为两行。如果用户不使用优惠券,我们只打折一行 额外10%的折扣金额
如果有人有意,请告诉我......
这是我正在使用的代码。
[code]
if($discountAmount>0) {
$total=$quote->getBaseSubtotal();
$quote->setSubtotal(0);
$quote->setBaseSubtotal(0);
$quote->setSubtotalWithDiscount(0);
$quote->setBaseSubtotalWithDiscount(0);
$quote->setGrandTotal(0);
$quote->setBaseGrandTotal(0);`enter code here`
$canAddItems = $quote->isVirtual()? ('billing') : ('shipping');
foreach ($quote->getAllAddresses() as $address) {
$address->setSubtotal(0);
$address->setBaseSubtotal(0);
$address->setGrandTotal(0);
$address->setBaseGrandTotal(0);
$address->collectTotals();
$quote->setSubtotal((float) $quote->getSubtotal() + $address->getSubtotal());
$quote->setBaseSubtotal((float) $quote->getBaseSubtotal() + $address->getBaseSubtotal());
$quote->setSubtotalWithDiscount(
(float) $quote->getSubtotalWithDiscount() + $address->getSubtotalWithDiscount()
);
$quote->setBaseSubtotalWithDiscount(
(float) $quote->getBaseSubtotalWithDiscount() + $address->getBaseSubtotalWithDiscount()
);
$quote->setGrandTotal((float) $quote->getGrandTotal() + $address->getGrandTotal());
$quote->setBaseGrandTotal((float) $quote->getBaseGrandTotal() + $address->getBaseGrandTotal());
$quote ->save();
$quote->setGrandTotal($quote->getBaseSubtotal())
->setBaseGrandTotal($quote->getBaseSubtotal())
->setSubtotalWithDiscount($quote->getBaseSubtotal())
->setBaseSubtotalWithDiscount($quote->getBaseSubtotal())
->save();
if($address->getAddressType()==$canAddItems) {
//echo $address->setDiscountAmount; exit;
$address->setSubtotalWithDiscount((float) $address->getSubtotalWithDiscount()-$discountAmount);
$address->setGrandTotal((float) $address->getGrandTotal()-$discountAmount);
$address->setBaseSubtotalWithDiscount((float) $address->getBaseSubtotalWithDiscount()-$discountAmount);
$address->setBaseGrandTotal((float) $address->getBaseGrandTotal()-$discountAmount);
if($address->getDiscountDescription()){
$address->setDiscountAmount(-($address->getDiscountAmount()-$discountAmount));
$address->setDiscountDescription($address->getDiscountDescription().', Custom Discount');
$address->setBaseDiscountAmount(-($address->getBaseDiscountAmount()-$discountAmount));
}else {
$address->setDiscountAmount(-($discountAmount));
$address->setDiscountDescription('Custom Discount');
$address->setBaseDiscountAmount(-($discountAmount));
}
$address->save();
Mage::getSingleton('core/session')->setspecialURLdiscount('updated');
// header("Cache-Control: no-cache");
}
} //end: foreach
}
}
[/代码]
答案 0 :(得分:0)
我从您的问题中了解到,以下信息可能会对您有所帮助。
在课程Mage_SalesRule_Model_Validator
中,您可以设置折扣说明。
在功能
中 public function process(Mage_Sales_Model_Quote_Item_Abstract $item)
转到以下行。
$discountAmount = $result->getDiscountAmount();
并在上面的代码之后放置以下2行,这将在当前的foreach循环中准备我们的描述数组
$_formatedDiscountAmount = Mage::helper('core')->currency($discountAmount, true, false);
$_descriptionArray[] = $rule->getName()."-".$_formatedDiscountAmount;
最后,在数组结束后立即放置此代码
$address->setDiscountDescriptionArray($_descriptionArray);
在$_descriptionArray
数组中,您可以获得折扣说明。