WooCommerce: Only One product in the cart at a time

Last Updated on

If you want to your customers to add only one product in the cart at a time, simply copy and paste the code given below to your themes function.php file. It will remove previously added product from the cart when buyer will add new product to the cart and will add latest product in the cart.

Only One product in the cart at a time

add_filter( 'woocommerce_add_cart_item_data', 'single_item_add_to_cart' );

function single_item_add_to_cart( $cart_single_item ) {

    global $woocommerce;
    $woocommerce->cart->empty_cart();

    return $cart_single_item;
}

code_canyon_728x90

1 Star2 Stars3 Stars4 Stars5 Stars (1 votes, average: 5.00 out of 5)
Loading...

Leave a Reply

Your email address will not be published. Required fields are marked *

More in WooCommerce
Online-Shopping
Woocommerce: Skip the product page and cart page to go straight to checkout

If your are selling an ebook or tickets via woocommerce and you want your buyer to go straight to checkout

Close