Needs review
Project:
Commerce Pricing Attributes
Version:
7.x-1.x-dev
Component:
Code
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
2 Aug 2013 at 18:53 UTC
Updated:
21 Dec 2016 at 13:44 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #1
poulou commentedsame here.. any solutions?
Comment #2
d.pagkratis commentedWe do not want them to be in the same line because the option selected maybe different. We want to see the different options.
Comment #3
lanceh1412 commentedChanged this to bug as it says in the features:
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.
Comment #4
lanceh1412 commentedI'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.
Comment #5
lanceh1412 commentedOK. I see what the problem is now. It works but you have to put the options in as Lists not as Term References!
Comment #6
kbrownell commentedThank 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.
Comment #7
alexborsody commented#6 works but you are hacking the module.
Comment #8
sujith.nara commentedYes, 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.
Comment #9
bisonbleu commented@sujith.nara, can you provide an export of your custom rule or a screen capture? That would really be helpful. Thanks.
Comment #10
cosolom commentedThis patch for combining similar line items
Comment #11
nexg commentedThe patch #10 not working for me.
Comment #12
cosolom commentedTry this
Comment #13
cosolom commentedThis is better