如何清空自定义结帐字段的字符串?
How to empty string for custom checkout field?
在 WooCommerce 中,我尝试使用以下方法为自定义结帐字段获取空值:
add_filter('woocommerce_checkout_get_value','__return_empty_string', 1, 1);
但是,它会在加载时删除所有字段。
我只想清空而已['billing']['billing_type']
对了,是无线电场
As it's a radio button custom checkout field, you should provide the necessary code to test it.
使用挂钩在 woocommerce_checkout_get_value
过滤器挂钩中的自定义函数来为任何所需的结帐字段获取空值的正确代码是:
add_filter('woocommerce_checkout_get_value','custom_checkout_get_value', 10, 2);
function custom_checkout_get_value( $value, $imput ){
if($imput == 'billing_type')
$value = '';
return $value;
}
代码进入您的活动子主题(或主题)的 function.php 文件或任何插件文件。
经过测试并在 WC 3+ 中与其他帐单字段一起工作,例如 'billing_phone'
…
在 WooCommerce 中,我尝试使用以下方法为自定义结帐字段获取空值:
add_filter('woocommerce_checkout_get_value','__return_empty_string', 1, 1);
但是,它会在加载时删除所有字段。
我只想清空而已['billing']['billing_type']
对了,是无线电场
As it's a radio button custom checkout field, you should provide the necessary code to test it.
使用挂钩在 woocommerce_checkout_get_value
过滤器挂钩中的自定义函数来为任何所需的结帐字段获取空值的正确代码是:
add_filter('woocommerce_checkout_get_value','custom_checkout_get_value', 10, 2);
function custom_checkout_get_value( $value, $imput ){
if($imput == 'billing_type')
$value = '';
return $value;
}
代码进入您的活动子主题(或主题)的 function.php 文件或任何插件文件。
经过测试并在 WC 3+ 中与其他帐单字段一起工作,例如 'billing_phone'
…