Go straight to checkout
Add to cart takes customers straight to the checkout instead of the cart. Suits shops that mostly sell one product at a time.
<?php
// Shop lists use normal links instead of adding in the background, so every
// add-to-cart button can go on to the checkout.
add_filter( 'option_woocommerce_enable_ajax_add_to_cart', static fn() => 'no' );
add_filter( 'option_woocommerce_cart_redirect_after_add', static fn() => 'yes' );
add_filter( 'woocommerce_add_to_cart_redirect', static fn() => wc_get_checkout_url(), 20 );
Good to know
Applies to classic product pages and shop lists. Product blocks with their own add-to-cart button keep adding in the background.
In these packs
- WooCommerce essentials: The small WooCommerce changes shop owners ask for most.