Support

Account

Home Forums Front-end Issues Show ACF field in WC Vendor Pro "Add Product" Reply To: Show ACF field in WC Vendor Pro "Add Product"

  • I have managed to show ACF field on “Add Product” page for WC Vendors.

    This is the code I have got from WC Vendor’s support forum.

    and just bit of modification in the hook, instead of add_action(‘wcvendors_settings_after_shop_name’, ‘wcv_save_acf_fields’); hook I used add_action('wcvendors_after_product_form' to save the form. and to display field original code : add_action(‘wcvendors_settings_after_seller_info’, ‘wcv_add_acf_fields’); and I have replaced it with add_action('wcv_after_product_details' to display it on Add product page. The full code is below:

    /*
     *- Courtesy of Ben Lumley -
     * https://www.wcvendors.com/help/topic/howto-add-acf-fields-to-frontend-shop-edit/
     *
     * https://docs.wcvendors.com/knowledge-base/adding-advanced-custom-fields-acf-support/
     *
     * This will display + save any custom fields applicable to the vendor_shop in question.
     * Second one displays the fields, you can adjust the action it’s attached to in order
     * to move the fields (see templates/dashboard/store-settings.php in the pro plugin for
     *  possible actions). You could also split and display different fields in different
     * places – see the docs for acf_form, you can select single/groups of fields.
     * http://www.advancedcustomfields.com/resources/acf_form/
     * Also possible via acf_form to alter the markup a bit to make it fit your theme.
     *
     * This code is not supported by WC Vendors, use at your own risk and at your own discretion.
    */
    
    add_action('wcvendors_after_product_form', function () {
        acf_form_head();
    });
    
    add_action('wcv_after_product_details', function () {
    
        acf_form(
            [
                'post_id' => 'user_' . get_current_user_id(),
                'form' => false,
                'return' => false
            ]
        );
    
    });

    the field shows now, but the problem is it’s not saving the ACF value. any idea why it is not saving 🙁