Jump to content

Negative Cart Rules/Voucher

Recommended Posts



I am trying to charge a percentage admin fee to an order using the voucher system in Prestashop


I have edited CartRule.php and taken out the validation check for a valid percentage as below:


'reduction_percent' => array('type' => self::TYPE_FLOAT, 'validate' => 'isAnything'),



this solved one of the 2 errors I got when putting in a negative value. The other error is:


"Reduction percent must be between 0% and 100%"


I cant find the check for this in the code.



Can anyone help?






Link to comment
Share on other sites



I have a partial solution.



I have added an extra field to the table "ps_cart_rule" called "negative_value"

Its a boolean field with the default of False.



I have then edited cart.php (as it seems that cartrules.php is no longer used) which checks if negative value is true and if it is makes the discount negative or if not leaves it alone.


It works for amounts applied to the total order. I haven't tested it for other uses. The update to cart.php is attached to this post.



What I am not sure is how to turn this into an override and how I can change the Cart Rules in the back office to show the extra field between the "Apply a discount to" and "Send a Free Gift" parts. Currently once the rule is created I am manually changing negative_value to True.



Can anyone help?







Edited by neiljroper (see edit history)
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...