Search code examples
inputshopifyminimumproduct-quantity

Shopify: Set minimum quantity for a product using the Quantity Selector


Trying to see if there's a way on certain products in my clients Shopify store where for wholesale customers, they must order at least a quantity of 15 per item.

I'm trying a script to get the Quantity Selector to start at 15 instead of one but it's not working. Here's my code:

<quantity-input class="quantity">
    <button class="quantity__button no-js-hidden" name="minus" type="button">
        <span class="visually-hidden">{{ 'products.product.quantity.decrease' | t: product: product.title | escape }}</span>
            {% render 'icon-minus' %}
        </button>
            {% assign productTags = product.tags | join: ', ' %}
            {% if productTags contains 'wholesale' %}
            <input class="quantity__input"
                type="number"
                name="quantity"
                id="Quantity-{{ section.id }}"
                min="15"
                value="1"
                form="{{ product_form_id }}"
              >
              {% else %}
            <input class="quantity__input"
                type="number"
                name="quantity"
                id="Quantity-{{ section.id }}"
                min="1"
                value="1"
                form="{{ product_form_id }}"
              >
              {% endif %}
            <button class="quantity__button no-js-hidden" name="plus" type="button">
              <span class="visually-hidden">{{ 'products.product.quantity.increase' | t: product: product.title | escape }}</span>
              {% render 'icon-plus' %}
          </button>
      </quantity-input>

Solution

  • Assuming all your other conditions are working regarding the wholesale Tag logic, you also need to set the Value to Min Value (in this case 15) instead of 1. So your input field code for Wholesale products would become

    <input class="quantity__input" type="number" name="quantity" id="Quantity-{{ section.id }}" min="15" value="15" form="{{ product_form_id }}">