Jump to content

Limit Virtual product quantity to one.


seb776

Recommended Posts

  • 3 weeks later...

oops, sorry I missed your answer.

 

 

 

Or just don't use quantities for it?

That's it.

 

It's not related to stocks quantities, Stock management is disable. It's related to the fact that a customer may add twice the same virtual product in it's cart. So he will it twice for the same product.

 

But now I've just made a small free module ( http://prestashop.seb7.fr/shop/en/modules/2-limit-virtual-products-quantity.html )

  • Like 1
Link to comment
Share on other sites

  • 9 months later...

Can you provide me access to code of your module? I'm in this situation at this time.

I override the front controller CartController and listen the function processChangeProductInCart, but if i can see you code i will save many time.

 

I'm not lazy man. My time is very, very short.

 

 

THANKS!!

Link to comment
Share on other sites

Forget it.

 

If you want to listen on add or update cart, use the hook actionCartSave and then 

 

$this->context->controller->errors[] = Tools::displayError('Max quantity is 1 for this product.', !Tools::getValue('ajax'));

 

for show errors to the front.

 

Is better than override, if you need to distribute your module.

Link to comment
Share on other sites

One simple contribution.

 

There are one hook that is not listed on documentation and is exactly what i need at this moment.

 

It is actionBeforeCartUpdateQty that is called (as the name says) BEFORE  add or update product in cart. Oppose the actionCartSave that is called AFTER. 

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