1

I am using Drupal 8/Commerce 2. How do I limit the quantity in the cart to one item so that users can't order more than one item per order.

1

2 Answers 2

0

Drupal 8 / Commerce have field "Default quantity to add to cart", so you can add default quantity for product is 1 and hide it from product page. After that user can't change quantity of products. Problem is solved!

1
  • 2
    this does NOT stop the user from adding another product with quantity 1 ... so problem NOT solved ... Commented Jan 17, 2018 at 7:48
0

Views >> Cart form >> Remove field... (order_items: Order Item) Order item: Quantity text field (Quantity)

This was a editable quantity field.

You can now add (order_items: Order Item) Order item: Quantity (Quantity) Which is a display only version of the quantity field.

For your Order item type >> manage display >> purchased entity >> rendered as cart.

The same item can still be added 1 at a time to the cart. To best solve solve this problem it would depend on your situation.

(1) Is your product a 'one off' unique item? then best solved by a stock strategy -or- (2) Is only one item of a certain sku allowed in a cart -or- (3) Must each sku in a cart be unique?

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.