WooCommerce Cart – Group Products By Category
You need to use has_term() conditional function inside the foreach loop like: foreach ( WC()->cart->get_cart() as $cart_item_key => $cart_item ) { if( has_term( array(‘football’), ‘product_cat’, $cart_item[‘product_id’] ) ) { // Do something } }