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

No order data returned from Customer queries.

Open revnelson opened this issue 2 years ago • 4 comments

Describe the bug When querying as an authenticated customer, orderCount returns 0 and orders returns an empty array. The orders query works as expected, however. You can see in the attached screenshot that I am running the query as authenticated, and the orders are retrieved when using the root orders query.

To Reproduce Steps to reproduce the behavior:

  1. Query customer as an authenticated customer. Include orderCount and orders in the return selection.
  2. Run the query

Expected behavior The customer's orders should be returned.

Screenshots Screenshot 2023-02-08 at 6 31 09 PM

Desktop (please complete the following information):

  • OS: macOS
  • Browser: Chrome, Safari, Thunder Client VSCode extension

Plugin Versions

  • WooGraphQL Version: 0.12.1
  • WPGraphQL Version: 1.13.8
  • WordPress Version: 6.1.1
  • WooCommerce Version: 7.3.0

Additional context I thought this may be because I am an administrator, but upon creating a new customer account, placing orders, and running the same query as in the screenshot (authenticated via Authorization headers as the new customer), I get the same outcome. Obviously I could just query orders, but I would like to store orderCount when a user logs in. The login mutation allows returning the customer>orderCount, but without that working I must send the login mutation, then send an orders query, and store the orders.nodes.length as orderLength. More network requests and client computing is less than ideal.

revnelson avatar Feb 09 '23 01:02 revnelson

@revnelson How are you placing the orders? with checkout in the GraphQL IDE, because those orders will always be tied to the admin who is logged in, see as you can't run checkout in the GraphQL IDE as a guest.

kidunot89 avatar May 21 '23 20:05 kidunot89

The query simply does not work under graphql (im using 0.19), when using an admin account and password auth, i do get responses from the rest api, but empty orders from the graphql query

When it comes to using the query with the customer's session in order to get his own orders, they are also returned as empty.

ZeroPie avatar Jun 04 '24 20:06 ZeroPie