With this module, "Attempt to combine like products on the same line item in the cart. " doesnt work.

i mean, every product is added as a new line item (doesnt matter, if attributes are changed or not.)

Comments

poulou’s picture

same here.. any solutions?

d.pagkratis’s picture

Category: Bug report » Feature request
Issue summary: View changes

We do not want them to be in the same line because the option selected maybe different. We want to see the different options.

lanceh1412’s picture

Category: Feature request » Bug report

Changed this to bug as it says in the features:

Cart combination based on product attributes.

I understand this to mean that product otions will be combined. I.e. If you add one blue widget then one red widget you will get two line items one for the blue and one for the red widget. If you then add another blue widget the blue widget line item should be updated to show quantity two.

lanceh1412’s picture

I've made some progress on this. The value of the commerce_attributes_pricing property used to determine whether to combine line items is created differently in function commerce_pricing_attributes_field_attach_submit compared to commerce_pricing_attributes_entity_load.
It looks like this line of code
$entity->commerce_pricing_attributes[$set_id['set_id']][$field_name] = isset($values[$lang_code][0]['value'])?$values[$lang_code][0]['value']:''; is suspect. It always returns "" so you never get the value of the option selected.
I can get it to work by using $term = taxonomy_term_load($tid) to load the term object and then setting the value as below:
$entity->commerce_pricing_attributes[$set_id['set_id']][$field_name] = $term;
This is assuming the option set field is set to term reference.

lanceh1412’s picture

OK. I see what the problem is now. It works but you have to put the options in as Lists not as Term References!

kbrownell’s picture

Thank you for opening this discussion! I found it very helpful for trying to achieve a similar task. Although, in my situation, we wanted to combine products even if they were added to the cart with different price attribute values. So I removing the hook_commerce_cart_product_comparison_properties_alter function, around line 1330 in commerce_pricing_attributes.module. In case anyone uses this strategy, note: the cost of products will adjust to the last price attribute chosen.

alexborsody’s picture

#6 works but you are hacking the module.

sujith.nara’s picture

Yes, but we didn't hack the contrib module. We just use this (hook_commerce_cart_product_comparison_properties_alter) in our custom module. However it is not a better approach to unset 'commerce_pricing_attributes' property.

In my case, I created a custom rule to overcome this issue:
Before adding a product to cart, I verify if this product already exists in cart. If exists, I remove the old line-item.
If required, we can also compare its prices.

bisonbleu’s picture

@sujith.nara, can you provide an export of your custom rule or a screen capture? That would really be helpful. Thanks.

cosolom’s picture

Status: Active » Needs review
StatusFileSize
new2.92 KB

This patch for combining similar line items

nexg’s picture

The patch #10 not working for me.

cosolom’s picture

cosolom’s picture