Support Center

How can I allow buying only more than X items of a Product?

On this page

Sometimes you want to restrict sales to a minimum quantity of products per order. You need to check quantity of item per products.

{% assign qty_valid = true %}
{% for product in order.products %}
  {% if product.qty < 5 %}
    {% assign qty_valid = false %}
  {% endif %}
{% endfor %}

Now, the variable returns true or false if all products in the cart have 5 or more items.

You can then use this varriable to perform logic operations, like hiding a button via CSS.

{% unless qty_valid %}
<style type="text/css">
  #button-id{display:none;}
</style>
{% endunless %}

FAQ

What about restricting orders bellow a certain price amount?

You can perform a check on the {{ order.total }} or any of the other variables:
{{ order.subtotal }}

{{ order.shipping }}

{{ order.tax }}

{{ order.discount }}

Start your journey with us!

Free trial for 14 days. No credit card required.