我不知道这里是否有任何 Ubercart 大师,但这是我的问题:
我想为订购超过 1 件相同产品的客户提供折扣。
假设价格如下:
1 件产品 - 每件 5 美元
< 10 件产品 - 每件 4.50 美元
< 100 件产品 - 每件 4 美元
任何人都知道如何实现这一点?我想添加我自己的自定义价格字段,但我想知道如何在购物车/结帐中调用它们。
我不是大师,但一些谷歌搜索将我指向 hook_uc_price_handler。
您可以设置一个处理程序来处理价格。
如果您有一个名为“示例”的自定义模块,您可以执行以下操作;
function example_uc_price_handler() {
return array(
'alter' => array(
'title' => t('Quantity price discount handler'),
'description' => t('Discounts the price based on quantity ordered'),
'callback' => 'example_price_alterer',
),
);
}
function example_price_alterer(&$price_info, $context, $options = array()){
if($price_info['qty'] > 200){
$price_info['price'] *= 0.8; //we're reducing the price by 20% as a demo - add your logic here
}
}
这是我的消息来源;
http://www.ubercart.org/docs/developer/11375/price_api http://www.ubercart.org/forum/development/14381/price_alteration_hook http://api.ubercart.org/api/function/hook_uc_price_handler/ 2
uc_bulk_discount模块怎么样?