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!
❓Ever wondered when and why ACF uses JSON instead of the database? Check out our summary of the most recent session of ACF Chat Friday for the answer, and make sure to register for the next session.
— Advanced Custom Fields (@wp_acf) February 23, 2023
👉 https://t.co/3UtvQbDwNmhttps://t.co/wfFEVcXVKc
© 2023 Advanced Custom Fields.
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 Cookie Policy. If you continue to use this site, you consent to our use of cookies.