WooCommerce: Check the number of different cart items / SKUs in cart WooCommerce: Check the number of different cart items / SKUs in cart wordpress wordpress

WooCommerce: Check the number of different cart items / SKUs in cart


You can use the following, that will get the count of different product(s) sku(s) in cart:

<?php $skus = array();foreach( WC()->cart->get_cart() as $cart_item ) :    $sku = $cart_item['data']->get_sku();    $skus[$sku] = $cart_item['data']->get_id();endforeach; if( count($skus) > 1 ) :     woocommerce_button_proceed_to_checkout();endif; ?>

It should work.