Check out the Youtube channel

Wholesale Minimum Quantity or Box Quantity in Shopify - No App

Written by Eduard Fastovski

Feb 16, 2022

If you have a wholesale store then you might want to sell in bulk quantities, and not allow people to buy just 1 item.

I’m going to be showing you two things:

  1. How to set a minimum order quantity, so customers can buy any amount higher than that quantity. So if the minimum is 6 they can buy 7 or 8 etc..
  2. How to set a “box quantity” so people can only buy multiples of that number i.e. you sell a box of 6, so people should only buy multiples of 6 - like 6,12,18,24 etc…

Let’s get started.

Define the metafield

We’re going to be using metafields so that you can set the MOQ or box quantity per-product.

Go to Settings > Metafields and define the metafield. Call it something like minimum quantity or box quantity, whichever makes more sense for your needs.

Now get a product your’e going to be testing on and fill out the metafield.

Editing your quantity field.

On Dawn (also Sense, Craft, Crave) theme it’s going to be inside a file called ‘main-product.liquid’

First we want to get the value from the metafield:

{% assign min_quantity = product.metafields.wholesale.min_quantity %}

We are going to be replacing the fields initial value with {{ min_quantity }} so make sure you set a fallback in case the product does not have this value filled.

{% if min_quantity == blank %}
  {% assign min_quantity = 1 %}
{% endif %}

Now you can edit your quantity field code

  • modify the min attribute
  • modify the value attribute

min="{{ min_quantity }}"

value="{{ min_quantity }}"

You also might want to prevent people from manually editing this, although this is a weird thing for them to do. But I think its fine to disable it and force people to click the + and - buttons, unless they need to add like 1000. In that case I wouldnt do it.

onkeydown="return false"

And if you’re doing box quantity, you will want to add a ‘step’ attribute:

step="{{ box_quantity }}"

Altogether, my code looks like this:

{% assign box_quantity = product.metafields.wholesale.box_quantity %}
{% if box_quantity == blank %}
  {% assign box_quantity = 1 %}
{% endif %}

<input class="quantity__input" 
  id="Quantity-{{ }}" 
  min="{{ box_quantity }}" 
  value="{{ box_quantity }}" 
  step="{{ box_quantity }}" 
  onkeydown="return false" 
  form="{{ product_form_id }}" 

Edit on the cart page

There is a quantity selector on the cart page and we want that to work the same way and not break our rules.

There are only a couple differences:

  • We need to put the word ‘item’ in front when we access the metafields. Since this is the cart template - we access the cart item, and inside of that is the product. So {{ item.product.metafields.wholesale.box_quantity }}
  • The value attribute should remain as {{ item.quantity }} - this is the amount that was added to cart.

Altogether my code on the cart page looks like this:

{% assign box_quantity = item.product.metafields.wholesale.box_quantity %}
{% if box_quantity == blank %}
  {% assign box_quantity = 1 %}
{% endif %}

<input class="quantity__input"
  value="{{ item.quantity }}"
  min="{{ box_quantity }}"
  step="{{ box_quantity }}"
  onkeydown="return false"
  aria-label="{{ 'products.product.quantity.input_label' | t: product: item.product.title | escape }}"
  id="Quantity-{{ item.index | plus: 1 }}"
  data-index="{{ item.index | plus: 1 }}"

Bulk Edit the metafields

Ok so now all you need to do is enter the MOQ or box quantity for all your products.

This will be really slow one by one, so you need to use the bulk editor.

There is a trick to opening metafields in the bulk editor, and I explain it in this video:

Want posts like this in your inbox? Subscribe to the newsletter.