Get FAST WordPress Support
World’s Fastest WordPress Support Since 2009  
Go Up  SERVICES  CHAT LIVE  
Easy Change WooCommerce Coupon Error Messages

Change WooCommerce Coupon Error Messages

Need to Change WooCommerce Coupon Error Messages?

WooCommerce is absolutely the most popular online store solution for WordPress users all over the world.

If you are using WooCommerce to sell your products or services online there’s a good chance that you are also using the built-in coupon system to provide discounts and special offers to your customers.

With this built-in coupon system there are pre-written error codes that will display when a coupon is not applied correctly to a customer’s order.

Take a look at the image below as an example of one of these are messages that a customer may see when trying to apply a WooCommerce coupon to their order.

Change WooCommerce Coupon Error Messages

There’s no native way to edit the messages that are displayed when there is a coupon error. So we wanted to put together a post that will show you how you can change these messages to anything you desire.


STEP #1 – Change WooCommerce Coupon Error Messages

In order to change WooCommerce coupon error messages you will need access to the functions. PHP file of your active theme. You can gain access to this file within your hosting control panels file manager or connecting to your website files using an FTP program.

Once you have connected and have access the functions.php file of your active theme you will need to paste in the custom function below into this file and re-save it and then re-upload it to your server.

function coupon_error_message_change($err, $err_code, $WC_Coupon) {
    switch ( $err_code ) {

//CHANGE HIGHLIGHTED COUPON CODE

        case $WC_Coupon::E_WC_COUPON_NOT_EXIST:

            $err = 'YOUR CUSTOM MESSAGE HERE';
    }
    return $err;
}

add_filter( 'woocommerce_coupon_error','coupon_error_message_change',10,3 );

There are two areas in the code snippet above that you will customize based on which WooCommerce coupon messages you wish to edit.


STEP #2 – Change WooCommerce Coupon Error Messages

The first piece will be the coupon code which is the call for the error message depending on which error is being triggered with the applied coupon.

The second area in this custom function that you will change will be the custom coupon message you wish to display to your customers when the error is triggered with an applied coupon.

Below is the list of coupon codes and the original message that will display which is built into WooCommerce.

This information below is from WooCommerce version 6.5.1.

COUPON CODE:
INVALID_FILTERED

ORIGINAL MESSAGE:
Coupon is not valid.
___________________________________

COUPON CODE:
NOT_EXIST

ORIGINAL MESSAGE:
Coupon "%s" does not exist!
___________________________________

COUPON CODE:
INVALID_REMOVED

ORIGINAL MESSAGE:
Sorry, it seems the coupon "%s" is invalid - it has now been removed from your order.
___________________________________

COUPON CODE:
NOT_YOURS_REMOVED

ORIGINAL MESSAGE:
Sorry, it seems the coupon "%s" is not yours - it has now been removed from your order.
___________________________________

COUPON CODE:
ALREADY_APPLIED

ORIGINAL MESSAGE:
Coupon code already applied!
___________________________________
	
COUPON CODE:			
ALREADY_APPLIED_INDIV_USE_ONLY

ORIGINAL MESSAGE:
Sorry, coupon "%s" has already been applied and cannot be used in conjunction with other coupons.
___________________________________

COUPON CODE:
USAGE_LIMIT_REACHED

ORIGINAL MESSAGE:
You have already used this coupon and that is the maximum usage.
___________________________________

COUPON CODE:
EXPIRED

ORIGINAL MESSAGE:
This coupon has expired.
___________________________________

COUPON CODE:
MIN_SPEND_LIMIT_NOT_MET

ORIGINAL MESSAGE:
The minimum spend for this coupon is %s.
___________________________________

COUPON CODE:
MAX_SPEND_LIMIT_MET

ORIGINAL MESSAGE:
The maximum spend for this coupon is %s.
___________________________________

COUPON CODE:
NOT_APPLICABLE

ORIGINAL MESSAGE:
Sorry, this coupon is not applicable to your cart contents.
___________________________________

COUPON CODE:
USAGE_LIMIT_COUPON_STUCK

ORIGINAL MESSAGE:
Coupon usage limit has been reached. If you were using this coupon just now but order was not complete, you can retry or cancel the order by going to the <a href="%s">my account page</a>.

STEP #3 – Change WooCommerce Coupon Error Messages

What you have finalized your custom function with the coupon error code and the custom message you wish to display you just want to make sure you save your functions.php file and load it back up on the server.

If you get stuck trying to implement this please feel free to comment below and we can give you some guidance. Enjoy!


Do all this above with a plugin we created for FREE

If you would like to bypass all the extra steps of hard coding these functions into your theme file you can simply use the free plugin that we created which is hosted at wordpress.org.

grab this buy now button

https://wordpress.org/plugins/custom-coupon-messages/

If you wish to do this for multiple coupon codes you can duplicate this function and give it a unique function name.

Leave a Reply

Your email address will not be published.