[英]Clear checkout fields for specific user(s) in WooCommerce
This code clear all input of the checkout page for everyone.此代码为每个人清除结帐页面的所有输入。 i want to clear all input for specific user.
我想清除特定用户的所有输入。 How can i do this.
我怎样才能做到这一点。
add_filter( 'woocommerce_checkout_get_value' , 'clear_checkout_fields' );
function clear_checkout_fields($input)
{
return '';
}
For a defined user ID you can use (set the related user Id in IF statement) :对于定义的用户 ID,您可以使用(在 IF 语句中设置相关的用户 ID) :
add_filter( 'woocommerce_checkout_get_value', 'clear_checkout_fields' );
function clear_checkout_fields( $input ) {
if ( get_current_user_id() == 259 ) {
return '';
}
return $input;
}
Or for an array of user ids:或者对于一组用户 ID:
add_filter( 'woocommerce_checkout_get_value', 'clear_checkout_fields' );
function clear_checkout_fields( $input ) {
if ( in_array( get_current_user_id(), array( 259, 321, 336 ) ) {
return '';
}
return $input;
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.