Jump to content

How to exclute a category from coupon


classic506

Recommended Posts

Hi!, does anyone know how to exclude a category from coupon on the latest Prestashop version 1.6.1.0?

 

For example: We created a coupon of 50% to be a apply to a certain category, however. If a customer comes in and adds a product from a different category to the existing cart... the coupon will apply to the products of both categories.

 

Is there a way to have the coupon applying the 50% to the category it was created for and none other?

 

Thanks for your time!

Ali.

Link to comment
Share on other sites

I think you need some custom coding here.
The CartRule class has a checkValidity() method. Within it, I'd say at the end, you might try to loops through all products (if $products is not assigned, use  $context->cart->getProducts().
Then get all categories for each. if any of them is not in the category you want (you will have to hardcode the ID), then return an error

 return (!$display_error) ? false : Tools::displayError('Invalid Category');

Like that

Link to comment
Share on other sites

  • 5 years later...

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