How to limit to one item and one quantity only per checkout?

You can do this with Custom Data by adding a field to all your products called Max Cart Quantity, then edit your Liquid templates in the right place to set the max=“” field on the Quantity <input HTML tag.

Steps:

  1. Go to Settings → Custom Data → Products
  2. Click Add Definition
  3. Add a new field called Max Cart Quantity
  4. Take note of the Namespace and Key field. This will be important for the Theme editing.
  5. Select Type as Integer. Set Minimum Value to 1 so that you can’t enter an negative quantity.
  6. Click Save

It should look like this once saved:

Note the custom field key of product.metafields.custom.max_cart_quantity.

Now lets edit your theme:

  1. Go to your theme and click on the three dots and click Edit Code.
  2. Find the .liquid files which contains the Quantity Input field. For the Dawn Theme this is in main-product.liquid and main-cart-items.liquid
  3. Look for the HTML which contains the quantity. This may looks something like

Edit it to add a max field with a condition like:

{%- if product.selected_or_first_available_variant.product.metafields.custom.max_cart_quantity != null %}
max="{{ product.selected_or_first_available_variant.product.metafields.custom.max_cart_quantity }}"
{%- endif %}

Note the custom field key of product.metafields.custom.max_cart_quantity that was configured in our Custom Data for Products.

Now you can go edit any of your products and edit the Max Cart Quantity custom field that you made.

1 Like