wp-graphql / wp-graphql-woocommerce

Add WooCommerce support and functionality to your WPGraphQL server
https://woographql.com
GNU General Public License v3.0
642 stars 130 forks source link

Retrieving and Ordering a mixture of normal priced and sale priced products #855

Open FourthElementLtd opened 4 months ago

FourthElementLtd commented 4 months ago

Hi team,

Here's a simple query

query MyQuery2 { products(where: {categoryId: 854, orderby: {field: PRICE, order: ASC}}) { nodes { name sku } } }

So this will pull out the first ten products in the category based on the price ascending, all good so far.

However, some of the products in that category are on sale, so if I render this query on the front end, it will obviously ignore the Sale price and render the products in the order of their original RRP/MSRP.

How can I extend this query to include the Sale Price so the Sale Price becomes part of the ordering, but retain the ability to pass the endCursor to manage pagniation for when it comes to our larger categories where we'll have upwards of 100 products in them?

Appreciate any help and advice! Thank you

Darren.