Top

Require Customer with a Specific Tag to Have a Minimum Cart Quantity for Certain Products before Checkout

Warning!

This is an unsupported theme customization. You can request this customization by emailing our Professional Services Team.

Customer Specific Pricing is designed to create price points for different types of customers (wholesale, trade, VIP and more). Customization can be done for stores that require their customers, with a specific tag, to reach a predefined cart quantity for specific products before checking out.

Note: This will not work with an Ajax theme (also known as a "slide","drawer", or "pop-out" cart).

  1. From "Shopify Admin", select Online Store.

    select online store 

  2. Select Actions.

    select actions

  3. Select Edit HTML / CSS.

    select edit html / css 

  4. Under "Templates", select cart.liquid.

    Note: If your theme contains sections, this may be found under "sections" in cart-template.liquid instead.

     select cart.liquid

  5. Add this code to the top of the file:
    {% assign disable_checkout = false %}
    {% assign skip_item = false %}
    {% assign display_min_msg = false %}

    add this code to the top 

  6. Find this line: {% for item in cart.items %}

    find this  line 

  7. Copy and paste this code immediately below that line:
    <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>

    Note: Replace #### with the customer pricing tag that you want to have a minimum quantity. Replace !!!! with the minimum quantity needed for these products. Replace &&&& with the product tag name to exclude from the minimum.

    add this code 

  8. Find the line of code containing: {{ item.title }}

    find item.title 

  9. Copy and paste this code immediately below that line:
    {% 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 %}

    Note: Replace !!!! with the minimum quantity needed for these products.

    paste this code below 

  10. Find the Checkout button, the code will be similar to 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>

    find the checkout button 

  11. Copy and paste this code immediately below it:
    {% if customer.tags contains '!!!!' %} 
    {% if disable_checkout == true %}
    <p>!!!! customers must purchase #### 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 %}

    Note: Replace !!!! with the customer pricing tag. Replace ### with the minimum cart quantity required to checkout. Cut the theme's checkout button code from step 10 and paste over the ****.

    The final code should look like this:

    {% if customer.tags contains 'Wholesale' %} 
    {% if disable_checkout == true %}
    <p>Wholesale customers must purchase 6 of the indicated item(s).</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" 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 %}

    final result 

  12. Select Save.

    save 

That's it!

Have more questions? Submit a request