[英]Combine like products on the same line item in the cart
I am having the same issue as outlined here 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. 与#4一样,但它不起作用。
https://www.drupal.org/node/2056711#comment-9474069 https://www.drupal.org/node/2056711#comment-9474069
Use hook_commerce_cart_product_comparison_properties_alter() to unset 'commerce_pricing_attributes' property. 使用hook_commerce_cart_product_comparison_properties_alter()取消设置'commerce_pricing_attributes'属性。
In case, your need your line-items to be distinguished by this property. 如果您需要通过此属性区分您的订单项。 I suggest you to utilise Rules module.
我建议你使用规则模块。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.