On a WooCommerce store, when a user puts the coupon code it says “Coupon code applied successfully.”. Do you want to change it? WooCommerce provides a hook woocommerce_coupon_message for this.
/**
* Snippet Name: Modify WooCommerce Coupon Message
*/
add_filter( 'woocommerce_coupon_message', 'modify_woocommerce_coupon_message', 10, 3 );
function modify_woocommerce_coupon_message( $msg, $msg_code, $coupon ) {
if( $msg === __( 'Coupon code applied successfully.', 'woocommerce' ) ) {
$msg = sprintf(
__( "You are getting $%s discounts.", "woocommerce" ),
'<strong>' . $coupon->get_amount() . '</strong>'
);
}
return $msg;
}
Now when someone adds a coupon code, it would say “You are getting 100 USD discounts.”
Link: Code Snippet
Leave a Reply