Skip to content
This repository has been archived by the owner on Apr 20, 2021. It is now read-only.

Woocommerce: filters work on some products but not others #103

Closed
mattdabell opened this issue Jul 30, 2020 · 10 comments
Closed

Woocommerce: filters work on some products but not others #103

mattdabell opened this issue Jul 30, 2020 · 10 comments
Assignees
Labels
todo after v4 release topic: WordPress Related to Gatsby's integration with WordPress

Comments

@mattdabell
Copy link

mattdabell commented Jul 30, 2020

Hi,

I noticed that queries on products are quite hit-and-miss. Sometimes they work, other times no result is returned.

Not working despite the product clearly existing:

Screenshot 2020-07-30 at 14 55 59

Working as expected if I select a different ID:

Screenshot 2020-07-30 at 15 00 23

Working fine in playground:

Screenshot 2020-07-30 at 15 03 43

Thanks!

@mattdabell
Copy link
Author

This could potentially be something to do with the product type. It seems like variable products can be queried but simple products cannot.

@TylerBarnes
Copy link
Collaborator

Interesting, this definitely seems like a bug. Are you able to share a /graphql endpoint that has this issue so I can debug?

Thanks!

@mattdabell
Copy link
Author

Hi @TylerBarnes, can use the same endpoint I've emailed you previously :)

@HumidBrains
Copy link

HumidBrains commented Sep 15, 2020

@TylerBarnes @mattdabell Any progress on this one? I suddenly experience a similar issue despite everything working well before. I think this happened when turning my variable products into simple ones. In fact, filters do not work at all on any of my simple products.

To spice things up, it turns out WP GraphiQL (WordPress) only lists 10 out of the 27 (non filtered) products, whereas GraphiQL (Gatsby/Localhost) lists all 27 of them. However, if I then filter on a product slug (or any other argument), I do get the expected result from WP GraphiQL (WordPress), but an empty array from GraphiQL (Gatsby/Localhost).

Using
WP GraphQL 0.12.3
WPGraphQL WooCommerce (WooGraphQL) 0.5.1
gatsby-source-wordpress-experimental 1.3.8

See screenshots below.

### WP GraphiQL (WordPress)
WPGraphiQL_WordPress_Products
WPGraphiQL_WordPress_Filtered_Product

GraphiQL (Gatsby/Localhost)

GraphiQL_Gatsby_Localhost_AllProduct

GraphiQL_Gatsby_Localhost_Filtered_Product

@mattdabell
Copy link
Author

I don't think there's any progress yet. I agree it definitely seems related to variable products, but something weird is going on for sure. I managed to work around the issue by up-front querying for every single product in gatsby-node then injecting the relevant products into the different taxonomy pages via context, basically using JS to filter instead of page queries & graphql. It works fine for now but I imagine breaks incremental builds & previews etc so hoping to refactor back to the normal way once things have stabilised.

@HumidBrains
Copy link

Thanks for the input @mattdabell. I've made another check now and filtering works for variable products, but not for simple products. I have not tried grouped or external products. If the bug is within WoographQl or gatsby-source-wordpress-experimental is hard for me to say. @TylerBarnes What's your take on this?

@TylerBarnes
Copy link
Collaborator

Thanks for the additional context @HumidBrains . The Woo schema is set up in a way this plugin isn't expecting so some additional logic needs to be added. Since we don't technically support Woo in this plugin just yet, I'm scoping this for after stable release. However, I am going to take a quick peek and see if this is a simple fix. If it is I'll cut a release soon.
Thanks for your patience !

@TylerBarnes
Copy link
Collaborator

TylerBarnes commented Sep 23, 2020

Hey Yall, I just had a look at this using @mattdabell 's API and I couldn't reproduce. I wonder if this was a Gatsby core bug that got fixed. What version of Gatsby are you on? @HumidBrains can you run gatsby info in your Gatsby directory?

@mattdabell I can access that product by id:
Screen Shot 2020-09-23 at 1 55 55 PM

@HumidBrains I'm able to filter by slug no problem as well.
Screen Shot 2020-09-23 at 1 58 50 PM

@TylerBarnes
Copy link
Collaborator

If it's not a Gatsby core bug that's been fixed, the other possibility is that the bug only happens after data is cached and updated via WP. But I haven't seen a bug like that since near the beginning of working on this plugin so it feels unlikely that that's it (not impossible though).

@acao acao added the preview label Nov 10, 2020
@TylerBarnes TylerBarnes added the topic: WordPress Related to Gatsby's integration with WordPress label Feb 5, 2021
@smthomas
Copy link
Contributor

Thank you for opening this issue. We recently moved this plugin over to the gatsbyjs monorepo and are trying to clean out this issue queue. This seems to be working after recent updates to the plugin. If you are still experiencing this issue, please provide a reproduction and open in the gatsbyjs repo.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
todo after v4 release topic: WordPress Related to Gatsby's integration with WordPress
Projects
None yet
Development

No branches or pull requests

5 participants