App reviews, troubleshooting, and recommendations
Hi! I'm hoping someone can help me figure out how to add code to my site that would require customers to reach a certain $ amount before they are able to check out. I'm moving the wholesale section of my business to a seperate website and was hoping to be able to add a minimum order value without having so many different apps... currently my minimum is 250! I'm using the Dawn theme! Thank you for any help!!:)
Hi Eadesigns,
There are at least 2 ways to do this.
Option 1 (preferred): Use the Cart and Checkout Validation Function API
The Cart and Checkout Validation Function API is a new Shopify API that allows developers to add custom rules, and prevent customers from checking out if they don't meet certain conditions. The conditions can be based on the contents/subtotal of the cart, or even the customer's location.
The main benefit of using this API is that it's compatible with multiple Shopify features, like the checkout, cart, and Storefront API. This is your best bet for new code.
However, there are some drawbacks:
Option 2: Use the Shopify AJAX API + JavaScript in your theme code
This method will only work with your online store.
You can use the AJAX API to get the contents of a customer's cart (get /{locale}/cart.js). After fetching the response, you can evaluate a condition in your code, and if it's true, you can then add some HTML to the cart to reflect on the error. You can also set the "Check out" button as disabled to prevent them from proceeding to the next step.
The tricky part will be listening for cart updates and reacting automatically, as I don't think the AJAX API has any way to listen for a stream of cart update events. You can use the JS MutationObserver API, but exactly what to put it in it will depend on your specific theme.
This option also won't work if your customer has disabled JavaScript in their browser. And you also can't use this method to edit the checkout page.
Let me know if you have any other questions or concerns.
- Tobe Osakwe
Yes, you can set a minimum order value using the PayRules: Hide Payment Methods app. Here's how you can do it:
This setup will ensure that customers need to have a cart total of at least $250 before being able to see and use the specified payment methods. This way, you can enforce a minimum order value without needing multiple apps.
Starting a B2B store is a big undertaking that requires careful planning and execution. W...
By JasonH Sep 23, 2024By investing 30 minutes of your time, you can unlock the potential for increased sales,...
By Jacqui Sep 11, 2024We appreciate the diverse ways you participate in and engage with the Shopify Communi...
By JasonH Sep 9, 2024