I am baffled for many hours... I am sure there is a simple solution ...any ideas ? I have tried .eq with lots of fields but nothing works when I try and filter the Orders.
J.D. thank you as always but that did not work. Strangely this does work:
let results = await wixData.query('Stores/Orders')
.eq("paymentStatus", "PAID")
.descending('_dateCreated')
.limit(100)
.find(options);
However I do not know how to get .eq to work with a field which contains JSON object e.g. to look up Orders by customer email which is a field within the buyerInfo JSON object. This does not work. Any ideas please?
let results = await wixData.query('Stores/Orders')
.eq("buyerInfo.email", email)
.descending('_dateCreated')
.limit(100)
.find(options);
I suspect that it is only possible to filter queries on certain fields? But this would mean searching the whole collection of orders (may be thousands) to possibly just inspect 2 orders a customer has placed (identified by their unique email) which means slower searching? At the moment i search all orders and then use an if statement on the result items to find the matching email field but that seems a long way? Filtering in the initial query would be faster better?? Thank you in advance.
Hi, since I don’t usually use the Wix Stores app (I use a third party’s transactions/orders), I wouldn’t like to mislead you with my answer.
On first glance the query looks fine to me. Maybe post a sample of your order item.
And maybe someone else will be able to help.