May 26, 2015

Woocommerce how to add to cart button direct redirect to checkout page?

Yes its possible using a simple wordpress function.

Please add following function in your theme functions.php file.

add_filter ('add_to_cart_redirect', 'redirect_checkout');

function redirect_checkout() {
    global $woocommerce;
    $checkout_url = $woocommerce->cart->get_checkout_url();
    return $checkout_url;
}

In the latest version of wordperss you also used following shot function.

function redirect_to_checkout() {
    return WC()->cart->get_checkout_url();

}

Enjoy!

No comments:

Post a Comment

Integrating Google reCAPTCHA v3 in HTML Form with PHP

  What is Google reCAPTCHA v3? Google reCAPTCHA is a free service that helps protect websites from spam and abuse. reCAPTCHA v3 is the lates...