【问题标题】:Recalculate item prices in onepage checkout在单页结帐中重新计算商品价格
【发布时间】:2016-01-17 22:05:11
【问题描述】:

我使用的付款方式接受分期付款。使用分期付款时,需要使用未打折价格,因此我在sales_quote_collect_totals_before 注册了一个观察员,以便在选中分期付款选项时强制重新计算商品价格(代码如下)。

  1. 完成单页结帐流程
  2. 到达支付信息部分
  3. 选择付款方式
  4. 检查分期付款选项
  5. 点击继续
  6. 到达购物车评论
  7. 请注意价格未更新(即使观察者已被执行)
  8. 返回付款方式选择
  9. 再次点击继续
  10. 到达购物车评论
  11. 价格现已更新

谁能解释为什么?并且可能给出一个解决方案来解决我如何跳过步骤 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


    【解决方案1】:

    好的,我自己找到了答案。

    显然Mage_Sales_Model_Quote_Payment::importData 在分配新的付款数据之前执行Mage_Sales_Model_Quote::collectTotals,之后totals_collected_flag 阻止重新计算。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2019-04-30
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-01-25
      相关资源
      最近更新 更多