wp-graphql-woocommerce icon indicating copy to clipboard operation
wp-graphql-woocommerce copied to clipboard

Multiple Taxonomy Query

Open thatONEjustin opened this issue 4 years ago • 4 comments

Is your feature request related to a problem? Please describe. Currently the wp-graphql-woocommerce plugin only supports finding products by a single taxonomy.

Describe the solution you'd like A clear and concise description of what you want to happen.

Currently you can only search products on a single taxonomy as follows:

query MyQuery {
  products(where: {categoryIn: "womens", taxonomyFilter: {or: {taxonomy: PACOUNTRY, terms:"USA"}}}) {
    edges {
      node {
        name
      }
    }
  }
}

Describe alternatives you've considered Would like to search multiple taxonomies with an array:

query MyQuery {
  products(where: {categoryIn: "womens", taxonomyFilter: {or: [{taxonomy: PACOUNTRY, terms:"USA"}, {taxonomy: PAFRAMECOLOR, terms:"Black"}] }}) {
    edges {
      node {
        name
      }
    }
  }
}

thatONEjustin avatar Dec 11 '20 18:12 thatONEjustin

@thatONEjustin Your query actually is supported, and should 100% work, however there seems to be a bug when using multiple entries in the and or or fields.

kidunot89 avatar Dec 14 '20 22:12 kidunot89

I have also faced this bug. Seems that taxonomyFilter with OR queries with AND operator instead.

vstrelianyi avatar Mar 16 '21 22:03 vstrelianyi

Could you pls inform if this bug is going to be fixed in the nearest future?

vstrelianyi avatar Mar 16 '21 23:03 vstrelianyi

it's kinda related would really help to get some help here:

query Products($first: Int!, $after: String, $categories: [String]) { products( first: $first after: $after where: {status: "PUBLISH", taxonomyFilter: {filters: {taxonomy: PRODUCT_CAT, operator: AND, terms: $categories}}} ) { pageInfo { hasNextPage endCursor } edges { node { databaseId } } } }

why this doesnt work when i add more than one elem in the categories array? this is working: { "categories": ["foo"], "first": 100 } this is not working: { "categories": ["foo","bar"], "first": 100 } how do i get over this?

webc-charles avatar May 10 '24 21:05 webc-charles