Add “Proceed to Checkout” next to “View Cart”

[ad_1]

Hello @iam3ple

Here is the solution for your query. Following filter is used to change/customize the Add to cart message.

"wc_add_to_cart_message_html"

Following code will add “Proceed to checkout” button link next to “View cart” in the notice when the product is successfully added to cart.

function wc_add_to_cart_message_html_custom_fun( $message, $products, $show_qty ) {
	return '<a href="'.esc_url( wc_get_checkout_url() ).'" tabindex="1" class="button wc-forward">'.esc_html__( 'Proceed to checkout', 'woocommerce' ).'</a> '. $message;
}
add_filter('wc_add_to_cart_message_html', 'wc_add_to_cart_message_html_custom_fun', 10, 3);

Add this code to your child theme’s functions.php file or via a plugin that allows custom functions to be added, such as the Code Snippets plugin. Remember, it’s not advisable to add custom code directly to your parent theme’s functions.php file, as updates to the theme will erase it.

I hope you find this information useful! If you have any more queries or need further help, don’t hesitate to ask.

Thread Starter
Tiago

(@iam3ple)

@smbhatia03 that worked like a charm! 🙌

Really appreciate your help here! This makes so much more sense to me, having the 2 options. And yes, I used the snippets plugin to avoid issues with future updates and all that.

Once again, thank you so much for helping me!

 

This site will teach you how to build a WordPress website for beginners. We will cover everything from installing WordPress to adding pages, posts, and images to your site. You will learn how to customize your site with themes and plugins, as well as how to market your site online.

Buy WordPress Transfer