If you operate an eCommerce business, you’ve probably tried a variety of methods to get clients to complete the order transaction. Due to the lengthy checkout procedure, a considerable proportion of such clients bail out or do not finish the transaction.
In such a circumstance, you lose a portion of people who could have been prospective clients if your checkout page had been designed for higher customer satisfaction.
While most stores will be fine with the default WooCommerce product page, some may want to redirect the “Add to Cart” button to the checkout page.
This might be handy if you want to convince them to purchase a product or if you want to upsell them on further things.
Following are the two ways to achieve this
1. WooCommerce default settings
1) WooCommerce default settings
2) Code snippet
a) Redirect the Cart page after successful addition
Go to WooCommerce > Settings > Products settings. Under the General section, you need to configure Add to cart behavior settings.
Tick the first checkbox to redirect to the cart page after the successful addition of product(s) as shown in the screenshot below.
Save the settings.
b) Redirecting the Cart page link to the Checkout page
Go to WooCommerce > Settings > Advanced settings. Click on the Advanced tab and move to the Page Setup section. Next, for the Cart Page setting, select the Checkout page option from the drop-down list, as shown in the below screenshot.
Save the settings.
This will now make the Add-to-Cart button to redirect to the Checkout page, instead of the Cart page. A simple demonstration is shown below.
2. Code snippet
Use this code. This code has been tested by our developers.
<?php
add_filter( 'woocommerce_add_to_cart_redirect', 'cxc_add_to_cart_redirect_checkout' );
function cxc_add_to_cart_redirect_checkout( $url ) {
global $woocommerce;
$url = function_exists( 'wc_get_cart_url' ) ? wc_get_checkout_url() : $woocommerce->cart->get_checkout_url();
// 3.2 From the WooCommerce and WordPress function
//$checkout_page_id = wc_get_page_id( 'checkout' );
//$checkout_page_url = $checkout_page_id ? get_permalink( $checkout_page_id ) : '';
return $url;
}
?>
If the code does not work for you or you have any questions, please leave them in the comments section below.
Thank you for this pretty code!!!
Wow, wonderful weblog layout! How long have you been blogging for?
you made blogging look easy. The entire glance of your website is
magnificent, as neatly as the content!
Раньше я всегда читал пост в новостных
газетах, но теперь, поскольку
я являюсь пользователем сети поэтому, теперья использую сеть для статей или обзоров,
благодаря web.
I am extremely impressed with your writing skills and also with the structure on your blog.
Is that this a paid topic or did you customize it your self?
Anyway stay up the nice high quality writing,
it’s uncommon to see a great blog like this one these days..
Hello, I check your blog daily. Your humoristic
style is witty, keep doing what you’re doing!
I do not even know how I ended up here, but I thought this post was good.
I do not know who you are but certainly you’re going to a famous blogger if you
aren’t already 😉 Cheers!
Hello my family member! I want to say that this post is awesome, great written and come with
almost all important infos. I’d like to peer more posts like this .