Home › Forums › Backend Issues (wp-admin) › Add ACF to existing Woocommerce metabox › Reply To: Add ACF to existing Woocommerce metabox
No, both traditional ACF field group and ACF group added into Woocommerce do not contain the same field(s). I’ve found that you need to manually save the ACF fields within woocommerce_process_product_meta
. Feels a little dirty, but it works.
add_action( 'woocommerce_product_options_general_product_data', function() {
acf_form([
'post_id' => get_the_ID(),
'field_groups' => [233],
'form' => false,
]);
});
add_action( 'woocommerce_process_product_meta', function($post_id) {
if (!empty($_POST['acf'])) {
foreach($_POST['acf'] as $key => $value) {
update_field($key, $value, $post_id);
}
}
});
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.