function display_notice_based_on_item_quantity() {
foreach ( WC()->cart->get_cart() as $cart_item ) {
if ( $cart_item[‘quantity’] == 1 )
{
$terms = get_the_terms( $cart_item[‘product_id’], ‘product_cat’ );
foreach ( $terms as $term )
{
if ($term->slug == ‘your-category-slug’)
continue 2;
}
if ( is_cart() )
wc_print_notice( sprintf( __(“there is an item with qunatity of 1 in the cart”, “woocommerce”) ), ‘notice’ );
break;
}
}
}
function display_notice_based_on_item_quantity() {
foreach ( WC()->cart->get_cart() as $cart_item ) {
if ( $cart_item['quantity'] == 1 )
{
if ( is_cart() )
wc_print_notice( sprintf( __("there is an item with qunatity of 1 in the cart", "woocommerce") ), 'notice' );
break;
}
}
}
add_action( 'woocommerce_check_cart_items', 'display_notice_based_on_item_quantity' );
