Remove item with $product_id - Woocommerce

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( 'PUT PRODUCT ID IN HERE' );
$cartItemKey = WC()->cart->find_product_in_cart( $cartId );
WC()->cart->remove_cart_item( $cartItemKey );

replace PRODUCT ID with yours.