Support

Account

Home Forums General Issues acf field hooking up with woocommerce hooks

Solving

acf field hooking up with woocommerce hooks

  • im trying to display acf field in woocommerce product data > genreal tab
    woocommerce product data

    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.

Viewing 3 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic.