Support

Account

Home Forums Bug Reports ACF not showing in WooCommerce Rest API

Solving

ACF not showing in WooCommerce Rest API

  • Hi community πŸ‘‹

    I have an ACF Field Group for WooCommerce Products that is used to show information on the product page. This ACF Field Group has the Show in REST API enabled.

    However, when I access it through the API, I can’t see anything from ACF.

    https://domain.com/wp-json/wc/v3/products/3644

    Is there anything I’m doing wrong, is there any workaround or something I can do? The information there is very important.

    Really thank you! 😊

  • I am having the same issue β€”Β any ideas?

  • add to functions.php , I managed to achieve fields from ACF in the response

    add_filter('woocommerce_rest_prepare_product_object', 'include_acf_fields_in_api_response', 10, 3);
    
    function include_acf_fields_in_api_response($response, $post, $request) {
        $data = $response->get_data();
    	$acf_fields = get_fields($response->data['id']);
        $data['acf'] = $acf_fields;
        $response->set_data($data);
        return $response;
    }
Viewing 3 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic.