Restricting WooCommerce Cart to Only Allow One Item
If you’re running a WooCommerce store and want to ensure that customers can only have one item in their cart at a time, you can achieve this by adding a filter to your functions.php file. This will empty the cart whenever a new item is added, allowing only one product to be present in the cart at any given time.
Step 1: Adding the Filter
Open your theme’s functions.php file and add the following code:






