• You MUST read the Babiato Rules before making your first post otherwise you may get permanent warning points or a permanent Ban.

    Our resources on Babiato Forum are CLEAN and SAFE. So you can use them for development and testing purposes. If your are on Windows and have an antivirus that alerts you about a possible infection: Know it's a false positive because all scripts are double checked by our experts. We advise you to add Babiato to trusted sites/sources or disable your antivirus momentarily while downloading a resource. "Enjoy your presence on Babiato"

Proceed to checkout button redirects

Maus010

Member
May 4, 2019
51
19
8
Hi Guys,

I hope someone can help me with my folowing issue.

I want to change the behaviour of the "proceed to checkout" button for my wordpress/woocommerce website.
When you click that button it will take you directly to the checkout page (duh).
But I want to change that into this:

1. Logged-in users are redirected to page "A" (checkout page)
2. Logged-out users are redirected to page "B" (custom page where they can log in or continue as guest)

Is this possible? And what would that code look like?

Thanks in advance! (y)
 
You can use the following hook

add_filter( 'add_to_cart_redirect', 'jokontol_add_to_cart_redirect' );
function jokontol_add_to_cart_redirect() {
global $woocommerce;
$jokontol_redirect_checkout = $woocommerce->cart->get_checkout_url();
return $jokontol_redirect_checkout;
}

I believe woocommerce has login conditional on the checkout page so you don't have to check the manually.
 
To bad. This piece of code doesn't work for me :cry:

It breaks my site. When I add a product to my cart, the "added to cart" popup doesn't show anymore. Also my cart stays empty until I refresh the page. Only then the item appears in my cart.

Also both logged in and logged out users are being redirected to the same checkout page.
 
AdBlock Detected

We get it, advertisements are annoying!

However in order to keep our huge array of resources free of charge we need to generate income from ads so to use the site you will need to turn off your adblocker.

If you'd like to have an ad free experience you can become a Babiato Lover by donating as little as $5 per month. Click on the Donate menu tab for more info.

I've Disabled AdBlock