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

ListOrdersForCustomerAsync - ListFilter<Customer> parameter #473

Closed
ernestogianoni opened this issue Mar 4, 2020 · 7 comments
Closed

ListOrdersForCustomerAsync - ListFilter<Customer> parameter #473

ernestogianoni opened this issue Mar 4, 2020 · 7 comments
Labels

Comments

@ernestogianoni
Copy link

ernestogianoni commented Mar 4, 2020

Hi,
v5.03 I'm trying to get all orders from a customer and I get 0 records, looking at the code, shouldn't this function receive aListFilter<Order>instead of a ListFilter<Customer>?

public virtual async Task<IEnumerable<Order>> ListOrdersForCustomerAsync(long customerId, ListFilter<Customer> filter = null)
        {
            var req = PrepareRequest($"customers/{customerId}/orders.json");
            
            if (filter != null)
            {
                req.QueryParams.AddRange(filter.ToQueryParameters());
            }
            
            var response = await ExecuteRequestAsync<List<Order>>(req, HttpMethod.Get, rootElement: "orders");
            return response.Result;
        }

Thank you

@nozzlegear
Copy link
Owner

@ernestogianoni It looks like that specific endpoint does not implement Shopify's new pagination stuff (there are a few endpoints that don't). So as far as I can tell, using that endpoint should just list all of the customer's orders in one call. If it returns zero records, I guess I'd just assume that customer has no orders, because even without the filter it would at least return the first 50 orders available.

@nozzlegear
Copy link
Owner

Here's a link to the documentation for that endpoint:

https://shopify.dev/docs/admin-api/rest/reference/customers/customer#orders-2020-01

@ernestogianoni
Copy link
Author

Thank you nozzlegear, thank you for your great job, I checked it manually, and a condition has to be sent, ie when I use ...customers/2887995654213/orders.json in the browser at shopify it returns 0 records, but it works when using customers/2887995654213/orders.json?status=any.
That's why I was suggesting to use the orders filter instead of the customer.

Thank you

@nozzlegear
Copy link
Owner

Ah I see, it must behave like the order service then. It would only show open orders by default I think. That's strange that they don't document that, but I can add a filter that lets you set the status property.

@ernestogianoni
Copy link
Author

Great, thank you

@nozzlegear
Copy link
Owner

Published in 5.0.4, you should now be able to use a CustomerOrderListFilter to set the status. Note that this class does not have a Fields or Limit property because Shopify’s docs don’t indicate that the endpoint supports any of them.

@akashvekariya
Copy link

@nozzlegear You updated 5.0.4 with CustomerOrderListFilter having status but now in 6.13.0 it shows deprecated. What is the solution to it? Did you add anything new?

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