How to add an Amount Order limit based on user's country

We are developing a food online store for a client. Some countries have maximun order amount limits for this kind of products (to import them). We need to limit the total order amount based on user’s country. Is there a way to achieve that?

1 Like

Hi @juanma-pernot

I see exactly what you’re trying to do here. Since your client’s food store ships internationally, and some countries have specific import restrictions on total order value, you need a way to limit orders based on the customer’s shipping country. Shopify doesn’t have a built-in feature for this, but there are a couple of practical workarounds you can use.

Solution 1: Use Shopify Scripts (For Shopify Plus)

If your client is on Shopify Plus, you can use Shopify Scripts to apply an order total limit based on the shipping country before checkout.

Here’s an example script (in Ruby) that prevents checkout if the order total exceeds a specific amount for certain countries:

Shopify Script to Restrict Order Total Based on Country

allowed_countries = {

“US” => 200, # USD

“CA” => 150,

“UK” => 180,

“AU” => 220

}

country_code = Input.cart.shipping_address.country_code

order_total = Input.cart.subtotal_price / 100 # Convert to currency

if allowed_countries.key?(country_code) && order_total > allowed_countries[country_code]

message = “The maximum order total for #{country_code} is $#{allowed_countries[country_code]}. Please adjust your cart.”

Input.cart.discount_code.reject(message)

end

Output.cart = Input.cart

This script blocks checkout if the order total exceeds the set limit for specific countries.

Solution 2: Use a Shopify App (For Non-Shopify Plus Stores)

If you’re not on Shopify Plus, you’ll need an app that can restrict checkout based on conditions. Some apps that can help:

  • Advanced Shipping Rules – Allows setting country-based conditions.
  • Locksmith – Lets you control product visibility and cart restrictions based on user location.
  • Dynamic Checkout Restrictions – Can prevent customers from checking out based on order total.

Solution 3: Use Shopify Functions & Checkout Extensibility (New)

If your client is using Shopify’s new Checkout Extensibility, you can use Shopify Functions to create custom validation logic in the checkout process. This is a more advanced method requiring custom development.

Solution 4: JavaScript Restriction on Cart Page

If you don’t have access to Shopify Plus or apps, you can use JavaScript in your cart.liquid file to prevent checkout when the order total is too high for specific countries. Here’s an example:

document.addEventListener(“DOMContentLoaded”, function () {

const countryLimits = {

“US”: 200,

“CA”: 150,

“UK”: 180,

“AU”: 220

};

let checkoutButton = document.querySelector(“button[name=‘checkout’]”);

let countrySelect = document.querySelector(“select#checkout_shipping_address_country”);

let cartTotal = parseFloat(document.querySelector(“.cart-subtotal__price”).innerText.replace(“$”, “”));

function validateOrderLimit() {

let selectedCountry = countrySelect.value;

if (countryLimits[selectedCountry] && cartTotal > countryLimits[selectedCountry]) {

alert(The maximum order limit for ${selectedCountry} is $${countryLimits[selectedCountry]}. Please adjust your cart.);

checkoutButton.disabled = true;

} else {

checkoutButton.disabled = false;

}

}

countrySelect.addEventListener(“change”, validateOrderLimit);

});

This script will disable the checkout button and show an alert if the order exceeds the limit for the selected country.

Final Thoughts

The best solution depends on your client’s Shopify plan. If they’re on Shopify Plus, Shopify Scripts is the cleanest way. If not, using an app or JavaScript-based validation in the cart page is a solid alternative.

Let me know if you need any tweaks or more details on implementation.
If you need any other assistance, feel free to ask, and I will try my best to support you.

Best regards,
Daisy.