4
Does anyone here know how to make a redirect to Woocommerce’s checkout page when they click to buy a product? (By default Woocommerce adds to cart the product and the person is required to go in cart to checkout)
4
Does anyone here know how to make a redirect to Woocommerce’s checkout page when they click to buy a product? (By default Woocommerce adds to cart the product and the person is required to go in cart to checkout)
6
You can see in the documentation you have option to configure the cart page so that when we are supposed to access the cart, we will be accessing another page.
So two things to let the visitor go to the "Checkout" when you click on "buy":
Go to Woocommerce > Settings
Mark the option to direct the visitor to the cart when used the "buy button":
Go to Woocommerce > Settings > Checkout (Tab):
Where you read "Cart", you choose "Checkout" for the "Cart page" option so that the cart page is effectively "Checkout":
Another method for versions from 2.1 onwards is to create a filter in the file functions.php
:
add_filter ('add_to_cart_redirect', 'redirect_to_checkout');
function redirect_to_checkout() {
return WC()->cart->get_checkout_url();
}
Versions below 2.1 can create a filter in the file functions.php
, but the function is a little different:
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;
}
0
You know how I can make two buttons, a buy that leads to checkout, and another that just add the product in the cart, this all in single product.
0
/**
* Set a custom add to cart URL to redirect to
* @return string
*/
function custom_add_to_cart_redirect() {
return 'http://www.yourdomain.com/your-page/';
}
add_filter( 'woocommerce_add_to_cart_redirect', 'custom_add_to_cart_redirect');
Browser other questions tagged wordpress woocommerce
You are not signed in. Login or sign up in order to post.
thanks very much worked however I left affection , with even Cart
– Flavio