fxdesca Posted December 23, 2014 Share Posted December 23, 2014 (edited) Hi,When i create a cart rule for free shipping , I choose a condition for the rule applies only for 1 manufacturer. No minimum command amount.It works okay if I add a product form the manufacturer I selected but if the cart contain also another product from another manufacturer it stills apply free shipping.Any help on how to offer free shipping ONLY if the cart contains product from the selected manufacturer ?Thanks Edited December 23, 2014 by fxdesca (see edit history) Link to comment Share on other sites More sharing options...
PascalVG Posted January 6, 2015 Share Posted January 6, 2015 Hi "Nora", I believe this will work: edit file classes/CartRule.php (make backup!!) find the following code (Sample code from 1.6.0.9) (search for case 'manufacturers' ) and then add the red code: case 'manufacturers': $cartManufacturers = Db::getInstance()->executeS(' SELECT cp.quantity, cp.`id_product`, p.`id_manufacturer` FROM `'._DB_PREFIX_.'cart_product` cp LEFT JOIN `'._DB_PREFIX_.'product` p ON cp.id_product = p.id_product WHERE cp.`id_cart` = '.(int)$context->cart->id.' AND cp.`id_product` IN ('.implode(',', array_map('intval', $eligibleProductsList)).')'); $countMatchingProducts = 0; $allProductsOfManufacturer = true; $matchingProductsList = array(); foreach ($cartManufacturers as $cartManufacturer) if (in_array($cartManufacturer['id_manufacturer'], $productRule['values'])) { $countMatchingProducts += $cartManufacturer['quantity']; $matchingProductsList[] = $cartManufacturer['id_product'].'-0'; } else $allProductsOfManufacturer = false; if (!$allProductsOfManufacturer || $countMatchingProducts < $productRuleGroup['quantity']) return (!$display_error) ? false : Tools::displayError('You cannot use this voucher with these products'); $eligibleProductsList = CartRule::array_uintersect($eligibleProductsList, $matchingProductsList); break; ... This will change the cart rule where a condition is set for manufacturer(s). If not all products are from (one of the) needed manufacturer, it will not give the discount/free shipping/gift. It still allows for setting a minimum amount of products in the cart that has to be of that manufacturer before you get the discount/free shipping, just like before. It only adds the condition you asked for. Example: Product X : manufacturer1 Product Y: manufacturer2 cart rule: if there are at least 2 products with manufacturer is manufacturer2, then get the free shipping, but only if there are NO products of other manufacturers. Result: if Cart contains: - 1 x Product X -> no free shipping (there is no manufacturer2-Product (product Y) in the cart) - 3 x Product X -> no free shipping (there is no manufacturer2-Product (product Y) in the cart) - 1x Product X, 1 x Product Y -> no free shipping (Not the minimum amount of Product Y AND there is a manufacturer1-product (product X) in the cart) - 3 x Product X, 3 x Product Y -> no free shipping ( there is a manufacturer1-product (product X) in the cart) - 3 x Product Y -> FREE SHIPPING (Enough Product Y's and NO products of other manufacturers. Hurray!) To see it work, look here (temp link, may not work in future). (Product with ID=6 and ID=7 are of manufacturer in cart rule. Other products are of manufacturer NOT in cart rule. Cart rule requires at least 3 products of product with ID=6 and/or product with ID=7 to get free shipping. If any other product in cart, no free shipping.) Hope this helps, pascal 1 Link to comment Share on other sites More sharing options...
fxdesca Posted January 7, 2015 Author Share Posted January 7, 2015 Pascal, It does work, you do rock ! Thanks a lot, that's exactly what i was looking for ! Very nice ! Link to comment Share on other sites More sharing options...
PascalVG Posted January 9, 2015 Share Posted January 9, 2015 Perfect. I'll mark the topic as solved. Happy selling and good health for 2015! pascal. 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