Drupal Commerce: How to disable the quantity text field in Shopping cart?

If you are using Drupal Commerce, you might have observed that on the Shopping Cart, there is an editable Quantity text field displayed in the cart after the user “Add to Cart”.In some scenarios, the quantity is always one. A similar case here is that we were implementing Drupal Commerce for a school and the product is a fee type. So the quantity expected is always one. So we had to disable it.

If you are also looking for ways to disable the quantity text field in the shopping cart, here is how to do it without any code edits.

Steps to disable the quantity field in Drupal Commerce Shopping Cart:
  • Go to Admin>Structure>Views
  • Find views named that starts with “Shopping Cart” which are created by Drupal Commerce like "Shopping cart block", "Shopping cart form", "Shopping cart summary".
  • Click on the edit button corresponding to each of the above "Shopping Cart" related view items.
  • Look at the “Fields” displayed and find “quantity” field
  • Click on the small down arrow corresponding to "Fields" where "Add" is displayed. 
  • Click on "rearrange"
  • Remove the Commerce Line item: Quantity field
  • Click Apply
  • Save the view
 The quantity field is no longer displayed in the shopping cart. This will only remove the "Quantity" field from displaying in the views page.

Before:

Disable the quantity text field in Shopping cart in Drupal Commerce
 After:
Disable the quantity text field in Shopping cart in Drupal Commerce 1

Find the Shopping Cart view and remove Quantity field:

Disable the quantity text field in Shopping cart in Drupal Commerce 2

Remove quantity field from Views > Fields > Rearrange > Remove the quantity field from view.

I hope this tip was helpful. If you found it helpful or there are other ways to do this, please leave me a comment below. 

Comment with Facebook

Comments