How to Redirect to the Checkout Page on Add to Cart for Woocommerce 2024

In this little snippet I’m going to show you a very simple way to redirect your customers to the checkout page on add to cart. There are a few possible scenarios that you might need to use this snippet. For instance, if you are selling avirtual product such as a course, or a downloadable product like an audio file or plugin. There really is no need for buyers to access the cart page, and every time they have to press a button there’s a risk of losing them as a paying customer. So let’s take a look at how simple this really is.

Disable ajax and redirection to cart page

The first step that you need to take is to head to Woocommerce > settings > product and under the general tab make sure both redirect to cart page after successful addition and redirect to cart page are unchecked.

See also  How to add a custom field to WooCommerce product data and display it on the frontend 2024

Once both boxes are unchecked as in the image above, click save at the bottom of the page.

Adding the snippet to redirect to checkout page on add to cart

* snippet Redirect to checkout page on add to cart for WooCommerce
* sourcecode
* author John Cook
* tested Woocommerce 8.8.2
add_filter( 'woocommerce_add_to_cart_redirect', 'wcsuccessacademy_redirect_to_checkout_on_add_cart' );

function wcsuccessacademy_redirect_to_checkout_on_add_cart( $url ) {
  $url = get_permalink( get_option( 'woocommerce_checkout_page_id' ) );
  return $url;

Where do you place the code?

Place the code snippet into your theme functions file, child theme functions file or functions plugin. Make sure it is placed before the closing ?> if you have it in your file. If you are uncertain how to place this, please use one of the plugins found in this list.

See also  How to add a custom WooCommerce checkbox checkout field 2024

Did this plugin work for you?

Please leave a comment letting me know if the code snippet showing how to redirect customers to the checkout page on add to cart has worked for you.

0 0 votes
Article Rating

Stay In Touch

Was this post helpful? Why not show your support and buy me a coffee?

Notify of
Inline Feedbacks
View all comments
Would love your thoughts, please comment.x
Scroll to Top