question

greg avatar image
greg asked matt commented

Get number of orders of a merchant

I wonder if it is somehow possible to query the number of existing orders of a merchant? Of course one could query "get all orders of merchant 123" and check for the number of items in the array, but as soon as the hard limit of 1000 is reached it gets a bit tedious working with offset. I am sure some merchants have 100k or even more orders in the cloud. Would be good to get just a number of existing orders back! (same is true for items / payments / cash events etc.)
OrdersREST API
10 |2000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

1 Answer

·
Lee Tickett avatar image
Lee Tickett answered matt commented
Try this (needs to be in a background thread iirc);

Cursor cursor = getApplicationContext()
.getContentResolver()
.query(
OrderContract
.Summaries
.contentUriWithAccount(AccountData.sCloverAccount)
, new String[] { OrderContract.Summaries.ID }
, null , null
, null);
int orderCount = cursor.getCount();
2 comments
10 |2000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

greg avatar image greg commented ·

Thanks, but forgot to mention that I am looking for a way to query this from the REST API.

0 Likes 0 ·
matt avatar image matt greg commented ·

Hi, is there any possibility to do this in the meanwhile?

0 Likes 0 ·

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Welcome to the
Clover Developer Community