Discuss and resolve questions on Liquid, JavaScript, themes, sales channels, and site speed enhancements.
Hello,
I need to set a minim order for some products, I change the minimum quantity from product-template.liquid, now I need to fixed this minimum amount also in cart-template.liquid for obtain a minimum order.
I write those code:
Product-template.liquid:
<label for="Quantity-{{ section.id }}">{{ 'products.product.quantity' | t }}</label>
{% assign productTags = product.tags | join: ', ' %}
<!--Now Check for the desired tag name-->
{% if productTags contains 'min1072' %}
<input type="number" id="Quantity-{{ section.id }}"
name="quantity" value="1072" min="1072" pattern="[0-9]*"
class="product-form__input product-form__input--quantity" data-quantity-input
>
{% else %}
{% if productTags contains 'min1500' % %}
<input type="number" id="Quantity-{{ section.id }}"
name="quantity" value="1500" min="1500" pattern="[0-9]*"
class="product-form__input product-form__input--quantity" data-quantity-input
>
{% else %}
{% if productTags contains 'min5250' % %}
<input type="number" id="Quantity-{{ section.id }}"
name="quantity" value="5250" min="5250" pattern="[0-9]*"
class="product-form__input product-form__input--quantity" data-quantity-input
>
{% else %}
<input type="number" id="Quantity-{{ section.id }}"
name="quantity" value="1" min="1" pattern="[0-9]*"
class="product-form__input product-form__input--quantity" data-quantity-input
>
{% endif %}
{% endif %}
{% endif %}
cart-template.liquid
<label for="updates_{{ item.key }}" class="cart__qty-label" aria-label="{{ 'cart.label.quantity' | t }}" data-quantity-label-mobile>
{{ 'cart.label.qty' | t }}
</label>
{% assign productTags = product.tags | join: ', ' %}
<!--Now Check for the desired tag name-->
{% if productTags contains 'min1072' %}
<input id="updates_large_{{ item.key }}" class="cart__qty-input" type="number"
value="{{ item.quantity }}" min="1072" pattern="[0-9]*"
data-quantity-input data-quantity-item="{{ forloop.index }}" data-quantity-input-desktop data-role="product-quantity-desktop">
>
{% else %}
{% if productTags contains 'min1500' % %}
<input id="updates_large_{{ item.key }}" class="cart__qty-input" type="number"
value="{{ item.quantity }}" min="1500" pattern="[0-9]*"
data-quantity-input data-quantity-item="{{ forloop.index }}" data-quantity-input-desktop data-role="product-quantity-desktop">
>
{% else %}
{% if productTags contains 'min5250' % %}
<input id="updates_large_{{ item.key }}" class="cart__qty-input" type="number"
value="{{ item.quantity }}" min="5250" pattern="[0-9]*"
data-quantity-input data-quantity-item="{{ forloop.index }}" data-quantity-input-desktop data-role="product-quantity-desktop">
>
{% else %}
<input id="updates_large_{{ item.key }}" class="cart__qty-input" type="number"
value="{{ item.quantity }}" min="1" pattern="[0-9]*"
data-quantity-input data-quantity-item="{{ forloop.index }}" data-quantity-input-desktop data-role="product-quantity-desktop">
>
{% endif %}
{% endif %}
{% endif %}
How can I solve?
I'm apologise: if I click on html I can't publish my post
Hi @Rlmps11,
I checked and see the code has been added, what do you want us to solve? Code not working at cart-template.liquid?
Please explain more about it, I will help you check it.
Yes it is possible to set minimum order for some products by using the Cart Lock https://apps.shopify.com/cart-lock app easily. Here is how you can do it:.
Now your customers cannot checkout the specific products if the order amount is less than 50.
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