Get Even More Visitors To Your Blog, Upgrade To A Business Listing >>

WooCommerce: Only One product in the cart at a time

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.

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;
}

The post WooCommerce: Only One product in the cart at a time appeared first on Wasim Sama.



This post first appeared on Wasim Sama, please read the originial post: here

Share the post

WooCommerce: Only One product in the cart at a time

×

Subscribe to Wasim Sama

Get updates delivered right to your inbox!

Thank you for your subscription

×