You are currently viewing WooCommerce: Allow 1 Product in the Cart or checkout page

WooCommerce: Allow 1 Product in the Cart or checkout page

For some digital product websites, we need to put 1 time the digital products in the cart or checkout. In this case, we can use the code below for implementing this funcitionality.

				
					add_filter( 'woocommerce_add_cart_item_data', 'woo_custom_add_to_cart' );
function woo_custom_add_to_cart( $cart_item_data ) {
    global $woocommerce;
    $woocommerce->cart->empty_cart();
    // Do nothing with the data and return
    return $cart_item_data;
}

				
			

for better understanding, we can follow the links below:

we can also use some plugins for doing similar functionality:

Leave a Reply