Skip to content

Featured product "tax_query" argument overwritten #370

@lstellway

Description

@lstellway

Describe the bug
When querying "featured" products in a category product connection, the tax_query argument is overwritten.

To Reproduce
Steps to reproduce the behavior:

  1. Setup WooCommerce store with products and WPGraphQL extensions
  2. Mark a single item as featured
  3. Query the category products, with a featured filter
query GetProducts {
  productCategory(idType:SLUG, id:"uncategorized") {
    products(where: {
      featured:true
    }) {
      nodes {
        name
      }
    }
  }
}

Expected behavior
Only the featured item should appear.

Desktop (please complete the following information):

  • OS: OSX
  • Browser: Postman

Additional context
The issue occurs somewhere between class-products.php::$resolve_product_from_taxonomy() and class-product-connection-resolver.php::set_query_arg().

I'm curious if the logic in class-product-connection-resolver.php::set_query_arg() is correct.
Should the $overwrite variable in the if statement have a ! (bang) in front of it?
I would think so, so the tax_query is appended to instead of overwritten.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions