我发现即使在使用
之后隐藏一些结帐字段也会出现问题// woocommerce checkout page
add_filter( 'woocommerce_checkout_fields' , 'custom_override_checkout_fields' );
function custom_override_checkout_fields( $fields ) {
unset($fields['billing']['billing_company']);
unset($fields['billing']['billing_country']);
unset($fields['billing']['billing_state']);
return $fields;
}
我什至用一个插件进行了测试,问题仍然存在,它仍然在前端显示输入。
添加代码后,您可以看到输入仍在显示,但它变得比其他字段短:
最佳答案
解决了定义 add_action()
函数中使用的参数的优先级和数量的问题:
// woocommerce checkout page
add_filter( 'woocommerce_checkout_fields' ,'custom_override_checkout_fields',20,1 );
function custom_override_checkout_fields( $fields ) {
unset($fields['billing']['billing_company']);
unset($fields['billing']['billing_country']);
unset($fields['billing']['billing_state']);
return $fields;
}
这里是解决方案^^
关于php - 在 Woocommerce 中隐藏一些结帐字段问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48460006/