Some stores sell products that can only be purchased once (for example, on iTunes, you can only buy a song for yourself once, or on Steam, you can only buy a game for yourself once).

So for products like this, how can I limit the quantity to 1 in Commerce? (Users should never be able to order 2+ of any individual product of type myproducttype.)

There are some answers for doing this in Drupal 7:

Unfortunately, these solutions use Rules, which is still in alpha for D8.

So how can I programatically restrict the product quantity to 1 for a given product type?

2 Answers 2


For me, simply skipping to checkout does not address my desired workflow. I still want users to be able to shop around and use a cart.

But some of my products are subscriptions, for which it doesn't make any sense to have multiple. For this purpose, I'm using https://www.drupal.org/project/commerce_xquantity module.


As pointed out in this question, there is an issue on Drupal.org for a "skip cart" feature that will create something similar to a "Buy it now" button, which means that the user will automatically be transferred to the checkout page as soon as the product is clicked.

This is effectively limiting the quantity to one.

Thanks to @Berdir for writing the code for this.

How to use the patch

  1. Apply the patch.
  2. Go to the Product Types -> Edit Display page for your product type that you want to skip the cart for (/admin/commerce/config/product-types/my-product-type/edit/display).
  3. Look for the Product Variations field, the format of which should be Add to cart form. Click the little gear icon on the right.
  4. Check the box for Skip cart and press Update.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.