Home › Forums › Bug Reports › ACF not showing in WooCommerce Rest API › Reply To: ACF not showing in WooCommerce Rest API
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;
}
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.