How to get total amount spent by a customer in a particular duration (day, week, month, custom) in Shopify using API?
Specifically, I need to limit customers spent on the store in those duration using Cart and Checkout validation API. Like a customer can only purchase products worth $1000 in a month
You can use the customer query to fetch a customer’s orders, and filter orders by date using the query parameter. Then you’d sum up the totalPriceSet field from the retrieved orders to calculate the total amount spent, and create logic from there.
Hey Liam, I believe the OP is doing this inside a Shopify Function, specifically the Validation API. Although this is available in the Validation API it is only for the Enterprise plan.