Christophe Boix Posted September 13, 2016 Share Posted September 13, 2016 (edited) Bonjour, plusieurs clients m'ont demandé de ne plus jamais rendre cumulable un bon de réduction, et certains modules créent des codes promo cumulables par défaut. J'ai oublié de préciser que c'est pour Prestashop v1.6 Si vous ne voulez plus que les codes promos soient cumulables, éditez le fichier CartRule.php se trouvant dans /classes (mieux vaut créer un override de cette classe) et modifiez les conditions (IF) comme ci-dessous. Commentez le code comme ci-dessous : /* if ($this->cart_rule_restriction && $otherCartRule['cart_rule_restriction'] && $otherCartRule['id_cart_rule'] != $this->id) { $combinable = Db::getInstance()->getValue(' SELECT id_cart_rule_1 FROM '._DB_PREFIX_.'cart_rule_combination WHERE (id_cart_rule_1 = '.(int)$this->id.' AND id_cart_rule_2 = '.(int)$otherCartRule['id_cart_rule'].') OR (id_cart_rule_2 = '.(int)$this->id.' AND id_cart_rule_1 = '.(int)$otherCartRule['id_cart_rule'].')'); if (!$combinable) { $cart_rule = new CartRule((int)$otherCartRule['id_cart_rule'], $context->cart->id_lang); // The cart rules are not combinable and the cart rule currently in the cart has priority over the one tested if ($cart_rule->priority <= $this->priority) { return (!$display_error) ? false : Tools::displayError('This voucher is not combinable with an other voucher already in your cart:').' '.$cart_rule->name; } // But if the cart rule that is tested has priority over the one in the cart, we remove the one in the cart and keep this new one else { $context->cart->removeCartRule($cart_rule->id); } } } */ Rajoutez ce code après le commentaire : if ($otherCartRule['id_cart_rule'] != $this->id) { $cart_rule = new CartRule((int)$otherCartRule['id_cart_rule'], $context->cart->id_lang); // The cart rules are not combinable and the cart rule currently in the cart has priority over the one tested if ($cart_rule->priority <= $this->priority) { return (!$display_error) ? false : Tools::displayError('This voucher is not combinable with an other voucher already in your cart:').' '.$cart_rule->name; } // But if the cart rule that is tested has priority over the one in the cart, we remove the one in the cart and keep this new one else { $context->cart->removeCartRule($cart_rule->id); } } Il existe surement d'autres manière de faire, celle-ci fonctionne bien et créera une erreur lorsque l'on veut rajouter un 2e code promo dans son panier. ----------------------- Ensuite, pour la page Mes bons de réductions : I faut modifier la colonne Cumulable pour obliger le "Non". Pour cela, ouvrez le fichier discount.tpl du thème, et enlever le IF ELSE pour ne laisser que la ligne du "No".Par exemple dans discount.tpl , remplacez : <td class="discount_cumulative"> {if $discountDetail.cumulable == 1} <i class="icon-ok icon"></i> {l s='Yes'} {else} <i class="icon-remove icon"></i> {l s='No'} {/if} </td> par : <td class="discount_cumulative"> <i class="icon-remove icon"></i> {l s='No'} </td> Vous pouvez aussi masquer la colonne du cumul si vous voulez avec ce bout de css à la fin de votre fichier global.css par exemple : #discount table.discount .discount_cumulative{ display:none; } Edited September 13, 2016 by Christophe Boix (see edit history) Link to comment Share on other sites More sharing options...
Olivier CLEMENCE Posted September 13, 2016 Share Posted September 13, 2016 Super merci 1 Link to comment Share on other sites More sharing options...
Christophe Boix Posted September 13, 2016 Author Share Posted September 13, 2016 de rien, ravi d'avoir aidé Link to comment Share on other sites More sharing options...
AAymeric Posted September 13, 2016 Share Posted September 13, 2016 J'ai fait quelques tests de mon côté, ça fonctionne bien dans la version : 1.6.1.0 Merci pour le partage. 1 Link to comment Share on other sites More sharing options...
Christophe Boix Posted September 13, 2016 Author Share Posted September 13, 2016 j'ai oublié de préciser, si vous utilisez la page Mes bons de réductions, alors il faut modifier la colonne Cumulable pour obliger le "Non".Pour cela, ouvrez le fichier discount.tpl du thème, et enlever le IF ELSE pour ne laisser que la ligne du "No".Par exemple dans discount.tpl , remplacez : <td class="discount_cumulative"> {if $discountDetail.cumulable == 1} <i class="icon-ok icon"></i> {l s='Yes'} {else} <i class="icon-remove icon"></i> {l s='No'} {/if} </td> par : <td class="discount_cumulative"> <i class="icon-remove icon"></i> {l s='No'} </td> 1 Link to comment Share on other sites More sharing options...
rachel01 Posted April 27, 2020 Share Posted April 27, 2020 (edited) Merci pour ce tuto ! Edited April 27, 2020 by rachel01 (see edit history) 1 Link to comment Share on other sites More sharing options...
opiii Posted March 15 Share Posted March 15 Voici le code à rajouter pour PS 1.7.7.5 if ($otherCartRule['id_cart_rule'] != $this->id) { $cart_rule = new CartRule((int) $otherCartRule['id_cart_rule'], $cart->id_lang); // The cart rules are not combinable and the cart rule currently in the cart has priority over the one tested if ($cart_rule->priority <= $this->priority) { return (!$display_error) ? false : $this->trans('This voucher is not combinable with an other voucher already in your cart: %s', [$cart_rule->name], 'Shop.Notifications.Error'); } else { // But if the cart rule that is tested has priority over the one in the cart, we remove the one in the cart and keep this new one $cart->removeCartRule($cart_rule->id); } } 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