In WooCommerce 3.6 or later you can use woocommerce_add_to_cart_redirect
(props @roman)
add_filter ('woocommerce_add_to_cart_redirect', function( $url, $adding_to_cart ) {
return wc_get_checkout_url();
}, 10, 2 );
Original answer:
you can use a filter in functions.php:
add_filter ('add_to_cart_redirect', 'redirect_to_checkout');
function redirect_to_checkout() {
global $woocommerce;
$checkout_url = $woocommerce->cart->get_checkout_url();
return $checkout_url;
}
it doesn't seem to work with ajax, but it works from the single product pages, which I think is what you use
On WooCommerce (>= 2.1) the function can be simplified as:
function redirect_to_checkout() {
return WC()->cart->get_checkout_url();
}
You can filter the checkout url via woocommerce_get_checkout_url
function so_37863005_checkout_url( $url ){
// Force SSL if needed
$scheme = ( is_ssl() || 'yes' === get_option( 'woocommerce_force_ssl_checkout' ) ) ? 'https' : 'http';
$url = site_url( '/custom-page/', $scheme );
return $url;
}
add_filter( 'woocommerce_get_checkout_url', 'so_37863005_checkout_url', 10, 2 );
Best Answer
You can solve this by setting the page. Goto http://yourwebsite.com/wp-admin/admin.php?page=woocommerce_settings&tab=pages
And set pages for cart from dropdown menu.