Enforcing Cart Minimum with Functions

I’ve built an extension for a client and they want to enforce a minimum order (varies per client). I’ve got the logic worked out, but I’m running into an issue where lets say the minimum is $1,000. I hit a few bugs.

  1. If I go to add something to an empty cart that is under $1,000 (one item that’s under it), it errors and says a minimum is required.
  2. If they add multiple items so they are over the minimum and try to reduce and it goes below the minimum in the cart, it errors and won’t let them reduce.

Is there a way to get this to enforce only on the checkout page? Otherwise this is very kludgy in that they have to add more than $1,000 then slowly add other items and then can remove the items they added as extras. Makes no sense. Really hoping there’s a way to simply enforce on the checkout page and not adding to cart or in the cart.

Thanks in advance.

I figured it out. I had to add the buyerJourney to the graphql so I could get the buyerJourney.step and compare that to make sure they were in checkout.

Glad you figured this out!