对于prestashop 1.6我们已经为特定产品设置了购物车规则,通过添加3个产品,另外1个产品将作为礼物添加,
这在购物车页面上运作良好,
但如何在特定产品页面上显示
$context::$this->$cart->$getCartRules();
未在产品页面上显示
我们必须在具有受尊重购物车规则的特定产品上显示购物车规则,
ex. "buy this product and you will get xyz product for free"
答案 0 :(得分:1)
我认为您必须构建自己的查询,选择带有仍然有效的gift_product标识的cart_rules。
在CartRule中添加一个静态方法(或者你需要的地方)并直接在product.tpl中调用并显示它
ex:{CartRule::getGifts($product.id)}
然后,处理结果
答案 1 :(得分:0)
为此构建自定义查询:
$result = Db::getInstance()->executeS('
SELECT *,rg.quantity as minimum_quantity FROM `'._DB_PREFIX_.'cart_rule_product_rule_value` cv
LEFT JOIN `'._DB_PREFIX_.'cart_rule_product_rule` pr ON cv.id_product_rule = pr.id_product_rule
LEFT JOIN `'._DB_PREFIX_.'cart_rule_product_rule_group` rg ON pr.id_product_rule_group = rg.id_product_rule_group
LEFT JOIN `'._DB_PREFIX_.'cart_rule` cr ON cr.id_cart_rule = rg.id_cart_rule
WHERE cv.id_item = '.$this->id_product.' AND cr.gift_product > 0 AND cr.date_to >= "'.date("Y-m-d H:i:s").'"'
);
答案 2 :(得分:0)
我在 Product.php
中的解决方案 public function getRule($category = "0"){
$rules = Db::getInstance()->executeS('SELECT *,rg.quantity as minimum_quantity FROM `'._DB_PREFIX_.'cart_rule_product_rule_value` cv
LEFT JOIN `'._DB_PREFIX_.'cart_rule_product_rule` pr ON cv.id_product_rule = pr.id_product_rule
LEFT JOIN `'._DB_PREFIX_.'cart_rule_product_rule_group` rg ON pr.id_product_rule_group = rg.id_product_rule_group
LEFT JOIN `'._DB_PREFIX_.'cart_rule` cr ON cr.id_cart_rule = rg.id_cart_rule
WHERE code = "" and ((cv.id_item = '.$this->id.' and type = "products") or (cv.id_item = '.$category.' and type = "categories")) AND cr.date_to >= "'.date("Y-m-d H:i:s").'"'
);
return $rules;
}