mirror of
https://gh.wpcy.net/https://github.com/mainwp/Code-Snippets-Functions.git
synced 2026-04-29 11:32:21 +08:00
https://stackoverflow.com/questions/70037818/woocommerce-restrict-coupon-to-user-role-error-message/70039530
12 lines
498 B
Text
12 lines
498 B
Text
function filter_woocommerce_coupon_error( $err, $err_code, $coupon ) {
|
|
// Compare
|
|
if ( intval( $err_code ) === WC_COUPON::E_WC_COUPON_INVALID_FILTERED ) {
|
|
// Message
|
|
$err = sprintf( __( 'Sorry, coupon code "%s" is not valid.', 'woocommerce' ), $coupon->get_code() );
|
|
} else {
|
|
$err = 'DEBUG INFORMATION, error code number = ' . intval( $err_code );
|
|
}
|
|
|
|
return $err;
|
|
}
|
|
add_filter( 'woocommerce_coupon_error', 'filter_woocommerce_coupon_error', 10, 3 );
|