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:
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:
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!
Leave a Reply