add_action( 'woocommerce_before_cart', 'custom_coupon_messages' );
add_action( 'woocommerce_before_checkout_form', 'custom_coupon_messages' );
function custom_coupon_messages() {
global $woocommerce;
$coupon_code = 'Your-Coupon-here';
$coupon_test = new WC_Coupon( 'Your-Coupon-here' );
$cart_subtotal = WC()->cart->subtotal;
if ( $coupon_test->is_valid() && $woocommerce->cart->has_discount( $coupon_code ) ) {
add_filter( 'woocommerce_coupon_message', 'filter_woocommerce_coupon_message', 10, 3 );
function filter_woocommerce_coupon_message( $msg, $msg_code, $instance ) {
$msg_code = 'case self::WC_COUPON_SUCCESS';
$msg = __( 'Your message here!', 'your-theme-text-domain' );
return $msg;
return $msg_code;
};
wc_print_notices();
}
elseif ( $cart_subtotal > 499 ) {
wc_print_notice( 'Spend $500 to qualify for the BIGLY YUGE discount!!!', 'notice' );
}
}