开发者

ubercart cart "stacking"

On my website, I use hook_add_to_cart_data to add some extra customization to items. When two identical products are added, but with different $data, it seems like ubercart squashes the old $data and stacks the items in the cart, updating $qty instead of adding a new item.

How can I tell ubercart to treat the new item and the old item as differe开发者_StackOverflow社区nt items in the cart, so they don't get stacked, and can I otherwise control this behavior?


No, it's shouldn't, see uc_cart_get_contents function in uc_cart.module, row #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;
    }
  }

One of reason: some other module merge (or clean) these $data for both products, before calling function uc_cart_get_contents in uc_cart_add_item function, in hook_add_to_cart_data implemention.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜