admin管理员组文章数量:1335606
I have built shop based on Woocommerce. In admin order, I need to disable state field. It shows state code, not full name, so it doesn't really matter.
When you enter certain order in admin page, you will get Billing and Shipping colums.
So basically, this snippet should do, but it doesnt. It removes fields in "edit" view.
add_filter( 'woocommerce_admin_billing_fields', 'custom_admin_billing_fields', 1, 1 );
function custom_admin_billing_fields( $billing_fields ) {
unset($billing_fields['state']);
return $billing_fields;
}
Edit: Here are the screenshots to better understand my problem
As you can see, there is no "state" field, but number 2 (which is state id) shows.
I have built shop based on Woocommerce. In admin order, I need to disable state field. It shows state code, not full name, so it doesn't really matter.
When you enter certain order in admin page, you will get Billing and Shipping colums.
So basically, this snippet should do, but it doesnt. It removes fields in "edit" view.
add_filter( 'woocommerce_admin_billing_fields', 'custom_admin_billing_fields', 1, 1 );
function custom_admin_billing_fields( $billing_fields ) {
unset($billing_fields['state']);
return $billing_fields;
}
Edit: Here are the screenshots to better understand my problem
As you can see, there is no "state" field, but number 2 (which is state id) shows.
Share Improve this question edited May 28, 2020 at 15:39 Slingy asked May 28, 2020 at 15:25 SlingySlingy 311 silver badge5 bronze badges 2
- I'm not clear on the difference between 'edit' and 'admin' - all of the edit screens are in the admin section. Can you clarify the difference? – Tony Djukic Commented May 28, 2020 at 15:29
- @TonyDjukic i have updated my question. – Slingy Commented May 28, 2020 at 15:39
1 Answer
Reset to default 0Maybe try this:
function custom_admin_billing_fields( &$billing_fields ) {
unset($billing_fields['state']);
}
It's not clear if when the custom_admin_billing_fields
function is called if its return is actually captured and used. So it's possible that the return is ignored.
The ampersand (&
) in the parameter definition makes that variable "by reference" instead of "by value". This way any changes made to this variable in the function will always be returned and affect the original variable passed.
本文标签: woocommerce offtopicWhere do I remove admin order fields (unset doesn39t work)
版权声明:本文标题:woocommerce offtopic - Where do I remove admin order fields (unset doesn't work) 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742393106a2466380.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论