Product Page

WooCommerce Redirect To Checkout After Adding Product To Cart On Product Page

WooCommerce store redirecting to the checkout page when the add to cart button is clicked

Pre-Requisites

For this functionality on the single product page only, you’ll need to disable “Redirect to the basket page after successful addition” under WooCommerce > Settings > Products . General > Add to cart behaviour.

How To Implement This Solution?

Simply copy the pre-coded solution to your active theme’s functions.php or preferably the Code Snippets Plugin. To change the button text to something more appropriate like “Buy Now” or “Go To Checkout”, check out our guide on changing the add to cart button text.

About This Solution

If your store deals with products where typically only one in the entire range is bought, you may wish to redirect users straight to the checkout page when they add a product to cart, effectively skipping out the cart stage entirely. By skipping stages in the sales funnel, you increase the likelihood of a sale because less effort is involved in moving through the buying process. This quick guide shows you how, on the single product page, you can redirect users straight to the checkout when they’ve added their product to cart. For a better User Experience (UX), you should probably change the text of the add to cart button too to let users know they will not being looking at a cart and instead, going straight to the WooCommerce checkout.

/**
* Snippet Name:   Redirect users to the checkout page when they add a product to cart on the single product page
* Snippet Author: ecommercehints.com
*/

add_filter( 'woocommerce_add_to_cart_redirect', 'ecommercehints_add_to_cart_checkout_redirect' );

function ecommercehints_add_to_cart_checkout_redirect() {
   return wc_get_checkout_url();
}

Snippet Benefits

  • Skip the cart completely and send users straight to the checkout when a product is added to cart.
  • Reduce the steps in the buying process, e.g. the cart page, increasing the likelihood of conversions.

100 WooCommerce Conversion Rate Optimisation Tips

This field is for validation purposes and should be left unchanged.

Let’s collaborate!

Need to outsource WordPress development?

Join forces with UnlimitedWP for an outsourced white label web development service you can truly rely on.

First Timer Here?

Sign up to receive 10% off on your first month with us.

26027
WELCOME OFFER