Skip to content

Instantly share code, notes, and snippets.

@toptools
Created September 19, 2020 08:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save toptools/4830e947fe7041b31dbd8fd3d72492c2 to your computer and use it in GitHub Desktop.
Save toptools/4830e947fe7041b31dbd8fd3d72492c2 to your computer and use it in GitHub Desktop.
<?php
/**
* Redirect users after add to cart.
*/
function my_custom_add_to_cart_redirect( $url ) {
$url = WC()->cart->get_checkout_url();
// $url = wc_get_checkout_url(); // since WC 2.5.0
return $url;
}
add_filter( 'woocommerce_add_to_cart_redirect', 'my_custom_add_to_cart_redirect' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment