FredActin Posted December 21, 2010 Share Posted December 21, 2010 Hello guys,I have been playing with Prestashop 1.4 alpha 3 for a while now and there is a new minimum quantity feature which is great.I tweaked it so that only multiples of this minimum quantity can be added to the basket.The problem is that if somebody tries to add a wrong quantity, I get a message box stating "you need add # quantity minimum"I need to be able to change that.I looked for "I need add" everywhere: all the template files, the translation, the core files and even the database without luck.Anybody would have any idea where I could find that?Please note that this is NOT the message that appears above the "add to cart" button. I changed that without problem (product.tpl file)Thanks in advance! Link to comment Share on other sites More sharing options...
rocky Posted December 22, 2010 Share Posted December 22, 2010 It's on line 160 of /controllers/CartController.php: die('{"hasError" : true, "errors" : ["'.Tools::displayError('you need to add', false).' '.$producToAdd->minimal_quantity.' '.Tools::displayError('quantity minimum', false).'"]}'); You will need to override CartController.php to change it. Link to comment Share on other sites More sharing options...
FredActin Posted December 22, 2010 Author Share Posted December 22, 2010 Fantastic!!Many thanks Rocky, I don't know why I didn't find it but that's exactly what I was looking for :-)Cheers! Link to comment Share on other sites More sharing options...
marcellinho Posted April 8, 2011 Share Posted April 8, 2011 Hello guys,I have been playing with Prestashop 1.4 alpha 3 for a while now and there is a new minimum quantity feature which is great.I tweaked it so that only multiples of this minimum quantity can be added to the basket.The problem is that if somebody tries to add a wrong quantity, I get a message box stating "you need add # quantity minimum"I need to be able to change that.I looked for "I need add" everywhere: all the template files, the translation, the core files and even the database without luck.Anybody would have any idea where I could find that?Please note that this is NOT the message that appears above the "add to cart" button. I changed that without problem (product.tpl file)Thanks in advance! Hello, please could you post here your modification, where only multiples of the quantity could be added to the basket?Thanks Link to comment Share on other sites More sharing options...
FredActin Posted April 8, 2011 Author Share Posted April 8, 2011 Hi,I had a few issues with this code.On 1.4 a3 there were some issues with tax so I tried again on 1.4Rc1 and it was working mostly fine. I think there were a few glitches but maybe you can improve it!The code below is from my 1.4a3 files but I think that's the same for 1.4rc1I haven't touched this code for a while but if I remember correctly:on "cart.php" classChange this after /* Update quantity if product already exist */- operator "Up" if (($quantity < $product->minimal_quantity) OR ($quantity %$product->minimal_quantity <>0)) return -1; - operator "down" if (($newQty < $product->minimal_quantity AND $product->minimal_quantity > 1)OR ($quantity %$product->minimal_quantity <>0 AND $product->minimal_quantity > 1)) return -1; Same on this one after /* Add product to the cart */ if (($quantity < $product->minimal_quantity) OR ($quantity %$product->minimal_quantity <>0)) return -1; Hope that makes sense Link to comment Share on other sites More sharing options...
marcellinho Posted April 13, 2011 Share Posted April 13, 2011 Thanks. Everything works fine.Now I´m wondering if it is possible to have this feature for some products. Link to comment Share on other sites More sharing options...
FredActin Posted April 13, 2011 Author Share Posted April 13, 2011 Not sure what you mean.Do you mean being able to have only minimum quantities for some products and multiple of quantities for others? Link to comment Share on other sites More sharing options...
marcellinho Posted April 13, 2011 Share Posted April 13, 2011 I ment, being able to have quantities (example : 4(minimum),5,6,7,... ) for some productsand multiple of quantities for others. Link to comment Share on other sites More sharing options...
FredActin Posted April 13, 2011 Author Share Posted April 13, 2011 Hum ok it's not the proper way to do it but that's what I'd do:You need to add another "AND" on your code and test another variable of the product.For instance if you don't use the EAN13 feature on the back end you could use it so that if you put a "1" it a minimum quantity product and if it is a "0" then it is a multiple quantity product.Following this example I think you can call the EAN13 variable with id_product->ean13Hope this makes sense!So you would have something like this if (($quantity < $product->minimal_quantity) OR (($quantity %$product->minimal_quantity <>0 AND (id_product->ean13 > 0))) return -1; I didn't check this code by the way, it's probably wrong but it gives you an idea hopefully Link to comment Share on other sites More sharing options...
marcellinho Posted April 16, 2011 Share Posted April 16, 2011 Thank you very much. Finally i´ve done it Cheers! Link to comment Share on other sites More sharing options...
FredActin Posted April 16, 2011 Author Share Posted April 16, 2011 Cool well done! If you get a chance share the code here, I'm sure it will help others Link to comment Share on other sites More sharing options...
Adria Laxson Posted July 5, 2011 Share Posted July 5, 2011 I have a question about this subject. I need to use 3 different classes on mine. Some items are singles, some are in 3's and some are in 6's. How can I use the EAN13 for this and make them automatically add multiples to the cart if need be for that product?Thank you. Link to comment Share on other sites More sharing options...
FredActin Posted July 6, 2011 Author Share Posted July 6, 2011 This piece of code is just a quick fix and I don't think it is suitable for anything more complex (I think it's possible with more tweaking though). I believe you would be better off selling your products as "packs" i.e. one pack of 6 / one pack of 3 etc... Link to comment Share on other sites More sharing options...
Adria Laxson Posted July 8, 2011 Share Posted July 8, 2011 Yes, I see. That's the way I'm currently selling. At times I have to break the packs & create a different "hidden" product of singles to place orders. It becomes an inventory nightmare. That's why I was thinking sell in singles but make the customer buy in prepacks. Thanks for your thoughts. Maybe I'll figure out something. 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