You add, for instance, product X to your cart and continue browsing the site. After a while you decide you actually want to buy another product X, browse back to the product page and hit the 'Add to cart' button again. When taking a look at the invoice you'll see both products (which are idential) listed separately rather than one product with quantity set to 2.

Comments

xano’s picture

This behaviour appears to be known. See the function commenting of uc_product_kit_cart_display():

* Displays either the kit as a whole, or each individual product based on the
* store configuration. Each product in the cart that was added by uc_product_kit
* was also given a unique kit id in order to help prevent collisions. The side
* effect is that identical product kits are listed separately if added separately.

* The customer may still change the quantity of kits like other products.

xano’s picture

Assigned: Unassigned » xano
Priority: Minor » Normal
Status: Active » Needs review
StatusFileSize
new391 bytes
new1.2 KB

The problem is how product_kit works. The attached patches provide a workaround. They add and implement a function that merges all duplicate products from a single order. This ensures identical products appear only once in the database and on the invoice. During checkout the last product overview also profits from this approach. The first overview (when entering shipping and billing addresses) doesn't. I have tried to implement this approach for this overview as well, but for reasons unknown to me it caused products to be saved to the database in quantities larger than the original ones.

Island Usurper’s picture

Status: Needs review » Needs work

Products are merged together in the cart if they have identical node ids and $data arrays. hook_add_to_cart_data() allows any module to add its own data when a product is added to the cart. Most commonly, the attributes and options are added, and since they affect the SKU of the product, it's important to keep them separate.

uc_product_kit adds the kit id and the unique id to the cart products in case the customer decides to remove the kit from the cart. In that event, it is very important that the right products with the right attributes get removed. While they are in the cart, kit products should remain separated.

However, once the cart has been ordered, I think merging the products is a good idea since product kits cease to matter. You just have to be careful that you don't lose any information when you do a merge. Product kits and attributes can affect the price of their products, so you don't want to lump products together if they have different unit prices.

xano’s picture

Product data shouldn't even be saved as a serialised array in the first place. But that's something for another issue.

Island Usurper’s picture

Status: Needs work » Closed (works as designed)

I think this only affects product kits, as was mentioned earlier. Since they're supposed to to keep the product data from being mangled, it's really "by design".

xano’s picture

Assigned: xano » Unassigned