It’s not unusual that products need to be handled singularly in an order, or that they can’t be sold in more than one unit.
WooCommerce covers the second case so you can limit customers to buy only one unit of a specific item per order. The first case instead is not covered by default, but it’s still possible to handle it with some custom coding.
Let’s see how to do both.
Limit purchases to one product per order
This scenario is not covered by WooCommerce by default, but it can be done with custom code. The goal is to allow customers to buy only one product per order.
Open your functions.php file in wp-content/themes/your-child-theme-name/ and add this code at the end of the file:
This snippet will not allow customers to add more than one item to the cart, showing them an error message and forcing them to empty the cart to order or to complete the current order first.
To choose which product to limit you need to change the product ID on line 3 of this snippet. In the example, the ID is 31. If you need to limit multiple products, change line 3 with this code instead:
if ( ! in_array( $product_id, array( 31, 32, 33 ) ) ) {
Limit purchases to one item per order
This is the second scenario and it covers any case where you don’t want your customers to add more units of the same product to the cart, but still allow them to buy multiple different products to the cart.
As I said before, this is already covered by WooCommerce, and to do it you need to edit a product in Products > All Products and click on the Inventory tab, then select the option Sold Individually, like shown in this screenshot:

After selecting this option, customers will not be able to buy more than one of the item in the same order, but they still can do it in different orders.
Also, if you are you looking for how to limit purchases by
Contribute to Improving This Blog
Did you enjoy this article? Was it helpful? Contribute to help me writing more articles! The funds collected from this blog are reinvested directly into improving my skills or the blog so that I can provide more and better content!
Make a one-time donation
Make a monthly donation
Make a yearly donation
Choose an amount
Or enter a custom amount
Your contribution is appreciated.
Your contribution is appreciated.
Your contribution is appreciated.
DonateDonate monthlyDonate yearlyDo you prefer using cryptocurrency? I’ve got you covered! You can donate at the following wallets:
- BTC: bc1q87nxpdpqw323ccmerrzyeffs72wnxpw93x7pzk / 17Gtc5e8yoh2LZzokoyK8P5DWbToBwztok
- ETH: 0xA5C89Be1df2896C3942DBEf751cCeacC7929388b
Leave a Reply