Skip to content

Instantly share code, notes, and snippets.

@bradleysa
Last active February 17, 2024 12:50
Show Gist options
  • Save bradleysa/7d1448253097784daf94 to your computer and use it in GitHub Desktop.
Save bradleysa/7d1448253097784daf94 to your computer and use it in GitHub Desktop.
WooCommerce: Add Continue Shopping Button on Cart Page
<?php
/**
* Add Continue Shopping Button on Cart Page
* Add to theme functions.php file or Code Snippets plugin
*/
add_action( 'woocommerce_before_cart_table', 'woo_add_continue_shopping_button_to_cart' );
function woo_add_continue_shopping_button_to_cart() {
$shop_page_url = get_permalink( woocommerce_get_page_id( 'shop' ) );
echo '<div class="woocommerce-message">';
echo ' <a href="'.$shop_page_url.'" class="button">Continue Shopping →</a> Would you like some more goods?';
echo '</div>';
}
@nootkan
Copy link

nootkan commented Apr 8, 2022

Thanks ! Still good in 2021. I'm no coder, but tweaked this slightly - plain button underneath cart, plus 'message' button above checkout.

/**
* Add Continue Shopping Button on Cart (& checkout) Page
*/

add_action( 'woocommerce_after_cart_table', 'woo_add_continue_shopping_button_to_cart' );

function woo_add_continue_shopping_button_to_cart() {
 $shop_page_url = get_permalink( woocommerce_get_page_id( 'shop' ) );
 
 echo '<div class="">';
 echo ' <a href="'.$shop_page_url.'" class="button">Continue Shopping</a>';
 echo '</div>';
}

add_action( 'woocommerce_before_checkout_form', 'woo_add_continue_shopping_button_to_checkout' );

function woo_add_continue_shopping_button_to_checkout() {
 $shop_page_url = get_permalink( wc_get_page_id( 'shop' ) );
 
 echo '<div class="woocommerce-message">';
 echo ' <a href="'.$shop_page_url.'" class="button">Continue Shopping</a> Not finished shopping ?';
 echo '</div>';
}

Everything I've tried from this thread works but I was wondering how to keep the button on the cart page the same way but have "continue shopping" show in the "have a coupon click here to enter your code" button instead of below it like the code above has it?

@sadhonKumar
Copy link

Awesome!!!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment