gatsby-source-woocommerce
gatsby-source-woocommerce copied to clipboard
Products with custom post type
Hi,
I just wanted to check if custom taxonomies created on post type product
are supported by this plugin?
We have created a custom post type to add product brands as a taxonomy but we do not see it in the query
Thank you in advance for your answer :)
Did you ever figure this out? Having the same issue right now.
Hi there,
It's supported, but needs some set up beforehand. The plugin just uses data returned by the WooCommerce REST API (https://woocommerce.github.io/woocommerce-rest-api-docs), which doesn't support custom taxonomies out of the box.
If you modify the WC API to return them, however, the plugin will be able to make use of them. Have a look at this example from stackoverflow. Once set up like that, the custom taxonomies should show up as accessible like below (including filtering etc):
{
allWcProducts {
nodes {
brands {
name
}
}
}
}
Note though: that particular example wouldn't allow you to query all brands, for example if that's what you're trying to do. Unless you modify the WC API to a degree that adds an endpoint similar to products/categories
etc, I don't think that would work.