Woocommerce Rest API Cache
-
Hi WP REST Cache Support
I registered Woocommerce endpoint to be cached in my code and made its authorization same as what you said here, and when I checked the endpoint api caches list in the plugin it still didn’t add them so what is the solution? (Sample of code added below)
Register woocommerce endpoint code sample:
add_filter( 'wp_rest_cache/allowed_endpoints', 'wprc_add_acf_posts_endpoint', 10, 1); function wprc_add_acf_posts_endpoint( $allowed_endpoints ) { if ( ! isset( $allowed_endpoints[ 'wc/v3' ] ) || ! in_array( 'shipping/zones/<id>/locations', $allowed_endpoints[ 'wc/v3' ] ) ) { $allowed_endpoints[ 'wc/v3' ][] = 'shipping/zones/<id>/locations'; } return $allowed_endpoints;
Authorization code sample:
add_filter('wp_rest_cache/cacheable_request_headers', 'wprc_add_cacheable_request_headers', 10, 1); function wprc_add_cacheable_request_headers( $cacheable_headers ) { $cacheable_headers['wc/v3/shipping/zones/<id>/locations'] = 'authorization';
And regarding the objects what are the object types that I can use and for custom endpoint can I use the below code for any object type to flush cache when updated or it can only be used for the product_cat object?
Thanks ??
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- The topic ‘Woocommerce Rest API Cache’ is closed to new replies.