WooCommerce 7.2 – be careful with quantity field

photo admin
December 31, 2022
In this article

What's the problem?

I discovered this problem when I was working on the website of a client who sells digital products. This type of product on his site is sold only one at a time (  Product edit page -> Inventory -> Sold Individually ).

'Sold individually' product option

In such a case the product quantity field is hidden and the user only sees the Add to Cart button.

This works before client updates to WoCommerce 7.2. After this he starts to see the quantity field for all products that are sold individually. This quantity field is useless because you can't change any value for it.

Page for individually sold product before WC 7.2

Page for individually sold product after WC 7.2

I investigated this issue a bit and found that it is a problem with the WooCommerce core template for quantity field. Looks like developers just forget to include conditions to check if the product is sold individually or not 😉

So in such cases we just need to wait for an update from the WooCommerce team. If you don't want to wait - I found some quick and a little dirty fix that I describe below.

How to solve?

Solution is very simple - just use following custom css:

.sold-individually .quantity { display: none; }

This code will hide all quantity fields for your individually sold product. Add this CSS inside your theme styles.css file, use the theme custom CSS option field ( if it has it ) or add style via WordPress Customizer.

Updates

31.12.2022

The WooCommerce team already knows about this issue and gives it a high priority tag - https://github.com/woocommerce/woocommerce/issues/36007. But in version 7.2.2 it is still not fixed.