【发布时间】:2016-01-17 22:05:11
【问题描述】:
我使用的付款方式接受分期付款。使用分期付款时,需要使用未打折价格,因此我在sales_quote_collect_totals_before 注册了一个观察员,以便在选中分期付款选项时强制重新计算商品价格(代码如下)。
- 完成单页结帐流程
- 到达支付信息部分
- 选择付款方式
- 检查分期付款选项
- 点击继续
- 到达购物车评论
- 请注意价格未更新(即使观察者已被执行)
- 返回付款方式选择
- 再次点击继续
- 到达购物车评论
- 价格现已更新
谁能解释为什么?并且可能给出一个解决方案来解决我如何跳过步骤 6-11 :-) ?
$installments = /* has the option been checked */
/** @var Mage_Sales_Model_Quote_Item $item */
foreach ($quote->getAllItems() as $item) {
$product = $item->getProduct();
$qty = $item->getQty();
$price = $installments ? $product->getPrice() : $product->getFinalPrice($qty);
if ($price == $item->getOriginalCustomPrice()) {
continue;
}
$item->setPrice($price);
$item->setCustomPrice($price);
$item->setOriginalCustomPrice($price);
$item->calcRowTotal();
}
【问题讨论】:
标签: magento magento-1.7