Remove cart functionality from WooCommerce so it doesn’t remember the products [closed]

Not sure if this is the right way to do it but I finally found an answer here: https://stackoverflow.com/a/49382476/2308992

and did the following:

add_action( 'woocommerce_add_to_cart_validation', function( $passed, $product_id, $quantity ) {
    if( ! WC()->cart->is_empty() ) {
        wc_empty_cart();
    }
    return $passed;
}, 20, 3);

What this does basically before WooCommerce tries to add anything in the cart, it simply clears the cart so the cart basically doesn’t remember anything. Implementing this has resolved the issue I was facing as mentioned above.

But again if you know a better way of doing this, please share it. I would love to know.