I have a coupon code (XYZ25) in woocommerce which include 25% off and maximum discount is Rs.250.
How can i restrict user's to not get more than Rs.250 Discount if they apply coupon code XYZ25 for 25% discount.
I have a coupon code (XYZ25) in woocommerce which include 25% off and maximum discount is Rs.250.
How can i restrict user's to not get more than Rs.250 Discount if they apply coupon code XYZ25 for 25% discount.
You could set an additional coupon
FIX250
code based on a fixed cart discount of **RS.250
(without tax) and with a Minimun spend of(4 x 250) = RS.1000
.Then with the help of the script below, if customer apply your
XYZ25
coupon code and if the cart total is up to Rs.1000, it will replaceXYZ25
coupon byFIX250
displaying at the same time an explicative notice…Here is that code:
Code goes in function.php file of your active child theme (or theme) or also in any plugin file.
This working code is tested on WooCommerce versions 2.6.x and 3.0+.
As @LoicTheAztec pointed out. It's either a fixed or a percentage discount.
Here's the code:
What this will do is also calculate the discount using "Fixed cart discount" logic; and using the
$max_discount
as the coupon amount to compute. Then whichever is the smaller among the two gets used up.To simply put it, let's take this example
min( A, B )
.A
is the max discount, andB
is the result of percent discount calculation.min( 250, 100 ) = 100
min( 250, 150 ) = 150
min( 250, 250 ) = 250
min( 250, 300 ) = 250
min( 250, 600 ) = 250
Thus resulting to always getting the desired max discount.
I have written more code relating to this here.
UPDATE another way of doing it but same result.