Making WooCommerce’s coupon removal message filterable

A proposed WooCommerce fix makes the classic cart and checkout coupon removal message customisable through woocommerce_coupon_message. See the before and after.

My proposed WooCommerce fix lets store owners and extension developers customise the coupon removal message on the classic cart and checkout through woocommerce_coupon_message. PR #69271 is open for review; the screenshots below show the patch applied.

The problem

Removing a coupon through the classic cart’s AJAX handler shows “Coupon has been removed.” The handler writes that text directly, bypassing WC_Coupon::get_coupon_message() and the woocommerce_coupon_message filter.

WooCommerce already defines “Coupon code removed successfully.” for this event in its coupon messaging API. Two strings describe the same action, but only the API’s message reaches the coupon filter. Issue #31198 ↗ reported the gap in November 2021.

The fix

The patch replaces the hardcoded notice in WC_AJAX::remove_coupon() with a call to the existing coupon API:

( new WC_Coupon( $coupon ) )->add_coupon_message( WC_Coupon::WC_COUPON_REMOVED );

With the patch, woocommerce_coupon_message can change the removal notice. The filter receives the message, the removal code (WC_Coupon::WC_COUPON_REMOVED, or 201) and the coupon object. The default becomes “Coupon code removed successfully.”

Returning an empty string suppresses the notice. The existing API also skips duplicate notices, matching the coupon-application path. I reused that API so extensions can control the wording through the same filter, without another hook for one message.

I reproduced the before, after and custom wording in WordPress Playground on WooCommerce 11.1.2, applying the patch for the after captures. The PR adds two PHPUnit tests covering the default and filtered messages; the full suite wasn’t run locally.

As of 1 October 2026, PR #69271 ↗ is open and awaiting review. This change covers AJAX coupon removal on the classic cart and checkout. The Cart and Checkout blocks use a different code path.

Before and after

Classic WooCommerce cart showing the notice: Coupon has been removed.
Before: the hardcoded notice bypasses the coupon message filter.
Classic WooCommerce cart with the patch showing: Coupon code removed successfully.
After: the patch uses the default message from WC_Coupon.
Patched classic WooCommerce cart showing: Coupon removed. Changed your mind? You can add it again anytime.
With a woocommerce_coupon_message filter: the store’s own wording.

See the PR ↗ · Issue ↗


More from the journal

The latest news on sustainability, knitwear and clothing care guides.