Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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>';
}
@simaem

This comment has been minimized.

Copy link

simaem commented Sep 22, 2015

Thanks a lot mate.
It helped me 👍

@targetimc

This comment has been minimized.

Copy link

targetimc commented Feb 23, 2016

Thanks

@anoop1409

This comment has been minimized.

Copy link

anoop1409 commented Oct 1, 2016

Simple and to the point. Thanks for sharing

@mcswainj

This comment has been minimized.

Copy link

mcswainj commented Oct 5, 2016

That code is brilliant, works perfectly!

I like to keep things difficult though and am not using the default shop page, to avoid breaking my site anymore through trial and error, how would I get that to go to a specific URL instead of the 'shop'?

@gersonbarbosa7

This comment has been minimized.

Copy link

gersonbarbosa7 commented Oct 21, 2016

Thanks for sharing

@MarcHorree

This comment has been minimized.

Copy link

MarcHorree commented Mar 7, 2017

Hello bradleysa,

I was looking for a continue shopping button for my webshop. So I was very pleased to find the code which you added on this page. So I copied the whole part and added into my functions.php file. After clicking at the bottom of functions.php page on the update button my screen became completely white. My dashboard was gone as well is my website. When I want to go to wwww.mywebsite.nl/wp-admin/ I only get a white page. Can somebody tell me how to get my dashboard and website back. I am not a professional when it comes to Wordpress. Thanks for helping me.

@MarcHorree

This comment has been minimized.

Copy link

MarcHorree commented Mar 7, 2017

Hello Bradleysa,

I already solved my problem.

@cookieweb

This comment has been minimized.

Copy link

cookieweb commented May 26, 2017

Simple and works! Thanks for sharing.

@raoinam92

This comment has been minimized.

Copy link

raoinam92 commented Jun 28, 2017

Can you please tell me how I can this button on the Checkout page?

@Smyczek

This comment has been minimized.

Copy link

Smyczek commented Dec 14, 2017

For Cart & Checkout:

<?php
/**
* Add Continue Shopping Button on Cart Page & Checkout page
* Add to theme functions.php file or Code Snippets plugin
*/
add_action( 'woocommerce_before_cart_table', 'woo_add_continue_shopping_button_to_cart' );
add_action( 'woocommerce_before_checkout_form', 'woo_add_continue_shopping_button_to_cart' );

function woo_add_continue_shopping_button_to_cart() {
 $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> Would you like some more goods?';
 echo '</div>';
}
@coachasymi

This comment has been minimized.

Copy link

coachasymi commented Jan 19, 2018

Hi. Thanks for the code. Let's take it up a notch. How do you change the "Continue Shopping" URL instead of taking the user to the default Shop page, but to a different page, like Shop2 page?

@marjesch

This comment has been minimized.

Copy link

marjesch commented Jan 21, 2018

Excellent. Thank you for posting this. Very helpful. And Smyczek, thank you for your addition.

@tcolling

This comment has been minimized.

Copy link

tcolling commented Feb 12, 2018

Terrific. This is a big help. Thank you for posting this! 👍

@Bambinaros

This comment has been minimized.

Copy link

Bambinaros commented Mar 19, 2018

Thank you bradleysa, this has been very helpful. Is there a way to make the button get the search page with your last searched results, instead of just the search page, in both the Cart and Checkout pages? I've been looking everywhere and i can't seem to figure it out. Thnx again.

@smsnobin77

This comment has been minimized.

Copy link

smsnobin77 commented Apr 13, 2018

Very helpful.

@msalep

This comment has been minimized.

Copy link

msalep commented May 3, 2018

Thank you so much! Worked like a charm!

@fencemaster

This comment has been minimized.

Copy link

fencemaster commented Jul 25, 2018

This still works and is still useful - and appreciated - just so you know. Thanks. Raymond

@fecamposb

This comment has been minimized.

Copy link

fecamposb commented Jul 28, 2018

Thank you so much!

I was looking for hours to this, and it worked perfectly!

@felixprojekt

This comment has been minimized.

Copy link

felixprojekt commented Aug 8, 2018

On Woocomerce higher than 3.0 this throws a notice, instead of woocommerce_get_page_id you can use wc_get_page_id to make it go away

@fadhilinsemwa

This comment has been minimized.

Copy link

fadhilinsemwa commented Sep 10, 2018

thanx alot.

@stefaeva

This comment has been minimized.

Copy link

stefaeva commented Oct 11, 2018

Fantastic!!! Thank's a lot :-)

@AndrevRensburg

This comment has been minimized.

Copy link

AndrevRensburg commented Nov 27, 2018

Brilliant.

@antmid

This comment has been minimized.

Copy link

antmid commented Dec 22, 2018

Genius! Than you!

@stephanieangelabrauer

This comment has been minimized.

Copy link

stephanieangelabrauer commented Jan 21, 2019

Thank you so much :-)

@giacomoialenti

This comment has been minimized.

Copy link

giacomoialenti commented Apr 26, 2019

Thanks a lot it is PERFECT!!!
Just one question is it possible to set the button just after the "APPLY COUPON" button?
Thank you in advance.
Giacomo

@Girlfoyle

This comment has been minimized.

Copy link

Girlfoyle commented Aug 27, 2019

So, I put this in, and it adds the text but the link doesnt work? advice?

@jaychauhan2000

This comment has been minimized.

Copy link

jaychauhan2000 commented Oct 8, 2019

this code is working nicely but the "continue shopping" button disappears when I click the "Update cart" button, Is there a way to fix it?

@fsask

This comment has been minimized.

Copy link

fsask commented Nov 19, 2019

Nice! Does exactly what it is supposed to do. Hard to believe that WooCommerce doesn't automatically add this functionality. Thank you so much!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.