Remove upsell product with main product From Cart in woocommerce
add_action( 'woocommerce_cart_item_removed', function( $removed_cart_item_key, $cart){ //wp_mail( 'navototest@gmail.com', 'test', $removed_cart_item_key ); $cart = WC()->instance()->cart; $line_item = $cart->removed_cart_contents[ $removed_cart_item_key ]; $product_id = $line_item[ 'product_id' ]; wp_mail( 'navototest@gmail.com', 'test'.$product_id, $product_id ); //$counter = WC()->cart->get_cart_contents_count(); // for($i = 1; $i <= $counter; $i++){ // $cart_item_breakfast_id = $cart->find_product_in_cart($product_id); // wp_mail( 'navototest@gmail.com', 'upsell'.$cart_item_breakfast_id, $cart_item_breakfast_id ); // if($cart_item_breakfast_id){ // $cart->set_quantity($cart_item_breakfast_id, 0); ...