gatsby-source-woocommerce icon indicating copy to clipboard operation
gatsby-source-woocommerce copied to clipboard

Products with custom post type

Open MichLan90 opened this issue 2 years ago • 2 comments

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 :)

MichLan90 avatar Feb 03 '23 09:02 MichLan90

Did you ever figure this out? Having the same issue right now.

HarleySalas avatar Apr 24 '23 19:04 HarleySalas

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.

pasdo501 avatar Apr 25 '23 00:04 pasdo501