How to remove all simple product in the cart Woocommerce

How do i remove all simple product in cart when click on a button:

// add item to cart on visit depending on cart total value
add_action( 'init', 'add_product_to_cart' );

function add_product_to_cart() {
  if ( isset($_POST['mix']) && !empty($_POST['mix']) && isset($_POST['mix_name']) && !empty($_POST['mix_name']) ) {
    global $woocommerce;    

      $addcart = $woocommerce->cart->add_to_cart( $product_ID = 700,  $quantity=1, $variation_id= '', array('attribute_strain' => 'sativa', 'attribute_level' => 'cbd', 'attribute_flavor' => 'flower shop') );   

      foreach ($woocommerce->cart->cart_contents as $cart_item_key => $values) {
            $_product = $values['data'];
          //find all simple product type to remove
          if($_product->product_type == 'simple') {
             unset($woocommerce->cart->cart_contents[$cart_item_key]);
          }
      }

    if($addcart) {
            wp_safe_redirect( WC()->cart->get_checkout_url() );
            exit;
        } else {
            wc_print_notices();
            _e('Can't add');
        }  
  }
}

When I hit the mix button, I want to add a product id = 700 (variation product) to the cart, and remove all other simple products. the part adding product is ok but not remove all other simple products. How do I remove all other ‘simple’ product_type

Related posts