Hi, I am wondering if there is a way to get each customer’s purchase amount over the past year.
Would I need to create a database and store the customer’s purchases? Is there a way to retrieve it with a simple GET request? Thanks
Hi, I am wondering if there is a way to get each customer’s purchase amount over the past year.
Would I need to create a database and store the customer’s purchases? Is there a way to retrieve it with a simple GET request? Thanks
With the Orders API you can SearchOrders with a query for specific customers get their order history. It would look something like this:
{
"location_ids": [
"{{location_id}}"
],
"query": {
"filter": {
"customer_filter": {
"customer_ids": [
"{{customer_id}}"
]
},
"date_time_filter": {
"created_at": {
"end_at": "2022-06-16T19:29:49.582Z",
"start_at": "2021-06-16T19:29:49.582Z"
}
}
},
"sort": {
"sort_order": "DESC"
}
}
}
@Bryan-Square What would the query look like if you wanted to get all of your customers orders?
If you want to get all orders for a customer you’ll need to call SearchOrders and parse the results for all the known customer_ids
for a given customer. I say that cause there may be more than one customer_id
for a customer due to merges. Is your application tracking merges?