【问题标题】:ubercart cart "stacking"ubercart 购物车“堆叠”
【发布时间】:2011-06-18 23:49:02
【问题描述】:

在我的网站上,我使用hook_add_to_cart_data 为项目添加一些额外的自定义。当添加两个相同的产品,但 $data 不同时,似乎 ubercart 会挤压旧的 $data 并将商品堆叠在购物车中,更新 $qty 而不是添加新商品。

我如何告诉 ubercart 将新商品和旧商品视为购物车中的不同商品,这样它们就不会被堆叠,否则我可以控制这种行为吗?

【问题讨论】:

    标签: drupal ubercart


    【解决方案1】:

    不,不应该,请参阅 uc_cart.module 中的 uc_cart_get_contents 函数,第 1358 行:

      for ($i = 0; $i < count($items[$cid]); $i++) {
        if ($items[$cid][$i]->nid == $item->nid && $items[$cid][$i]->data == $item->data) {
          $items[$cid][$i]->qty += $item->qty;
          continue 2;
        }
      }
    

    其中一个原因:在 uc_cart_add_item 函数中调用函数 uc_cart_get_contents 之前,在 hook_add_to_cart_data 实现中,其他一些模块合并(或清理)这两种产品的这些 $data。

    【讨论】:

      猜你喜欢
      • 2011-03-15
      • 2011-05-12
      • 2011-04-28
      • 2015-04-25
      • 2023-03-04
      • 2011-01-30
      • 2018-05-07
      • 2012-06-29
      • 2015-06-09
      相关资源
      最近更新 更多