ChDUP Posted December 29, 2015 Share Posted December 29, 2015 (edited) Bonjour à toutes et à tous. Prestashop dans ses version 1.5 et 1.6 ne permet pas d'exclure les produits déjà remisés lorsque l'on crée une règle panier. Une fonctionnalité qui semble pourtant évidente et indispensable. Personnellement, voici ma méthode pour que les règles paniers ne s'appliquent pas aux produits remisés, mais s'appliquent bien aux autres produits du panier si ceux-ci sont éligibles. Il faut modifier la méthode checkProductRestrictions de la class CartRule. Il est donc bien évidemment conseillé de passer par un override. modif effectuée sur 1.6.0.9 Remplacez $eligibleProductsList = array(); if (isset($context->cart) && is_object($context->cart) && is_array($products = $context->cart->getProducts())) foreach ($products as $product) $eligibleProductsList[] = (int)$product['id_product'].'-'.(int)$product['id_product_attribute']; if (!count($eligibleProductsList)) return (!$display_error) ? false : Tools::displayError('You cannot use this voucher in an empty cart'); par $eligibleProductsList = array(); $promoProduct=false; if (isset($context->cart) && is_object($context->cart) && is_array($products = $context->cart->getProducts())) foreach ($products as $product) { if(empty($product["reduction_applies"]) || $product["reduction_applies"] == 0) $eligibleProductsList[] = (int)$product['id_product'] . '-' . (int)$product['id_product_attribute']; else $promoProduct = true; } if (!count($eligibleProductsList) && $promoProduct == false) return (!$display_error) ? false : Tools::displayError('You cannot use this voucher in an empty cart'); elseif (!count($eligibleProductsList) && $promoProduct == true) return (!$display_error) ? false : Tools::displayError('You cannot use this voucher with discounts products.'); Edited December 29, 2015 by ChDUP (see edit history) Link to comment Share on other sites More sharing options...
Eolia Posted December 29, 2015 Share Posted December 29, 2015 (edited) Perso, je n'aurais pas écrit ça à la mode Prestashop mais plutôt $eligibleProductsList = array(); $promoProduct = false; if (isset($context->cart) && is_object($context->cart) && is_array($products = $context->cart->getProducts())) { foreach ($products as $product) { if(empty($product["reduction_applies"])) $eligibleProductsList[] = (int)$product['id_product'] . '-' . (int)$product['id_product_attribute']; else $promoProduct = true; } if (!count($eligibleProductsList)) { if(!$promoProduct) return (!$display_error) ? false : Tools::displayError('You cannot use this voucher in an empty cart'); else return (!$display_error) ? false : Tools::displayError('You cannot use this voucher on an already discounted'); } } Edited December 29, 2015 by Eolia (see edit history) 1 Link to comment Share on other sites More sharing options...
Oron Posted December 29, 2015 Share Posted December 29, 2015 Bonjour Je pense que ce topic serait mieux placé dans : Aide er support communautaire >> Utilisation et Prestashop configuration et difficultés. Merci de bien poster au bon endroit. Topic déplacé. 1 Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now