Website Building » WooCommerce » How Do I Change the Continue Shopping Link in WooCommerce?

How Do I Change the Continue Shopping Link in WooCommerce?

Last updated on January 12, 2023 @ 12:54 pm

If you’re using the WooCommerce plugin for WordPress, you may have noticed that the “Continue Shopping” button on the cart page goes to the WooCommerce shop page by default. While this may be fine in some cases, there are definitely times when you’ll want to change where this button goes.

Maybe you want it to go back to the previous page, or maybe you want it to go to a specific product page. Whatever the reason, changing the “Continue Shopping” link in WooCommerce is actually pretty easy.

The first thing you need to do is locate the WooCommerce template files. These are located in wp-content/plugins/woocommerce/templates.

Once you’re in that folder, open up cart/cart.php. This is the main template file for the WooCommerce cart page.

Near the top of this file, you’ll see a line that looks like this:

<?php echo apply_filters( 'woocommerce_continue_shopping_redirect', wc_get_raw_referer() ? wc_get_raw_referer() : wc_get_page_permalink( 'shop' ) ); ?>
PRO TIP: If you are not a developer or are not comfortable with code, we do not recommend trying to change the Continue Shopping link in WooCommerce. This is a complex process that can break your site if done incorrectly.

This is where the “Continue Shopping” link URL is generated. By default, it just goes to the shop page. If you want it to go somewhere else, though, you can just change that line of code.

For example, let’s say you wanted the “Continue Shopping” button to take people back to the previous page. In that case, you would change that line of code to this:

<?php echo apply_filters( 'woocommerce_continue_shopping_redirect', wc_get_raw_referer() ? wc_get_raw_referer() : esc_url( $_SERVER['HTTP_REFERER'] ) ); ?>

Or let’s say you wanted it to go to a specific product page. In that case, you would change it to something like this:

<?php echo apply_filters( 'woocommerce_continue_shopping_redirect', wc_get_raw_referer() ? wc_get
Madison Geldart

Madison Geldart

Cloud infrastructure engineer and tech mess solver.