How to Add Basic Product Edit of WooCommerce from the Advanced Custom Fields

This will customize way the add/edit to the Product of WooCommerce possible from Advanced Custom Fields.

If you want to without Advanced Custom Fields, please see it post.

How to Add New Product/Edit Product items of WooCommerce from the custom fields

 

WooCommerce with Advanced Custom Fields

WooCommerce with Advanced Custom Fields

 

 

Step1 Remove the metabox of Product Data of WooCommerce

 

Please add code to functions.php of your theme.

 

 

 

Step2 Create the Custom Fields Group of Advanced Custom Fields

 

Please create the Fields Group correspond to simple product of WooCommerce.
And here, correspond to the follow items.

  • Regular Price (number)
  • Sale Price (number)
  • Stock Status (select)
  • Shipping Class (select)

 

For example. And code is here.

 

Create Field Group of Advanced Custom Fields

Create Field Group of Advanced Custom Fields

 

 

But this alone will not work.
Because Stock Status and Shipping Class is not loaded. So it need to customize.

 

Not loaded Shipping Class

Not loaded Shipping Class

 

 

 

Step3 Customize the Fields Group code of Advanced Custom Fields

 

Shipping Class is need in the Shipping Class terms.

But get_terms can not be use in custom_product_basic_acf_register_fields function.
Because it have faster fire than init action. So it change the choices of Shipping Class from acf/load_field filter.

Please add code to functions.php.

 

It looks like this.

 

Add Choices Shipping Class

Add Choices Shipping Class

 

 

 

Step4 Add the other fields.

 

Please add code to custom_product_basic_load_acf function.

 

And please add code to functions.php.

 

 

Step5 Save the data

 

Some field data is can be possible to save.
But Shipping Class is not custom field. So it is be able to save it.

Please add code to functions.php.

 

 

And please add code to custom_product_basic_load_acf function.

 

And please add code to functions.php.

 

 

This is complete! 🙂

It look like this.

 

Example Product with ACF

Example Product with ACF

 

 

Full code is here.

 

 

 

 

 

Leave a Reply

Your email address will not be published. Required fields are marked *


*