One Item Per Order In Cart

Looking to add one item per order in your WooCommerce cart? All you may need is to add a filter to woocommerce_add_to_cart_validation.

One order per order function

To add one product per order, you must add the code below into your functions.php file.

function custom_only_one_in_cart( $passed, $added_product_id ) {
     wc_add_notice( 'New product added to cart.', 'notice' );
     return $passed;
add_filter( 'woocommerce_add_to_cart_validation', 'custom_only_one_in_cart', 99, 2 );

Disable original item added to cart message

To disable the original cart message, add the code below in the same functions.php file.

function custom_remove_add_to_cart_message() {
add_filter( 'wc_add_to_cart_message', 'custom_remove_add_to_cart_message' );