Top sellers

  • Delete Orders
    Delete Orders

    Enable the option to delete orders in admin page -> orders Also you...

    $0.00
  • CoolShare
    CoolShare

    Add a social bookmarks with mouse over animation.

    $0.00
  • Categories image
    Categories image

    This module allows you to display the block in the category, but with...

    $0.00
  • Mass price update
    Mass price update

    This module allows you to update quantity or percentage, the prices of...

    $0.00

In this little tutorial, we'll show you how to create a cart rule that only applies if cart products do NOT belong to a certain category. For example, we wish to have a discount of 10% for the entire catalog, but we do not want that discount applied if the products purchased belong to the category HOT SALE (ID 10).

First we create the discount rule as we normally do, and then modify the CartRule.php file.

The file that is responsible for validating the coupons is the classes / CartRule.php, inside it, there is a function called "checkValidity".

What we will do is add our code to the beginning of this function, but for this we can create a file called CartRule.php inside the folder overrides / classes / and create the override, or directly modify the original file in classes / CartRule.php ( If we update PrestaShop the change is lost and we must do it again). There are hundreds of tutorials to do overrides, so we will focus on the function itself.

The only thing we need to change is the category code that prevents the rule from being applied to apply the Voucher. In this case it is 10