drupal - 在购物车中的同一行项目中合并同类产品

标签 drupal drupal-7 drupal-commerce drupal-hooks

我遇到了与 here 相同的问题但以下解决方案不起作用。我确实启用了“商务产品选项”。

我也用这个钩子(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);
}

我试过了
$entity->commerce_pricing_attributes[$set_id['set_id']][$field_name] = $price;

与 #4 一样,但它不起作用。

最佳答案

https://www.drupal.org/node/2056711#comment-9474069

使用 hook_commerce_cart_product_comparison_properties_alter() 取消设置 'commerce_pricing_attributes' 属性。

以防万一,您需要通过此属性区分您的订单项。我建议你使用规则模块。

关于drupal - 在购物车中的同一行项目中合并同类产品,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31387451/

相关文章:

drupal-7 - Drupal 7 更改现有节点的内容类型

drupal - CKEditor 图像属性选项卡消失

php - 在 webfarm 上运行 Drupal 应用程序(可扩展性),如何?

php - drupal 7 db_select 选项

drupal - hook_theme() 是如何工作的?

drupal-7 - 获取用户拥有的所有产品

drupal - 使用 Drupal 商务模块添加折扣

html - Drupal ckeditor 不支持某些 html 标签

api - Drupal 7 编程与 Drupal 6 相比有哪些变化?

drupal - 基于规则的节点创建 : commerce product + product display node set