Top

Minimum Cart Value or Product Count before Checkout

Unsupported Theme Modification
This is an unsupported theme customization. If you require assistance in setting this up, contact our team for a quote

Our Customer Pricing app is designed to create price points for different types of customers (wholesale, trade, VIP, and more).

We understand that some stores may require their customers to reach a pre-defined cart value before checking out. This can be done with some modification to the cart.liquid template but this will not work with an Ajax (also know as a "slide","drawer", or "pop-out" cart).

In the cart.liquid, locate the checkout button. This will commonly be an input attribute, and may have the id and/or name as "checkout"

Above the input line, add this line, replacing the ### with the specified spending amount, without decimals: (For example, if the customer needs to spend $150.00, it would be entered as 15000)

{% if cart.total_price >= ### %}

Below the input line, add the lines {% else %} and {% endif %}

Between the {% else %} and {% endif %}, type the message you want to display, add an image or anything you choose to indicate to customer what needs to be done to checkout.

The end result should now look something like this:

{% if cart.total_price >= 15000 %}
<input id="checkout" name="checkout" type="submit" value="Check Out" />
{% else %}
You need to spend $150 to checkout
{% endif %}

This basically shows a checkout button with link to next page if the order is more than $150 or a message if the value is not met.

 

I don't want my regular customers to spend $150, just customers with a specific tag.

That's a quick edit! If you have customers tagged 'wholesale' and require them to spend $150, use this instead:

{% if customer.tags contains 'wholesale' %}
{% if cart.total_price >= 12500 %}
<input id="checkout" name="checkout" type="submit" value="Check Out" />
{% else %}
You need to spend $125 to checkout
{% endif %}

{% else %}

<input id="checkout" name="checkout" type="submit" value="Check Out" />
{% endif %}

 

I want specifically tagged customers to have a minimum product quantity in the cart before checking out.

The following code should be able to do this (replace ### with the number of minimum products that one needs to checkout): 

{% if customer.tags contains 'wholesale' %}
{% assign wholesale_count = cart.item_count %}
{% if wholesale_count >= ### %}
<input id="checkout" name="checkout" type="submit" value="Check Out" />
{% else %}
You need to have ### products in the cart before checking out.
{% endif %}

{% else %}

<input id="checkout" name="checkout" type="submit" value="Check Out" />
{% endif %}

 

I want specifically tagged customers to have a minimum product quantity for all products before checking out:

Add the following to the top of the cart.liquid file:

{% assign disable_checkout = false %}

 

Find the following line in the file:

{% for item in cart.items %}

 

Add the following code underneath that line:

{% if customer.tags contains '!!!!' %}
{% if item.quantity < #### %}
{% assign disable_checkout = true %}
{% endif %}
{% endif %}

 

Replace !!!! with the customer pricing tag that you want to have a minimum quantity.  Replace #### with the minimum quantity per product required for the user to checkout with.

 

Find the code that outputs the checkout buttons on the cart page.  It'll look something like this:

{{ 'cart.general.or' | t }} <input type="submit" class="altaltcolour" style="display: inline-block !important; border: 1px grey solid; padding: 10px 15px !important; margin: 10px 0px" id="update-cart" name="checkout" value="{{ 'cart.general.checkout' | t }}" />
{% if additional_checkout_buttons %}
<div id="additional-checkout-buttons">
<span>{{ 'cart.label.other_payment_types' | t }}</span>
{{ content_for_additional_checkout_buttons }}
</div>

 

Add the following right below that (replace !!!! with the customer pricing tag name that you want to have the minimum product quantity before checking out):

{% if customer.tags contains 'Wholesale' %}
{% if disable_checkout == true %}
<p>!!!! customers must purchase #### of each item</p>
{% else %}

****

{% endif %}
{% endif %}
{% else %}

****

{% endif %}
{% endif %}

 

Replace !!!! with the customer pricing tag name that you want to have the minimum product quantity before checking out.  Replace #### with the required minimum quantity.  Cut the theme's checkout button code and select and paste over the **** with what you cut.  The end result should look something like this:

{% if customer.tags contains 'Wholesale' %}
{% if disable_checkout == true %}
<p>Wholesale customers must purchase 6 of each item</p>
{% else %}

{{ 'cart.general.or' | t }} <input type="submit" class="altaltcolour" style="display: inline-block !important; border: 1px grey solid; padding: 10px 15px !important; margin: 10px 0px" id="update-cart" name="checkout" value="{{ 'cart.general.checkout' | t }}" />
{% if additional_checkout_buttons %}
<div id="additional-checkout-buttons">
<span>{{ 'cart.label.other_payment_types' | t }}</span>
{{ content_for_additional_checkout_buttons }}
</div>

{% endif %}
{% endif %}
{% else %}

{{ 'cart.general.or' | t }} <input type="submit" class="altaltcolour" id="update-cart" name="checkout" value="{{ 'cart.general.checkout' | t }}" />
{% if additional_checkout_buttons %}
<div id="additional-checkout-buttons">
<span>{{ 'cart.label.other_payment_types' | t }}</span>
{{ content_for_additional_checkout_buttons }}
</div>

{% endif %}
{% endif %}

 

 

I want specially tagged customers to have a minimum product quantity amount for only certain products before checking out

In order to specific which products that you don't want to have 

 

Add this to the top of the cart page:

{% assign disable_checkout = false %}
{% assign skip_item = false %}
{% assign display_min_msg = false %}

 

Find this in the cart.liquid file:

{% for item in cart.items %}

 

Add this below that:

<script>

{% if customer.tags contains '####' %}
{% for tag in item.product.tags %}
{% if tag contains '&&&&' %}
{% assign skip_item = true %}
{% endif %}
{% endfor %}
{% unless skip_item == true %}
{% if item.quantity < !!!! %}
{% assign skip_item = true %}
{% assign display_min_msg = true %}
{% assign disable_checkout = true %}
{% endif %}
{% endunless %}
{% endif %}

</script>

 

In the above code, replace #### with the customer pricing tag that you want the minimums for.  Replace !!!! with the minimum quantity needed for these proudcts.  Replace &&&& with the product tag name that you'd like to use to exclude the product from having a minimum.

 

Find the line of code that outputs the title of each product in the cart page.  It should have {{ item.title }} in that line.  When you find it, press enter to add a line break.  Input the following underneath that on its own line (change !!!! to the minimum quantity needed for that product):

{% if display_min_msg == true %}
<p>Minimum of !!!!! quantity for this product is required to checkout</p>
{% endif %}
{% assign skip_item = false %}
{% assign display_min_msg = false %}

 

Find the code that outputs the checkout buttons on the cart page.  It'll look something like this:

 

{{ 'cart.general.or' | t }} <input type="submit" class="altaltcolour" style="display: inline-block !important; border: 1px grey solid; padding: 10px 15px !important; margin: 10px 0px" id="update-cart" name="checkout" value="{{ 'cart.general.checkout' | t }}" />
{% if additional_checkout_buttons %}
<div id="additional-checkout-buttons">
<span>{{ 'cart.label.other_payment_types' | t }}</span>
{{ content_for_additional_checkout_buttons }}
</div>
{% endif %}

 

Add the following above that block of code:

{% if customer.tags contains '####' %}
{% if disable_checkout == true %}
<p>Wholesale customers must purchase 6 of the indicated item(s) before checking out.</p>
<script>alert("Wholesale customers must purchase a minimum of 6 products per item. Doesn't apply to Professional products. Please update your cart.");</script>
{% else %}

****

{% endif %}
{% endif %}
{% else %}

****

{% endif %}
{% endif %}

In the above code, replace #### with the customer pricing tag that you want the minimums for.  Replace !!!! with the minimum quantity needed for these products.  Cut the theme's checkout code, then paste it over both instances of ****.  The end result should look something like this:

{% if customer.tags contains 'Wholesale' %}
{% if disable_checkout == true %}
<p>Wholesale customers must purchase 6 of the indicated item(s) before checking out</p>

{% else %}

{{ 'cart.general.or' | t }} <input type="submit" class="altaltcolour" style="display: inline-block !important; border: 1px grey solid; padding: 10px 15px !important; margin: 10px 0px" id="update-cart" name="checkout" value="{{ 'cart.general.checkout' | t }}" />
{% if additional_checkout_buttons %}
<div id="additional-checkout-buttons">
<span>{{ 'cart.label.other_payment_types' | t }}</span>
{{ content_for_additional_checkout_buttons }}
</div>

{% endif %}
{% endif %}
{% else %}

{{ 'cart.general.or' | t }} <input type="submit" class="altaltcolour" id="update-cart" name="checkout" value="{{ 'cart.general.checkout' | t }}" />
{% if additional_checkout_buttons %}
<div id="additional-checkout-buttons">
<span>{{ 'cart.label.other_payment_types' | t }}</span>
{{ content_for_additional_checkout_buttons }}
</div>

{% endif %}
{% endif %}

 

Go to the products section of the Shopify admin and tag whatever product you want to be excluded from the minimum quantity with the tag that you selected at the beginning of this article. 

 

 

Have more questions? Submit a request