Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GetCustomerOrders Returns No Orders #1084

Open
shafaqat-ali-cms365 opened this issue Jul 15, 2024 · 6 comments
Open

GetCustomerOrders Returns No Orders #1084

shafaqat-ali-cms365 opened this issue Jul 15, 2024 · 6 comments
Labels

Comments

@shafaqat-ali-cms365
Copy link

shafaqat-ali-cms365 commented Jul 15, 2024

I am trying to get customer orders, here is my code

var filter = new CustomerSearchListFilter { //Searches for a customer from the United States with a name like 'Jane'. Query = $"email:{emailAddress}" }; var customer = (await customerService.SearchAsync(filter)).Items.FirstOrDefault(); if (customer != null) { var customerOrders =await customerService.ListOrdersForCustomerAsync(customer.Id.Value); }

but it is returning 0 orders.

@Diceble
Copy link

Diceble commented Jul 16, 2024

Have you tried using postman to do a similar api call and see if that does return a value?

@shafaqat-ali-cms365
Copy link
Author

No, I don't have postman setup, otherwise I would have tried.

@nozzlegear
Copy link
Owner

nozzlegear commented Jul 18, 2024

Hey @shafaqat-ali-cms365! I've just tested this myself and it seems to work fine. I've added it to ShopifySharp's integration tests in this commit and they pass without issue.

I think it might be a permission issue. Both the customers and orders are protected by special permissions that may not necessarily return errors. Off the top of my head, you'd need the following:

  • Permission to read orders.
  • Permission to read customers.
  • Approval from Shopify to read customer data, which can be requested in your app's settings in the Partner dashboard.
  • Approval from Shopify to read order data, again requested in your app's settings in the Partner dashboard.
  • If the order is older than 60 days, permission to read all orders – this requires manual approval from Shopify staff, and then you need to request that permission from everyone who installs your app by using the read_all_orders scope.

@shafaqat-ali-cms365
Copy link
Author

image

image

I have checked permissions again and looks every thing ok.
I have also noticed that I can get non archived orders only and as soon as I fulfill them, I can't retrieve them. So it is something related to order status.

@nozzlegear
Copy link
Owner

Your permissions look good, and so does the customer data privacy stuff. The fulfillment/order status thing is an interesting observation though, that sounds like it could be the problem. On the list filter, there's a property named Status I think, try setting the value to "any" and see if that returns some orders?

Note: I marked Status property as obsolete at some point because there was no mention of it in Shopify's documentation. Maybe that has changed now, I'll have to check.

@shafaqat-ali-cms365
Copy link
Author

I have added the status field in the filter and I can confirm that I get orders returned but If I remove the status field, I don't get any order returned for the same customer.
So looks like by default it returns open order only.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants