Home › Forums › Backend Issues (wp-admin) › Adding additional data to woocommerce product
Hi,
I’m hoping to get a bit of assistance. I’ve created a series of fields that I would like to appear in the editor for the products. I can make it appear as any other meta data like it would normally appear for other posts types but I’m hoping to insert it into a custom product data tab. I’ve had a hunt around and I can find lots of information about how to add it to the product tabs on the front end but not in the admin area.
Here’s the code I have so far:
// Add additional tab to product-data section
add_filter('woocommerce_product_data_tabs','fifteen_event_data');
function fifteen_event_data( $tabs ) {
$tabs['fifteen'] = array (
'label' => 'Event Details',
'target' => 'fifteen_add_event_data',
'class' => array('show_if_ticket'),
'priority' => 40,
);
return $tabs;
}
add_action ('woocommerce_product_data_panels','fifteen_event_data_panels');
function fifteen_event_data_panels() {
echo '<div id="fifteen_add_event_data" class="panel woocommerce_options_panel hidden">';
echo '<div class="options_group show_if_ticket">';
echo the_field('event_start');
echo the_field('event_end');
echo the_field('event_venue');
echo '</div>';
echo '</div>';
}
Using this I can see the values that I’ve already added but I don’t have any option to edit them.
Thanks!
Hi Vverner,
I’ve given it a try but it embeds the form onto the product data tab rather than integrating with it (you can’t update these fields unless you use the update button provided at the bottom of the tab). I wasn’t sure if there was any documentation or an example for something similar that I can use a basis?
@fifteenit did you ever figure this out? I’m looking to do the same.
Hi @ahenriksen, no unfortunately not. The method suggested just embedded a front end version of the form which on the face of it looked okay but it didn’t actually save any of the data when updating the product. It wasn’t essential but it would have been nice for the end user so it was a bit tidier.
The topic ‘Adding additional data to woocommerce product’ is closed to new replies.
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.