Skip to content

Instantly share code, notes, and snippets.

@sarangs07
Last active July 22, 2020 08:52
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sarangs07/7185e331223809e299b97407e3694537 to your computer and use it in GitHub Desktop.
Save sarangs07/7185e331223809e299b97407e3694537 to your computer and use it in GitHub Desktop.
Redirect to the checkout page instead of cart page. Works with any theme.
/*
* How to add the custome code.
*
* Please follow below instructions:
* 1. Copy the below code.
* 2. Open your child theme's functions.php file.
* 3. Paste the copied code at the very bottom of it & save the file OR upload it on your server/hosting.
*/
// Trigure the action
add_filter('woocommerce_add_to_cart_redirect', 'redirect_add_to_cart');
function redirect_add_to_cart() {
// Your checkout page URl
$cw_redirect_url_checkout = "add_your_checkout_page_url_here";
// Return your URL.
return $cw_redirect_url_checkout;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment