Get all product variations in woocommerce cart page

We have a product with 3 flavor variations where you need to choose all 3 flavors. On the cart page need to check how many bottles the user has chosen, if there are other numbers than 1, 3, 6, 9, or 25 ask the user to change the quantity (image below). I also have a code below but it works only with products and not variations, I need to use the same logic but instead check how many variations we have. add_action( 'woocommerce_check_cart_items', 'check_cart_items_conditionally' ); function check_cart_items_conditionally() { $specific_order = array(1, 3, 6, 9, 25); if (!in_array(WC()->cart->get_cart_contents_count(), $specific_order)){ wc_add_notice( sprintf( __('Please order 1, 3, 6, 9 or 25 bottles', 'woocommerce') ), 'error' ); } }

Comment (0)

You’ll be in good company