Jump to content

Negative Cart Rule / Voucher


Recommended Posts

Hi

 

Does anyone know how to make a cart rule negative (exclusive)

 

That is to say for all products that are NOT a member of a certain category the voucher applies. I know I can include all the categories except the one I want to exclude but I have a lot of categories and some overlap, so is not a very functional solution.

 

Thanks in advance 

 

Ward

Link to comment
Share on other sites

  • 2 years later...

I'm workig on this too. Will be handy to add a fee.

When i enter a negative value the cart rule there is a message that says that the value must be greater than zero.

So in AdminCartRulesController.php i commented arround line 220

//if ((int)Tools::getValue('reduction_amount') < 0) {
            //    $this->errors[] = Tools::displayError('Reduction amount cannot be lower than zero.');
            //}

and in AdminGroupsController.php i changed

protected function validateDiscount($reduction)
    {
        if (!Validate::isPrice($reduction) || $reduction > 100 || $reduction < 0) {		 					
            return true;
        } else {
            return true;
        }
    }

to

protected function validateDiscount($reduction)
    {
				if ((!Validate::isPrice($reduction) && $reduction > 100) || (!Validate::isNegativePrice($reduction) && $reduction > -100)) {
            return true;
        } else {
            return true;
        }
    }

 

Now there is a negative value in the database for the reduction_amount in the ps_cart_rule table but the cart rule is now not visible in the cart. So i think there is somewhere another thing i need to change.

 

Anyone any idea?

 

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