We have a requirement to prevent any single customer from spending more than $10,000 in a single day.
Is there an easy way to do this, or would I need to fetch all of a single customer's orders for today and sum up the order totals to get the daily spend number?
Shopify wants you to sell as much as you have so isn't built with this type of limit in mind can you elaborate on the use case?
You really need an app to support this you can hobble it together on the frontend but it has problems.
And recognize that unless you collect legal identification it's an expensive thing to combat people using different emails, names, address, methods of payments , etc so avoid that unless legally required.. just get a process to verify ID's there a plenty of apps for that ; and in combination with scary messages and strong wording in TOS would probably go a long way for most needing to combat that situation.
If your on Shopify Plus talk to your MSM to see if this is possible with Flow, I don't think it can handle it but worth checking.
If you have a regulatory requirement you will need an app to auto reject this on the backend to avoid people checking out programmatically using ajax.
https://apps.shopify.com/mechanic can be scripted to handle this business rule.
If your able to just do this through frontend validation you can customize your theme to disable the add-to-cart or checkout buttons.
And if on Plus modify checkout to also disable progress as another defensive step.
💣 Do note this may not prevent checkouts by clever users due to the existence of the ajax api so if this is a critical legal issue you MUST use or build and app for automatic backend validation. And in mind there liquid issues like if you try to check orders against the current date the way liquid caches pages can result in stale data being evaluated getting false positives or true negatives.
For signed in customers basically either use https://shopify.dev/api/liquid/objects/customer#customer-total_spent or loop over all of a customers orders getting the totals you care about and build the sum.
And evaluating this against the cart contents for a grand spend to then prevent rendering the AtC and checkout buttons in liquid.
For the cache date issue the alternative is to make an alternative template to grab the orders and parse the order dates then enable the relevant buttons.
Merchants that need to consult on this or explore the frontend customization can contact me at email@example.com with store url, this topic url, and provide further details.
Paul, sorry for the delay here. I appreciate your thoughtful response. I think I'm going to ultimately write an app, but I do appreciate your input. It definitely helps to understand if my understanding of the required approach is on the right track, and I think it is.
Have you created a collection on your online store and experienced an issue with adding yo...By Ollie Aug 24, 2022