Made a function where the customer get a product added to the cart when they reach a specific amount.
Example of when customer reaches level 3 and get the
I think you're using remove_cart_item
incorrectly. If you go through the documentation, you will find that it accepts cart_item_key as parameter (as wisdmLabs mentioned in comment).
You are using it like so:
WC()->cart->remove_cart_item($product_3);
Try this instead:
WC()->cart->remove_cart_item($cart_item_key);
After updating that line, I think you will able to remove product.
Use this for latest versions of WooCommerce:
$cartId = WC()->cart->generate_cart_id( 'PRODUCT ID' );
$cartItemKey = WC()->cart->find_product_in_cart( $cartId );
WC()->cart->remove_cart_item( $cartItemKey );
replace PRODUCT ID with yours.