Home » WooCommerce: Redirect to Checkout on Add to Cart

WooCommerce: Redirect to Checkout on Add to Cart

by Tutor Aspire

Here’s how you force redirection to the checkout page every time a product is added to cart, no matter if you do so from the loop/shop pages or the single product page.

On top of adding the code to your functions.php you also need to double check your WooCommerce settings, see screenshot below. Enjoy!

Force Redirection to WooCommerce Checkout on Add to Cart

1. WooCommerce Settings

Go to WooCommerce > Settings > Products > General and disable both options: “Redirect to the cart page after successful addition” & “Enable AJAX add to cart buttons on archives“:

WooCommerce Settings to Allow for Checkout Redirect

2. PHP Snippet: Redirect to Checkout on Add to Cart – WooCommerce

/**
 * @snippet       Redirect to Checkout Upon Add to Cart - WooCommerce
 * @how-to        Get tutoraspire.com FREE
 * @author        Tutor Aspire
 * @compatible    Woo 3.8
 * @donate $9     https://www.tutoraspire.com
 */
 
add_filter( 'woocommerce_add_to_cart_redirect', 'tutoraspire_redirect_checkout_add_cart' );

function tutoraspire_redirect_checkout_add_cart() {
   return wc_get_checkout_url();
}

You may also like