Min/max order quantities
Important!
It is only necessary to add the code below to your theme if you are using a Version 2 or Version 1 theme. Users of Version 3, Version 4 and Version 5 themes do not need to install any code to use these features.
Installation instructions (for all theme versions)
To set minimum and maximum order quantities for products you will first need to install the app. To do this select INSTALL THIS APP.
from the menu. Find and select the 'Min & Max Order Quantity' app and selectOnce the app is installed, you'll need to add the relevant code to your live theme's files. To add the relevant code you'll need to use the page editor for your live theme. Alternatively, if you don't want to add the code yourself, you can select request installation on the app installation page, and we will install the code for you for a small charge which is shown on the installation page.
The following instructions tell you how to display the minimum/maximum order quantity set for a product on the product page on your website.
To do so you can use the following four Twig variables:
{{ product.minimum_order_quantity }} will output the minimum order quantity set at a per-product level
{{ global.minimum_product_quantity }} will output the minimum order quantity set globally for all products
{{ product.maximum_order_quantity }} will output the maximum order quantity set at a per-product level
{{ global.maximum_product_quantity }} will output the maximum order quantity set globally for all products
This code should be used on the product.twig file (located in /views/product pages/product.twig) on Version 2 or earlier themes, and on the product_form.twig file (located in /views/partials/) on Version 3 or later themes.
You may choose to write some simple text to explain the variable, as in this example:
This product has a minimum order quantity of <strong>{{ product.minimum_order_quantity }}</strong>.
On the basket page
The product.minimum_order_quantity and product.maximum_order_quantity variables are also available on the checkout/basket page through the basket item object, i.e. item.product.minimum_order_quantity and item.product.maximum_order_quantity.
Javascript implementation
The app prevents the customer adding less than the minimum or more than the maximum order quantity at the platform level. This means that it is only once the 'product add to basket form' is submitted and the page reloads that the user will be informed that they have added too few or too many of the product.
A Javascript implementation is also possible which will work at the browser level (i.e. immediately alerting the user rather than waiting for the form to be submitted and the page to be reloaded).
For example, attaching the minimum order quantity to the 'product add to basket' form on the product page, e.g.:
<form ... id="product-form" data-min-quantity="{{ global.minimum_product_quantity > 0 ? global.minimum_product_quantity : product.minimum_order_quantity }}"> ... </form>
This means you can then reference the minimum order quantity in your Javascript files, e.g.
var form = $('#product-form'); form.on('submit', function(event) { var quantity = parseInt(form.data('min-quantity'), 10); if(quantity > 0) { event.preventDefault(); ... } });