How to remove woocommerce added cart items and redirect to checkout?

admin

Administrator
Staff member
I have a Woocommerce form to 'Add Funds'. It has an amount input field ($20, $30 ...etc.) and a submit button that redirects to cart page with the input amount as total.

Redirect to checkout is working, but the cart items are not getting removed if a user abandons the cart and tries to order again.

I tried numerous solutions for the redirect to checkout, but only one worked.

<strong>Working solution for redirect to checkout:</strong>

<a href="https://stackoverflow.com/questions/39655722/woocommerce-skip-cart-page-redirecting-to-checkout-page">WooCommerce - Skip cart page redirecting to checkout page</a>

<strong>Solutions not working for redirect to checkout:</strong>

<a href="https://wordpress.stackexchange.com...out-after-adding-to-cart-item-already-in-cart">https://wordpress.stackexchange.com...out-after-adding-to-cart-item-already-in-cart</a>

<a href="https://stackoverflow.com/questions/15592633/woocommerce-add-to-cart-button-redirect-to-checkout">Woocommerce add to cart button redirect to checkout</a>

<blockquote>
N.B. I have added the working and not working solutions for redirect
to checkout because it may provide an insight as to why the empty cart
solutions are not working.
</blockquote>

Incase of emptying cart before adding a new product, none of the solutions are working:

<a href="https://gist.github.com/viniciusrtf/b49403b5f87dcd7699c1" rel="nofollow noreferrer">https://gist.github.com/viniciusrtf/b49403b5f87dcd7699c1</a>

<a href="https://hungred.com/how-to/empty-woocommerce-cart-adding-item/" rel="nofollow noreferrer">https://hungred.com/how-to/empty-woocommerce-cart-adding-item/</a>

<a href="https://wordpress.stackexchange.com...out-after-adding-to-cart-item-already-in-cart">https://wordpress.stackexchange.com...out-after-adding-to-cart-item-already-in-cart</a>

<strong>Using Woocommerce 3.2.6 and WordPress 4.9.2</strong>