Make custom checkout fields appear as editable in

2019-07-26 23:50发布

问题:

I added fields to the WooCommerce Checkout field; Some with a plugin ( WooCommerce Checkout Field Editor and WooCommerce Checkout Add-Ons ) and others with a function.

I can export these fields to CSV, but How can I edit them in the order admin page? Sometimes I a user might forget to add their ClientCode or ID Number, and then I want to be able to manually add it.

Thank you Schalk

回答1:

If you want to add existing custom checkout billing and shipping fields to the editable order shipping and billing sections in edit order pages, you will use one or both of the following filter hooks:

  • For editable admin order "Billing" section: woocommerce_admin_billing_fields,
  • For editable admin order "Shipping" section: woocommerce_admin_shipping_fields.

Example usage and related answers:

  • Editable admin custom billing fields error issue in Woocommerce 3
  • Add a drop down list of cities on admin orders pages in Woocommerce

Those fields values will be automatically saved when edited/changed.


For others very custom checkout fields you can add them out of the editable boxes at the bottom of each section using one of those actions hooks:

  • At the bottom of "General" section: woocommerce_admin_order_data_after_order_details
  • At the bottom of "Billing" section: woocommerce_admin_order_data_after_billing_address
  • At the bottom of "Shipping" section: woocommerce_admin_order_data_after_shipping_address

Then you will have to add similar editable fields, with the same keys (name attribute) and use save_post_shop_order action hook…