Limit Daily Customer Spend

abOne
New Member
4 0 0

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?

Replies 2 (2)
PaulNewton
Shopify Partner
3491 234 679

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.

 

Backend - 

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.

 

Frontend - 

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.

 

 

Research

There are forum posts that discuss similar topics of daily spend, or daily item quantity limits ,etc to reference how to build the liquid logic or javascript functions.

 

 

Merchants that need to consult on this or explore the frontend customization can contact me at paull.newton+shopifyforums@gmail.com with store url, this topic url, and provide further details.

 

What important thing did you learn this Black Friday?


Answers powered by coffee Buy Paul a ☕ Coffee for more answers or donate to eff.org

Problem Solved? ✔Accept and Like solutions to help future merchants

Confused? Busy? Buy a custom solution paull.newton+shopifyforum@gmail.com
abOne
New Member
4 0 0

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.