Home › Forums › General Issues › acf field hooking up with woocommerce hooks
im trying to display acf field in woocommerce product data > genreal tab
add_action('woocommerce_product_options_general_product_data', 'add_custom_file_upload');
function add_custom_file_upload() {
if( function_exists('acf_add_local_field_group') ):
acf_add_local_field_group(array (
'key' => 'group_12uyy',
'title' => 'My Group 123',
'fields' => array (
array (
'key' => 'field_1',
'label' => 'Sub Title light',
'name' => 'sub_title_light',
'type' => 'file',
'prefix' => '',
'instructions' => '',
'required' => 0,
'conditional_logic' => 0,
'wrapper' => array (
'width' => '',
'class' => '',
'id' => '',
),
'default_value' => '',
'placeholder' => '',
'prepend' => '',
'append' => '',
'maxlength' => '',
'readonly' => 0,
'disabled' => 0,
)
),
'location' => array (
array (
array (
'param' => 'post_type',
'operator' => '==',
'value' => 'product',
),
),
),
'menu_order' => 0,
'position' => 'normal',
'style' => 'default',
'label_placement' => 'top',
'instruction_placement' => 'label',
'hide_on_screen' => '',
));
endif;
}
im trying to hook acf field-> file type with woocommerce_product_options_general_product_data but im unable to display acf field type in woocommerce hook.
acf field is not displayed in product data -> general tab
1) You cannot define a field group only on a single admin page. If you do this the field group will not be usable anywhere but on the admin page. You will not be able to get the values of these fields anywhere other than on this admin because the field are only defined when loading this admin page.
2) You cannot add an ACF field group inside of one of the existing WC product data tabs. I say can’t, but it is possible to do this using acf_form() by inserting it inside of the existing form without form tags as long as you comply with #1.
You must be logged in to reply to this topic.
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.