cleoni Posted November 20, 2013 Share Posted November 20, 2013 Hello, one of my customers has presented me a problem laying in PS 1.5 and I found no solution to this apart from open requests left unresolved on the forum and issuetracker. Suppose you have a shop with a number of items on sale with reduced prices. Say you are placing these on sale items in a specific category (named, say, "on sale") or that you are ticking the "sale" flag to active the "on sale" icon, or even both things. Now suppose you create a new cart rule (voucher) to give a discount of 25% to all products... of course you do not want to apply this discount on items already on sale. Well, it seems there is absolutely no way to avoid this. If one gets the voucher, she will get the 25% off discount even on items on sale. I think that an option on cart rules saying: "exclude items on this category: ----" or "exclude items marked 'on sale' " would do the job, but it's not there. I think this is a very common case. Perhaps I am tackling the issue in the wrong way?Hope to get a few suggestions, thanks in advance Link to comment Share on other sites More sharing options...
breda_Mcg Posted December 18, 2013 Share Posted December 18, 2013 This is really important to get implemented in the next verison of prestashop as most other shopping carts have a facility to not appy discounts to items already on sale. I hope Prestashop are looking at it. Regards Breda. Link to comment Share on other sites More sharing options...
AndersHelbo Posted January 9, 2014 Share Posted January 9, 2014 I'm also looking for a solution like this. Link to comment Share on other sites More sharing options...
breda_Mcg Posted January 10, 2014 Share Posted January 10, 2014 We needed to apply Discount to only products that were not in the "on sale" We achieved this by Editing the file: classes/CartRule.php After this code: // Do not give a reduction on free products! $order_total = $context->cart->getOrderTotal($use_tax, Cart::ONLY_PRODUCTS, $package_products); foreach ($context->cart->getCartRules(CartRule::FILTER_ACTION_GIFT) as $cart_rule) $order_total -= Tools::ps_round($cart_rule['obj']->getContextualValue($use_tax, $context, CartRule::FILTER_ACTION_G IFT, $package), 2); Add these lines: foreach ($package_products as $product) if($product['on_sale']) $order_total -= $use_tax ? $product['total_wt'] : $product['total']; 3 Link to comment Share on other sites More sharing options...
AndersHelbo Posted January 10, 2014 Share Posted January 10, 2014 We needed to apply Discount to only products that were not in the "on sale" We achieved this by Editing the file: classes/CartRule.php After this code: // Do not give a reduction on free products! $order_total = $context->cart->getOrderTotal($use_tax, Cart::ONLY_PRODUCTS, $package_products); foreach ($context->cart->getCartRules(CartRule::FILTER_ACTION_GIFT) as $cart_rule) $order_total -= Tools::ps_round($cart_rule['obj']->getContextualValue($use_tax, $context, CartRule::FILTER_ACTION_G IFT, $package), 2); Add these lines: foreach ($package_products as $product) if($product['on_sale']) $order_total -= $use_tax ? $product['total_wt'] : $product['total']; Hmm. Did not work for me. Still gets discount on products that are on sale. Link to comment Share on other sites More sharing options...
Lucagiaicheca Posted February 19, 2014 Share Posted February 19, 2014 Didn't work for me too on PS 1.5.1 Any suggestion? Link to comment Share on other sites More sharing options...
mrluck Posted March 20, 2014 Share Posted March 20, 2014 Didn't work for me too on PS 1.5.1 Any suggestion? Worked perfectly for me on PS 1.5. I didn't change original files. I copied CartRule.php to override/clases directory and edited it right there. Then I cleared theme cache in BO and turned off CCC for a while. Then it started working. 1 Link to comment Share on other sites More sharing options...
Guorilla Posted March 30, 2014 Share Posted March 30, 2014 Hello, I did put this code into CartRules.php and then tried to shop... What works is that there's no reduction given in a % voucher on the products in sale... But the strange thing is that when I try to apply this code to a sales product, in the cart the prices is changed to the normal (not on sale) price... So something is not going the right way... What can be wrong? Thanks... Link to comment Share on other sites More sharing options...
mouse1 Posted March 31, 2014 Share Posted March 31, 2014 Hi everyone. Solution from post #4 does not work for me either on 1.5.4.0 :-( Link to comment Share on other sites More sharing options...
AlexFL Posted April 7, 2014 Share Posted April 7, 2014 Worked for me too, 1.5.6.2 Just don't forget to clear your cache on Performance settings. Link to comment Share on other sites More sharing options...
elvispl Posted April 15, 2014 Share Posted April 15, 2014 its work (ps 1.5.6.2) but... you must 'checked' ON SALE option in your products. 1 Link to comment Share on other sites More sharing options...
elvispl Posted April 15, 2014 Share Posted April 15, 2014 If I do not have the 'On sale' marked however is the reduced price. I think thet is problem all us. Any help? ps. sorry to my english Link to comment Share on other sites More sharing options...
elvispl Posted April 15, 2014 Share Posted April 15, 2014 SOLVED Ok I have the solution: CartRule.php line ~796 after: $order_total -= Tools::ps_round($cart_rule['obj']->getContextualValue($use_tax, $context, CartRule::FILTER_ACTION_GIFT, $package), 2); foreach ($package_products as $product) // if($product['on_sale']) if (Product::isDiscounted((int)$product['id_product'])) $order_total -= $use_tax ? $product['total_wt'] : $product['total']; 2 Link to comment Share on other sites More sharing options...
Guorilla Posted April 20, 2014 Share Posted April 20, 2014 (edited) OK, and then when a client has a 'oney' voucher, they still can buy the sale products? Or then also not? Thanks... ______ EDIT: I see that if I use a 'money' voucher, the price of the sales article is going back to the normal price... How can this be changed? Anyone a clue over here? Edited April 20, 2014 by dekarperboer (see edit history) Link to comment Share on other sites More sharing options...
vekia Posted April 20, 2014 Share Posted April 20, 2014 you can order "on sale" products with voucher code, why not? Link to comment Share on other sites More sharing options...
blackflow Posted May 3, 2014 Share Posted May 3, 2014 (edited) you can order "on sale" products with voucher code, why not? Yes but the problem is when you have products on sale presta shouldn't add discount coupons because it doesn't make sense:) Edited May 5, 2014 by blackflow (see edit history) Link to comment Share on other sites More sharing options...
vekia Posted May 3, 2014 Share Posted May 3, 2014 yeap i understand, unfortunately, this option was disabled in prestashop 1.5.x i have no idea why, in 1.4 and oldest releases it was a default feature Link to comment Share on other sites More sharing options...
Guorilla Posted May 5, 2014 Share Posted May 5, 2014 you can order "on sale" products with voucher code, why not? Hello Vekia, sorry for the late reaction, but I was on holidays... What I mean is following: For % vouchers/rules: When I order some products which are in sale, with this code the price of the product will get back to the normal price and then is calculating the discount (%), after that the order price is reduced with the discount calculated... This is OK... For money vouchers/rules: When I order some products which are in sale, with this code the price of the product will get back to the normal price and after that the total order price is reduced with the value of the money voucher... This is NOT OK... Because a money voucher should have the possibilities of enjoying the sales prices. If you know what I mean... Thanks, Marco Link to comment Share on other sites More sharing options...
blackflow Posted May 7, 2014 Share Posted May 7, 2014 SOLVED Ok I have the solution: CartRule.php line ~796 after: $order_total -= Tools::ps_round($cart_rule['obj']->getContextualValue($use_tax, $context, CartRule::FILTER_ACTION_GIFT, $package), 2); foreach ($package_products as $product) // if($product['on_sale']) if (Product::isDiscounted((int)$product['id_product'])) $order_total -= $use_tax ? $product['total_wt'] : $product['total']; Yep, it's working. But still there's a small problem. When you add a product that is not on sale and use a coupon it adds a discount for the whole cart. A finishing touch from Vekia and we will have a perfect solution;) Link to comment Share on other sites More sharing options...
vekia Posted May 7, 2014 Share Posted May 7, 2014 Yep, it's working. But still there's a small problem. When you add a product that is not on sale and use a coupon it adds a discount for the whole cart. A finishing touch from Vekia and we will have a perfect solution;) hello you have to define target of code in "actions" section, if you selected that code is for whole cart, it will be included for whole cart\ there is also available solution as a module for PrestaShop 1.5 and 1.6: disble vouchers for items on sale Link to comment Share on other sites More sharing options...
Guorilla Posted July 5, 2014 Share Posted July 5, 2014 hello you have to define target of code in "actions" section, if you selected that code is for whole cart, it will be included for whole cart Can you explain what you mean Vekia? We really need some coding for this... Let me try what I'm looking for again: At this moment, when a customer adds a product to the cart that is in SALE and they use a % cart rule the SALE price is removed and the original price shows up. That’s not what we want, what we want is that % cart rules can never be used on products that are in SALE. When a customer uses an € amount cart rule they should be able to also buy SALE products. Now, what we want is that the % sales vouchers keep working as they do now, when a customer fills in a % voucher the sales price returns to the normal / original price and then calculates the discount over the normal / original price. But when a customer fills in an € amount voucher, then the sales price has to stay. As we sell these vouchers to our customers, it’s a bit strange that the price of Sales products will change. From what we understand, you want to sell vouchers with a specific € amount. Is that right? Please also confirm if we can add these vouchers as products. This means that an adjustment needs to be made to how the cart will handle different cart rules (% rule and € rule). See Cart Image #1 Here you van see the cart without a cart rule applied and you can see the sales price is calculated on some products. See Cart Image #2 Here you can see the cart with a % cart rule applied and you can see the sales prices are removed and the % cart rule is then calculated over the normal / standard price giving the customer the discount of 15% over the total of the cart. THIS IS WORKING GOOD! See Cart Image #3 Here you see the cart with a € cart rule applied and you can also see here the sales prices are set back to normal / original price and after that the customer get’s the € discount price. THIS IS NOT WORKING GOOD! As we want the € cart rule applied to the cart WITH the sales prices as I tried to make clear in See Cart Image #4. Is this possible you think? Thanks... Link to comment Share on other sites More sharing options...
Dolemite Posted July 14, 2014 Share Posted July 14, 2014 I've got to work this somehow on a Prestashop 1.5.2. I've used the code with the "if($product['on_sale'])" clause instead of the call to Product::isDiscounted funtion. I don't think it's the optimal way of resolving this issue as each time we want to have a discounted price we need to mark the product with the "on sale" mark. Anyone having problem with the Product::isDiscounted function? Even thought the product had a discount (catalogue rule o price rule) the function returned false and the whole discount to the order was applyed. I'll keep on investigating this and if I find a solution I'll post it here. Thanks to all the contributors. Link to comment Share on other sites More sharing options...
zandrauppzala Posted August 23, 2014 Share Posted August 23, 2014 I haven't used 1.5, but in the process of upgrading from 1.4 to 1.6. I was happy to see that there are further possibilities to configure the cart rules, but it's a pity that one can't exclude already discounted products/categories/specific products. I'm regularly running special offers like 10% or 15% off the whole store, but I need to be able to exclude certain product categories/products such as e-gift certificates and additional shipping charges. Is there a way to do this? Thanks Link to comment Share on other sites More sharing options...
sirDonald Posted September 8, 2014 Share Posted September 8, 2014 (edited) I was having trouble disabling the group discount if a product is already on sale. This thread has helped me quite a lot, but I still had to look through a lot of code. So this is how I did it, I hope it helps someone! In GroupReduction.php In the function "getValueForProduct", after if (!Group::isFeatureActive()) return 0; i added: if (Product::isDiscounted($id_product)) return 0; Note: I'm running 1.6.0.6 Cheers! Edited September 8, 2014 by sirDonald (see edit history) Link to comment Share on other sites More sharing options...
ClearSolid Posted October 1, 2014 Share Posted October 1, 2014 Why cant they add a product level "disable cart rule" feature. Would solve everyones problems. Link to comment Share on other sites More sharing options...
mfreew Posted October 1, 2014 Share Posted October 1, 2014 I was having trouble disabling the group discount if a product is already on sale. This thread has helped me quite a lot, but I still had to look through a lot of code. So this is how I did it, I hope it helps someone! In GroupReduction.php In the function "getValueForProduct", after if (!Group::isFeatureActive()) return 0; i added: if (Product::isDiscounted($id_product)) return 0; Note: I'm running 1.6.0.6 Cheers! SirDonald, I have recently downloaded the latest version of 1.6.0.9 and I am also trying to exclude sale items on a store wide voucher (though I think it would be nice to have the option per cart rule). Is the code you posted above the extent of the changes you made or did you use any of the code previously posted in this thread or other wise? Tks, Link to comment Share on other sites More sharing options...
PrestaShark Posted October 24, 2014 Share Posted October 24, 2014 We needed to apply Discount to only products that were not in the "on sale" We achieved this by Editing the file: classes/CartRule.php After this code: // Do not give a reduction on free products! $order_total = $context->cart->getOrderTotal($use_tax, Cart::ONLY_PRODUCTS, $package_products); foreach ($context->cart->getCartRules(CartRule::FILTER_ACTION_GIFT) as $cart_rule) $order_total -= Tools::ps_round($cart_rule['obj']->getContextualValue($use_tax, $context, CartRule::FILTER_ACTION_G IFT, $package), 2); Add these lines: foreach ($package_products as $product) if($product['on_sale']) $order_total -= $use_tax ? $product['total_wt'] : $product['total']; I must say big thanks! Real life saver. Makes the job! 1) I have put into basket some sale product 2) I want to apply voucher code and nothing happend (no alert no voucher in shopping cart) yay! 3) I add non sale product to basket and before applied voucher is available and the voucher reduce price only to non discounted product! Superb! 1.5.6.2 1 Link to comment Share on other sites More sharing options...
PrestaToys Posted November 28, 2014 Share Posted November 28, 2014 (edited) Wow! Same nightmare problem, but i have found a workaround and I must share. I am using 1.5.6.2 I did not want to make a coding change. I tried everything, almost... Then I tried this and it works perfectly!!!. Presta-tricks!!! Create a new manufacturer called On Sale (or whatever you like) go to each Product that is on sale and go to the Associations tab change the Manufacturer to On Sale go to your cart rule that is providing a discount for all regular priced merchandise only go to Product Selection and add a rule concerning all manufacturers except the On Sale manufacturer under Actions choose to apply discount to all selected products So happy that this works. Please tell me if it does or does not work for you!!! Remember also to also uncombine the other cart rules if necessary. Cheers! Edited November 28, 2014 by PrestaToys (see edit history) 2 Link to comment Share on other sites More sharing options...
mouse1 Posted November 30, 2014 Share Posted November 30, 2014 Thank you all for a great help!! Post #13 works perfectly for me. Plus I added a piece of code that disables my two products from the whole cart discount (gift vouchers). This is my code: foreach ($package_products as $product) // if($product['on_sale']) if (Product::isDiscounted((int)$product['id_product'])) $order_total -= $use_tax ? $product['total_wt'] : $product['total']; foreach ($package_products as $product) if ($product['id_product'] == 45 || $product['id_product'] == 46) $order_total -= $use_tax ? $product['total_wt'] : $product['total']; Link to comment Share on other sites More sharing options...
yay Posted December 2, 2014 Share Posted December 2, 2014 Wow! Same nightmare problem, but i have found a workaround and I must share. I am using 1.5.6.2 I did not want to make a coding change. I tried everything, almost... Then I tried this and it works perfectly!!!. Presta-tricks!!! Create a new manufacturer called On Sale (or whatever you like) go to each Product that is on sale and go to the Associations tab change the Manufacturer to On Sale go to your cart rule that is providing a discount for all regular priced merchandise only go to Product Selection and add a rule concerning all manufacturers except the On Sale manufacturer under Actions choose to apply discount to all selected products So happy that this works. Please tell me if it does or does not work for you!!! Remember also to also uncombine the other cart rules if necessary. Cheers! Creative solution! Unfortunately this requires all products to have a manufacturer set, right? So if you're not using Manufacturers you would have to set all regular priced products to a manufacturer called "Not On Sale". Link to comment Share on other sites More sharing options...
PrestaToys Posted December 2, 2014 Share Posted December 2, 2014 Hey Yay, I do not have manufacturers set and it works for me... I think it should work for you too. Not sure if version matters (I am using 1.5.6.2) Try it and see! Good luck. Link to comment Share on other sites More sharing options...
yay Posted December 2, 2014 Share Posted December 2, 2014 (edited) Hey Yay, I do not have manufacturers set and it works for me... I think it should work for you too. Not sure if version matters (I am using 1.5.6.2) Try it and see! Good luck. Thanks for the reply! Don't know if I'm just slow today but I can't get it to work completely. If I keep the On sale manufacturer in the Unselected box, I don't get a discount for On Sale products. So far so good. But what doesn't work is discounts for other products. Since my regular priced products don't have a Manufacturer they are not affected by the cart rule and should therefore not work. Right? Using 1.5.6.2 as well. Edited December 2, 2014 by yay (see edit history) Link to comment Share on other sites More sharing options...
PrestaToys Posted December 2, 2014 Share Posted December 2, 2014 hi Yay, I checked further. Of course, it's a bit strange. When i look at the Manufacturers tab, i see a whole list of manufacturers. But when i go to a Product's Association Tab, the Manufacturer is blank. I created a new manufacturer called "On Sale" and select. My other products still have a blank for manufacturer. When i set up the cart rule, I add all the manufacturers for the condition and then remove the "On Sale" manufacturer. Then it works. Check to see if you have any Manufacturers on the Catalog > Manufacturers tab. If so, they should appear in the cart rules, and you can make this work. If not, maybe you will have to create them... my list of manufacturers simply corresponds to the Brand name of the product. I will keep investigating on my end, but it seems to have worked for the Cyber Monday Deal that I set up. Worst case, you will have to create a list of manufacturers (or maybe just the on sale and not on sale). Link to comment Share on other sites More sharing options...
PrestaToys Posted December 2, 2014 Share Posted December 2, 2014 Seems I have 73 Manufacturers listed but they are all disabled except "On Sale" Starting to seem kinda strange that this works, but it does. Link to comment Share on other sites More sharing options...
PrestaToys Posted December 2, 2014 Share Posted December 2, 2014 Ok checked the database. My ps_products table shows id_manufacturer from 1 to 73. The ones that I put "On Sale" are #73. Check your table. If they are all #1, make "Not on Sale" #1 then create the "On Sale" as #2 (or whatever the system generates) If they are all zero, then create #1 and change them to #1, then change the On Sale ones to #2 (or whatever the system generates) Good luck! Link to comment Share on other sites More sharing options...
yay Posted December 3, 2014 Share Posted December 3, 2014 Thanks again for taking the time. Might look into automating this solution. Editing all id_manufacturer to a "Not on sale" manufacturer in the database is done in a jiffy but then again it's easy to forget to add the "Not on sale" manufacturer to all new products. Maybe it would be easiest to add some SQL trigger that adds the "Not on sale" manufacturer to all new products and then adds the "On sale" manufacturer to all products that get a specific price or has the On sale checkbox active. Link to comment Share on other sites More sharing options...
Danijelp Posted June 18, 2015 Share Posted June 18, 2015 (edited) Hi, i'm using 1.6.0.14 and I cant' get this to work. Has anyone has some solution for this. I don't use vouchers, coupons etc... I'm using customer group discount for every customer with his own customer group. All I need is to don't get group discount for products marked ON SALE. Is this possible somehow? Please; I need help ASAP!!! thnx Edited June 18, 2015 by Danijelp (see edit history) Link to comment Share on other sites More sharing options...
pietrac Posted July 1, 2015 Share Posted July 1, 2015 It's working for me fine, it does not include discount to the products what are already on sale. But i have another issue a bit different. I would need to apply the same price rule / discount to all products (which are on sale and which are not) and to apply a discount from a base price. So let say: one product i have with 10 %, 2nd 15%discount and i want now 30% to all. Normally would take 30% from already 10%/15% discounted product, with above mentioned code it does not take at all. Any ideas? Many thanks in advance.. Link to comment Share on other sites More sharing options...
DARKF3D3 Posted July 2, 2015 Share Posted July 2, 2015 Why PS team removed this feature? Now that I'm using PS1.6.0.9 and I can't make anymore a voucher that add discount only to products without any price reduction. Link to comment Share on other sites More sharing options...
dhada Posted September 1, 2015 Share Posted September 1, 2015 try this I'm using prestashop 1.6.0.9 it will remove the sale items from the discount computation In CartRule.php find this if statement code // Discount (%) on the selection of products if ($this->reduction_percent && $this->reduction_product == -2) and replace it with this code // Discount (%) on the selection of products if ($this->reduction_percent && $this->reduction_product == -2) { $selected_products_reduction = 0; $selected_products = $this->checkProductRestrictions($context, true); if (is_array($selected_products)) foreach ($package_products as $product) if (in_array($product['id_product'].'-'.$product['id_product_attribute'], $selected_products) || in_array($product['id_product'].'-0', $selected_products)) { if (!(Product::isDiscounted((int)$product['id_product']))){ $price = ($use_tax ? $product['price_wt'] : $product['price']); $selected_products_reduction += $price * $product['cart_quantity']; } } $reduction_value += $selected_products_reduction * $this->reduction_percent / 100; } 2 Link to comment Share on other sites More sharing options...
catzarov Posted October 27, 2015 Share Posted October 27, 2015 Hi all I'm using 1.6.1.1 the code on CartRule.php is: // Discount (%) on a specific product if ($this->reduction_percent && $this->reduction_product > 0) { foreach ($package_products as $product) { if ($product['id_product'] == $this->reduction_product) { $reduction_value += ($use_tax ? $product['total_wt'] : $product['total']) * $this->reduction_percent / 100; } } } How do I edit to stop the use voucher of the products in discount? Link to comment Share on other sites More sharing options...
rastavmp Posted November 5, 2015 Share Posted November 5, 2015 Hi! First sorry for my english. the code used by dhada is only when I select products in the cart rules. If we have product with discounts, the cart rules action would be 'apply in the order', and modify cartRules.php: // Discount (%) on the whole order if ($this->reduction_percent && $this->reduction_product == 0) { // Do not give a reduction on free products! $selected_products_reduction = 0; foreach ($package_products as $product) if (!(Product::isDiscounted((int)$product['id_product']))){ $price = ($use_tax ? $product['price_wt'] : $product['price']); $selected_products_reduction += $price * $product['cart_quantity']; } $reduction_value += $selected_products_reduction * $this->reduction_percent / 100; } Link to comment Share on other sites More sharing options...
dex Posted November 8, 2015 Share Posted November 8, 2015 Im running presta 1.6.0.14 and as everyone else on this thread im having issues with this discount and voucher thing... When i replace code: // Discount (%) on the whole order if ($this->reduction_percent && $this->reduction_product == 0) { // Do not give a reduction on free products! $order_total = $context->cart->getOrderTotal($use_tax, Cart::ONLY_PRODUCTS, $package_products); foreach ($context->cart->getCartRules(CartRule::FILTER_ACTION_GIFT) as $cart_rule) $order_total -= Tools::ps_round($cart_rule['obj']->getContextualValue($use_tax, $context, CartRule::FILTER_ACTION_GIFT, $package), _PS_PRICE_COMPUTE_PRECISION_); $reduction_value += $order_total * $this->reduction_percent / 100; } with code: // Discount (%) on the whole order if ($this->reduction_percent && $this->reduction_product == 0) { // Do not give a reduction on free products! $selected_products_reduction = 0; foreach ($package_products as $product) if (!(Product::isDiscounted((int)$product['id_product']))){ $price = ($use_tax ? $product['price_wt'] : $product['price']); $selected_products_reduction += $price * $product['cart_quantity']; } $reduction_value += $selected_products_reduction * $this->reduction_percent / 100; } It gets working as far as function wise, but my theme get disorted... product image on product page and related products images get stretched somehow (actually just place for them gets stretched as you can see from following images) I hope you guys have any solution to this. and Link to comment Share on other sites More sharing options...
rastavmp Posted November 8, 2015 Share Posted November 8, 2015 Hi Dex! It's very strange, the cartRule.php code only affects the cart, not the product page. Can you send the url? Link to comment Share on other sites More sharing options...
dex Posted November 8, 2015 Share Posted November 8, 2015 Hi Dex! It's very strange, the cartRule.php code only affects the cart, not the product page. Can you send the url? Yeah i know that it shouldnt affect it, but somehow it does. This is random product url: http://dsbutik.si/kratke-obleke/170-modna-balonasta-obleka But you wont see much there since i have returned it back to as it was while looking for solution. I couldnt leave it that way because this is live store. I will be gratefull for any tips and solutions. Link to comment Share on other sites More sharing options...
ramlov Posted November 23, 2015 Share Posted November 23, 2015 ... I think that an option on cart rules saying: "exclude items on this category: ----" ... Hey. Dose any one have a code to make the cart rule not include a specific catagory in the order total? Jacob Link to comment Share on other sites More sharing options...
Aagje Vanden Bussche Posted November 25, 2015 Share Posted November 25, 2015 I'm also running into this problem. While the idea of post #28 might be a solution, it is limited. The cart rule condition 'product selection' or 'manufacturer selection' says: The cart must contain at least Product(s) matching the following rules: Add a rule concerning -- Choose -- Products Attributes Categories Manufacturers Suppliers [Manufacturers] The product(s) are matching on of these Choose Which means that as soon as a product from an allowed selection/category is added to the cart, the whole cart will get the discount (in my case 15%). So even items that are already on sale, which I don't want to allow a double discount on, are treated as 'okay' since at least 1 product/category is correct under this condition.I'm looking for a rule setup with EXCEPTIONS. A rule where you can say: all products, categories... except category/product A, B or C Link to comment Share on other sites More sharing options...
ramlov Posted December 4, 2015 Share Posted December 4, 2015 Hey. Dose any one have a code to make the cart rule not include a specific catagory in the order total? Jacob Hey again. Would somthing like foreach ($package_products as $product) { if ($product['category=1']) { if ($use_tax) $order_total -= Tools::ps_round($product['total_wt'],2); else $order_total -= Tools::ps_round($product['total'],2); } } Work? Link to comment Share on other sites More sharing options...
ramlov Posted December 20, 2015 Share Posted December 20, 2015 (edited) Thank you all for a great help!! Post #13 works perfectly for me. Plus I added a piece of code that disables my two products from the whole cart discount (gift vouchers). This is my code: foreach ($package_products as $product) // if($product['on_sale']) if (Product::isDiscounted((int)$product['id_product'])) $order_total -= $use_tax ? $product['total_wt'] : $product['total']; foreach ($package_products as $product) if ($product['id_product'] == 45 || $product['id_product'] == 46) $order_total -= $use_tax ? $product['total_wt'] : $product['total']; Hey Mouse1 it seems that I cant make your last code work. What version of prestashop do you use? Edited December 20, 2015 by ramlov (see edit history) Link to comment Share on other sites More sharing options...
patelakshay177 Posted January 27, 2016 Share Posted January 27, 2016 #13 post works perfectly in my ps, but i want throw a warning massege in cart that "Coupon are not applied on special product" when user applied coupon on cart . Help me!!! Thanks in advance. Link to comment Share on other sites More sharing options...
Cas Posted January 30, 2016 Share Posted January 30, 2016 (edited) For me the solution in post #13 works fine so far. (PS v1.6.1.3) I had just a little confusion about the position to add the code. I looked like the solution should be in the previous foreach loop but actually is a new foreach loop --> so put the code after the ending bracket } ;-) foreach ($context->cart->getCartRules(CartRule::FILTER_ACTION_GIFT) as $cart_rule) { $order_total -= Tools::ps_round($cart_rule['obj']->getContextualValue($use_tax, $context, CartRule::FILTER_ACTION_GIFT, $package), _PS_PRICE_COMPUTE_PRECISION_); } // no discount for on sale products foreach ($package_products as $product) if($product['on_sale']) $order_total -= $use_tax ? $product['total_wt'] : $product['total']; Edited January 30, 2016 by Cas (see edit history) Link to comment Share on other sites More sharing options...
patelakshay177 Posted February 1, 2016 Share Posted February 1, 2016 need a warning message on cart when voucher applied on special product.... Link to comment Share on other sites More sharing options...
2p12p1 Posted February 20, 2016 Share Posted February 20, 2016 Still can't get it to work in presta 1.6. Is there really no way to do this without changing the code? Can someone make a simple module that insert the correct code in the right place? Link to comment Share on other sites More sharing options...
Joe Dalborn Posted February 23, 2016 Share Posted February 23, 2016 Hi everybody, my CartRule.php is more like this so i don't know where to insert the code or if it will work at all.. // Do not give a reduction on free products! $order_total = $context->cart->getOrderTotal($use_tax, Cart::ONLY_PRODUCTS, $package_products); foreach ($context->cart->getCartRules(CartRule::FILTER_ACTION_GIFT) as $cart_rule) $order_total -= Tools::ps_round($cart_rule['obj']->getContextualValue($use_tax, $context, CartRule::FILTER_ACTION_GIFT, $package), _PS_PRICE_COMPUTE_PRECISION_); $reduction_value += $order_total * $this->reduction_percent / 100; } Link to comment Share on other sites More sharing options...
quadd Posted March 25, 2016 Share Posted March 25, 2016 This code foreach ($package_products as $product) if($product['on_sale']) $order_total -= $use_tax ? $product['total_wt'] : $product['total']; from post #52 works on PS 1.6.1.3 (although it makes no sense) BUT ONLY for percent discounts.... It is not working if the discount is an amount Link to comment Share on other sites More sharing options...
roberto77 Posted May 9, 2016 Share Posted May 9, 2016 Hi I tried this solution, it works https://github.com/PrestaShop/PrestaShop/pull/2060/files 3 Link to comment Share on other sites More sharing options...
PrestaShark Posted May 9, 2016 Share Posted May 9, 2016 Hi I tried this solution, it works https://github.com/PrestaShop/PrestaShop/pull/2060/files Well done! Great contribution!!! 1 Link to comment Share on other sites More sharing options...
Juhy Posted June 8, 2016 Share Posted June 8, 2016 Hi I tried this solution, it works https://github.com/PrestaShop/PrestaShop/pull/2060/files I tried this solution, but in PS 1.6.1.4 it's not working. Coupons are not showing in cart also there in so reductons for non sales products Link to comment Share on other sites More sharing options...
Rissinko Posted November 8, 2016 Share Posted November 8, 2016 Hey guys is there any solution how to count in cart how much products is in discount and how much products from the same cart is not in discount ? I need to use my function when there are only products in discount. so i need check if there are some products which are not in discount. Thanks. Link to comment Share on other sites More sharing options...
MNBY Posted November 11, 2016 Share Posted November 11, 2016 No solution yet? This is a major "feature"! 1.6.1.7 Link to comment Share on other sites More sharing options...
PrestaShark Posted November 18, 2016 Share Posted November 18, 2016 Hi. I found (damn!) issue with this mod When i add product that is disabled to use with Voucher and add him to cart i have correct info that voucher dont work with this product. But when i add product that is valid with this voucher the voucher works for both products (not only for the valid product but the disabled too!!) Link to comment Share on other sites More sharing options...
Attrexx Posted February 12, 2017 Share Posted February 12, 2017 On PS 1.6.1.9 the solution #51 (https://www.prestashop.com/forums/topic/290274-disabling-discounts-cart-rules-to-items-already-on-sale/?p=2244540) worked GREAT! - If I put an "On sale" product in cart, voucher does not apply- If I put a regular price product, voucher works fine- and most importantly, if I add two products, one discounted and one with full price, the discount is applied only to the full-priced one yay! If you want to test the outcome, fiddle on the website: larysa.ro A great solution indeed! Maybe PS could use it for a future feature? The only (small) drawback is that the client is not being notified that his voucher was not applied. It just does not appear in summary. But all in all it works great! Many thanks, guys. Link to comment Share on other sites More sharing options...
peeweetoms Posted March 16, 2017 Share Posted March 16, 2017 I can't get this to work in 1.6.1.11 I have tried numerous ways to get this to work and can't, even built an overide and a plugin fix based off of the plugin suggested to no avail. What's more annoying is we have tons of experience in presta shop but this seems to baffle everyone. Link to comment Share on other sites More sharing options...
hakeryk2 Posted March 31, 2017 Share Posted March 31, 2017 (edited) try this I'm using prestashop 1.6.0.9 it will remove the sale items from the discount computation In CartRule.php find this if statement code // Discount (%) on the selection of products if ($this->reduction_percent && $this->reduction_product == -2) and replace it with this code // Discount (%) on the selection of products if ($this->reduction_percent && $this->reduction_product == -2) { $selected_products_reduction = 0; $selected_products = $this->checkProductRestrictions($context, true); if (is_array($selected_products)) foreach ($package_products as $product) if (in_array($product['id_product'].'-'.$product['id_product_attribute'], $selected_products) || in_array($product['id_product'].'-0', $selected_products)) { if (!(Product::isDiscounted((int)$product['id_product']))){ $price = ($use_tax ? $product['price_wt'] : $product['price']); $selected_products_reduction += $price * $product['cart_quantity']; } } $reduction_value += $selected_products_reduction * $this->reduction_percent / 100; } This solution works on 1.6.0.4 but does anyone know how to show information to the customer that vouchers cannot be applied for already discounted products? Edited May 18, 2017 by hakeryk2 (see edit history) Link to comment Share on other sites More sharing options...
Attrexx Posted August 10, 2017 Share Posted August 10, 2017 (edited) For me the solution in post #13 works fine so far. (PS v1.6.1.3) I had just a little confusion about the position to add the code. I looked like the solution should be in the previous foreach loop but actually is a new foreach loop --> so put the code after the ending bracket } ;-) foreach ($context->cart->getCartRules(CartRule::FILTER_ACTION_GIFT) as $cart_rule) { $order_total -= Tools::ps_round($cart_rule['obj']->getContextualValue($use_tax, $context, CartRule::FILTER_ACTION_GIFT, $package), _PS_PRICE_COMPUTE_PRECISION_); } // no discount for on sale products foreach ($package_products as $product) if($product['on_sale']) $order_total -= $use_tax ? $product['total_wt'] : $product['total']; I regret to resurrect this thread but even though the solution at post #51 worked great (been using it on all my shops for a while now) it seems we have a problem I use a special "SALE" category where I associate all my reduced products. This is because Prestashop lacks ANOTHER very basic feature, which is product filtering on the dynamically generated "prices-drop" page. So I have to use a SALE category instead Not nice, PS, not nice. Anyhow, the problem I ran into today is that if a product is both associated with the SALE category AND it's regular category, the the (fixed amount) voucher code gets applied in cart, even if I have it set up not to. If I deselect it's regular category and leave checked only the SALE one, the voucher gets rejected (with warning and all) on the order page. Thing is, I don't want to be forced to keep all my products that are on sale ISOLATED in a specific category! As far as I can understand from the mods in post #51, it checks for reduced price and not for category association, therefore it shouldn't be doing this kind of trickery Any ideas? [Feel free to test this on the live site (condurbyalexandru.com)] Edited August 10, 2017 by Attrexx (see edit history) Link to comment Share on other sites More sharing options...
Recommended Posts