Open 355am opened 3 weeks ago
I don't think we necessarily need to duplicate functionality available in other WP APIs. Categories for example can be looked up via /wp-json/wp/v2/product_cat
. From that you can derive IDs from slugs—perhaps you can utilise this in your use case?
Reference: https://developer.wordpress.org/rest-api/reference/taxonomies/
I agree, duplicating functionality isn’t ideal, but unfortunately, the endpoint mentioned (/wp-json/wp/v2/product_cat
) isn’t publicly queryable like the others under /wp-json/wc/store
, which is causing some issues for my use case. Any suggestions on how to work around this?
edit: also see #42321
@355am I think you're mistaken there. The read only post type APIs are public. https://woocommerce.com/wp-json/wp/v2/product_cat
@mikejolley You are right! Interestingly, I tested the endpoint with several WooCommerce webshops and consistently received 404 "rest_no_route"
responses. Thank you for providing the link as evidence.
While it works, it would be nice to directly query based on the slug instead of having to make two requests. Is there any chance of introducing slug-based querying in the future?
Describe the solution you'd like
The WooCommerce public (= no API key needed) Store API enables us to query products via the
wp-json/wc/store/products
endpoint. It is also possible to filter the results simply by adding the product category ID or product tag ID as a query param for eg. like this:wp-json/wc/store/products?category=1377
.But there is no way to
Since the goal (according to this post) of the WooCommerce Store API is to provide public REST API endpoints for the development of customer-facing cart, checkout, and product functionality, would be nice to include both.
Describe alternatives you've considered
No response
Additional context
No response