woocommerce offtopic - Where do I remove admin order fields (unset doesn't work)

I have built shop based on Woocommerce. In admin order, I need to disable state field. It shows state code, not full na

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
Add a comment  | 

1 Answer 1

Reset to default 0

Maybe 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.

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1742393106a4435404.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信