I have a single page site that has a product listing, cart & checkout all on one page. It's been a challenge to get this setup working but I have it 99% of the way there :/
My issue is if I click on the Update Cart button without any of the Qty fields being changed is redirects me to the actual cart page.
Here is my setup
add_filter('woocommerce_checkout_redirect_empty_cart', '__return_false');
echo do_shortcode('[woocommerce_cart]');
This works great, I can add products to the cart, adjust the qty in the cart and checkout without issue.
However, if I click the "Update Cart" without any changes to any Qty fields it redirects to /cart. This is a huge problem as I need to stay on this page.
Things I've tried...
wp_nonce_field( 'woocommerce-cart', '_wpnonce', false, true );
but that didn't seem to do anythingThe only way to get this solved is by keeping the update button disabled until a quantity has been changed. It requires custom JavaScript (jQuery).
Now for that redirection problem to the cart page, you could try to change the cart URL used in/with wc_get_cart_url()
function to the checkout URL, using the following:
add_filter( 'woocommerce_get_cart_url', function( $url ) {
return wc_get_checkout_url();
} );
or simply:
add_filter( 'woocommerce_get_cart_url', 'wc_get_checkout_url' );
This could improve/solve the redirection behavior issue.