3 replies [Last post]
Xano's picture
Offline
Joined: 07/29/2008
Juice: 41
Was this information Helpful?

I am trying to fix the problem in uc_product_kit 5.x-1.2 where the same kits are added as individual products if you hit the 'Add to cart' button twice. See issue #289102 for more information.

It took me a while to figure out how uc_product_kit saved what product kits were added to the cart. I discovered this data was serialised and saved in DB table uc_order_products in the 'data' column. In the module itself it is present as $data (in this case I'm looking at uc_cart_add_item()). During this search I discovered that those kits were added as individual products because when trying to select an existing kit from the cart the DB couldn't find a match against $data, I believe (primarily) because $data['unique_id'] is not always being saved tot the DB and when it is, it is unique, so it will never match any product.

If you would be so kind, I'd like to have some confirmation on this and more information on what $data['unique_id'] does exactly and if it is necessary. For a project I'm working on I need products to be listed only once in the cart and uc_cart_add_item() probably is one of two parts in the code where things go wrong.

Xano's picture
Offline
Joined: 07/29/2008
Juice: 41
Re: What does $data['unique_id'] do?

*Bumps*

Lyle's picture
Offline
AdministratoreLiTe!
Joined: 08/07/2007
Juice: 6846
Re: Re: What does $data['unique_id'] do?

It took me a while to remember, but I think I finally did. When products have attributes, I needed a way to put the right products with the right product kits on the cart page.

Imagine you have two products, A and B, each with attributes and options. A product kit lets them be bought together, but you can still select the attributes for each product. If someone gets a kit with A1 and B2 and a kit with A3 and B4, the cart page shouldn't display A1 and B4 together or A3 with B2. It'd be hard to change the quantity or remove a mistake from the cart if that could happen.

If each kit has a unique identifier, we can keep all the products in the right combinations.

Xano's picture
Offline
Joined: 07/29/2008
Juice: 41
Re: Re: Re: What does $data['unique_id'] do?

Got any idea on how to fix this behaviour? Because now even when two kits are the same and their containing products have the same attributes, the kit is still being added as a separate product.