Nicola Mustone

Happiness Lead @ Automattic



How to Change the Continue Shopping Redirect URL

A man scaring a standing man as if he was a ghost.

In the past we discussed about how to change the Return to Shop button URL in the Empty Cart page. Today we will learn how to change the Continue Shopping button URL always on the cart page.

This button appears when the option Redirect to the cart page after successful addition is selected in WooCommerce > Settings > Products > General > Shop pages > Add to cart behaviour.

Before implementing any code changes, always ensure your site is backed up. This will help you restore things in case of unforeseen errors. I recommend using Jetpack Backup for real-time backups and one-click restores.

The necessary snippet is quite short, requiring only one line even:

<?php
add_filter( 'woocommerce_continue_shopping_redirect', function() { return get_home_url(); } );
view raw functions.php hosted with ❤ by GitHub

You can add a layer of complexity and return a different link, maybe conditionally by using a full function instead of an anonymous one, like so:

<?php
add_filter( 'woocommerce_continue_shopping_redirect', 'custom_continue_shopping_redirect' );
function custom_continue_shopping_redirect( $default ) {
// Write your conditional code here
return $default;
}
view raw functions.php hosted with ❤ by GitHub

This would allow you to add conditions to your function so that you can maybe redirect to a different page based on what product is added to the cart, or based on the user role. Use your imagination!

Advertisements

Subscribe to This Blog

Receive new articles from this blog directly in your inbox! No spam guaranteed!

Join 651 other subscribers

Contribute to Improving This Blog

Did you enjoy this article? Was it helpful? Contribute to help me write more articles! The funds collected from this blog are reinvested directly into improving my skills or the blog so that I can provide more and better content!

One-Time
Monthly
Yearly

Make a one-time donation

Make a monthly donation

Make a yearly donation

Choose an amount

€5.00
€15.00
€100.00
€5.00
€15.00
€100.00
€5.00
€15.00
€100.00

Or enter a custom amount


Your contribution is appreciated.

Your contribution is appreciated.

Your contribution is appreciated.

DonateDonate monthlyDonate yearly
Advertisements

More Posts That You Might Like…


One response to “How to Change the Continue Shopping Redirect URL”

  1. […] If you turn on the option to redirect to the cart page after adding a product to the cart, you will have a nice little button that invites you to Continue Shopping. You can change this URL to anything you want! […]

Leave a Reply

Advertisements

Categories

Newsletter

Receive new articles from this blog directly in your inbox!

No spam guaranteed!

Join 651 other subscribers

About The Author

Hi, I’m Nico! Support Lead at Automattic, championing WordPress.com & WooCommerce. Off-duty, I’m at Elemental Beacon, leading epic D&D adventures. Let’s connect, whether it’s about WordPress or a quest!

Advertisements

Don't Miss a Thing!

Receive new articles from this blog directly in your inbox!

No spam guaranteed!

Join 651 other subscribers

Continue Reading

%d bloggers like this: