0Day Forums
Combine like products on the same line item in the cart - Printable Version

+- 0Day Forums (https://zeroday.vip)
+-- Forum: Coding (https://zeroday.vip/Forum-Coding)
+--- Forum: CMS (https://zeroday.vip/Forum-CMS)
+---- Forum: Drupal (https://zeroday.vip/Forum-Drupal)
+---- Thread: Combine like products on the same line item in the cart (/Thread-Combine-like-products-on-the-same-line-item-in-the-cart)



Combine like products on the same line item in the cart - globalised594790 - 07-27-2023

I am having the same issue as outlined [here][1] but the solutions below do not work. I do have "Commerce Product Option" enabled.

I also alter the price using this hook,

function mectronic_get_amount_qty($price, $length) {
//print '<pre>P ' . print_r($price, 1) . '</pre>';
//print '<pre>L ' . print_r($length, 1) . '</pre>';

if ($length >= 1 && $length <= 5) return $price;
elseif ($length >= 6 && $length <= 10) return $price * (1 - 0.166666667);
elseif ($length > 10) return $price * (1 - 0.285714286);
}

I have tried

$entity->commerce_pricing_attributes[$set_id['set_id']][$field_name] = $price;

As in #4 but it does not work.


[1]:

[To see links please register here]




RE: Combine like products on the same line item in the cart - yawl491 - 07-27-2023

[To see links please register here]


Use hook_commerce_cart_product_comparison_properties_alter() to unset 'commerce_pricing_attributes' property.

In case, your need your line-items to be distinguished by this property. I suggest you to utilise Rules module.