How to set up Minimum Order Amount in the liquid file: cart-template.liquid?

Solved

How to set up Minimum Order Amount in the liquid file: cart-template.liquid?

paulson1
Pathfinder
140 1 10

Hi,

I want to set up a minimum order amount before anyone can place an order.

For example, no one should be able to pay if the order amount is less than £40.

 

Is there any sample code to do this.

I have heard you can add a code in cart-template.liquid .

Is there any sample code available?

Thanks,

 

Accepted Solution (1)

rajweb
Shopify Partner
747 63 138

This is an accepted solution.

Hey @paulson1 ,

To set a minimum order amount in your Shopify store, you can indeed modify the cart-template.liquid file. Here's a sample code snippet that checks the cart's total value and prevents the user from checking out if it’s below £40.

Follow these steps:

1. Online Store > Theme > Edit Code

2. Open cart-template.liquid (this file may also be named cart.liquid  depending on your theme).

3. Add The following code before the checkout button:

 

{% assign min_order_amount = 40 %}
{% if cart.total_price < min_order_amount * 100 %}
  <p style="color: red;">Your current order total is below the minimum required amount of £40. Please add more items to your cart.</p>
  <style>
    .btn--checkout {
      display: none;
    }
  </style>
{% endif %}

 

If I was able to help you, please don't forget to Like and mark it as the Solution!

Best Regard,

Rajat Sharma

Rajat | Shopify Expert Developer
Need a reliable Shopify developer for your next project?
Dash Drop App: https://apps.shopify.com/dash-drop-delivery
Email: rajat.shopify@gmail.com
Portfolio: https://rajatweb.dev

ProductifyGroups App:  Shopify App - Product Variants

View solution in original post

Replies 4 (4)

rajweb
Shopify Partner
747 63 138

This is an accepted solution.

Hey @paulson1 ,

To set a minimum order amount in your Shopify store, you can indeed modify the cart-template.liquid file. Here's a sample code snippet that checks the cart's total value and prevents the user from checking out if it’s below £40.

Follow these steps:

1. Online Store > Theme > Edit Code

2. Open cart-template.liquid (this file may also be named cart.liquid  depending on your theme).

3. Add The following code before the checkout button:

 

{% assign min_order_amount = 40 %}
{% if cart.total_price < min_order_amount * 100 %}
  <p style="color: red;">Your current order total is below the minimum required amount of £40. Please add more items to your cart.</p>
  <style>
    .btn--checkout {
      display: none;
    }
  </style>
{% endif %}

 

If I was able to help you, please don't forget to Like and mark it as the Solution!

Best Regard,

Rajat Sharma

Rajat | Shopify Expert Developer
Need a reliable Shopify developer for your next project?
Dash Drop App: https://apps.shopify.com/dash-drop-delivery
Email: rajat.shopify@gmail.com
Portfolio: https://rajatweb.dev

ProductifyGroups App:  Shopify App - Product Variants
rajweb
Shopify Partner
747 63 138

@paulson1 ,

Thank you for your response! I'm glad to hear the solution worked well for you. If you need any further assistance, please don’t hesitate to reach out.

Rajat | Shopify Expert Developer
Need a reliable Shopify developer for your next project?
Dash Drop App: https://apps.shopify.com/dash-drop-delivery
Email: rajat.shopify@gmail.com
Portfolio: https://rajatweb.dev

ProductifyGroups App:  Shopify App - Product Variants

lynth
Shopify Partner
199 11 33

Hi, you can find snippet (modified example):

 

      <input
        data-name="quantity-selector-pro-input-cart"
        class="quantity-selector__input {% if size == 'sm' %}text-sm{% endif %}"
        type="number"
        is="quantity-input"
        value="{{ line_item.quantity }}"
        {% if add_updates %}
        name="updates[]"
        {% endif %}
        inputmode="numeric"
        step="{{ variant.quantity_rule.increment }}"
        min="{{ pro_prod_min_quant_cart }}"
        {% if max_quantity != blank %}
        max="{{ max_quantity | at_least: line_item.quantity }}"
        {% endif %}
        data-line-key="{{ line_item.key }}"
        aria-label="{{ 'product.quantity.change_quantity' | t | escape }}">

 

where min is the minimum and max is the maximum. I use the product/variant meta field as a reference for the value. Look for the tag quantity-selector. If you still need help, let me know. I also need to know what theme you use

If my tips are useful, just mark it as the solution. Cheers!
Feeling grateful? Buy me a coffee!
paulson1
Pathfinder
140 1 10

Hi,

I could not find the file cart-template.liquid. There is one called main-cart.liquid.

I am using the theme - https://themes.shopify.com/themes/canopy/styles/natural

Hope the file I need to edit is main-cart.liquid

Thanks