WooCommerce Checkout Redirect After Adding Product To Cart On Archive
Pre-Requisites
There are no pre-requisites for this code snippet to work. Keep in mind this solution consists of two code snippets, one to display the content and one to style it.
How To Implement This Solution?
Add these two code snippets as separate entries in either your active child theme’s functions.php file or the Code Snippets plugin.
About The Snippet
This quick guide demonstrates how to redirect your customers to the checkout page immediately after they add a product to their cart from the product archive page. This process is particularly useful for stores where only one product can be purchased at a time.
Code Snippet 1 (Paste This Code In functions.php or Code Snippets )
//**
* Snippet Name: Redirect users to the checkout page when they add a product to cart on the single product page
* Snippet Author: Nevercrox Solutions
*/
add_filter( 'woocommerce_add_to_cart_redirect', 'nevercrox_add_to_cart_checkout_redirect' );
function nevercrox_add_to_cart_checkout_redirect() {
return wc_get_checkout_url();
}