Jump to content

[Solved] "You need add" minimum product warning box - prestashop 1.4 alpha 3


Recommended Posts

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

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

  • 3 months later...
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

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.4rc1

I haven't touched this code for a while but if I remember correctly:

on "cart.php" class

Change 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

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->ean13

Hope 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

  • 2 months later...

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

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

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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...