Skip to content

Instantly share code, notes, and snippets.

@SiR-DanieL
Created December 7, 2023 06:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save SiR-DanieL/200b5e99b80984340313da46ee5d7252 to your computer and use it in GitHub Desktop.
Save SiR-DanieL/200b5e99b80984340313da46ee5d7252 to your computer and use it in GitHub Desktop.
How to Change the Continue Shopping Redirect URL on the Cart
<?php
add_filter( 'woocommerce_continue_shopping_redirect', 'custom_continue_shopping_redirect' );
function custom_continue_shopping_redirect( $default ) {
// Example condition 1: Redirect to Home
if ( /* your condition for Home */ ) {
return home_url(); // Redirects to the Home page
}
// Example condition 2: Redirect to Shop
if ( /* your condition for Shop */ ) {
return wc_get_page_permalink( 'shop' ); // Redirects to the Shop page
}
// Example condition 3: Redirect to Blog
if ( /* your condition for Blog */ ) {
return get_permalink( get_option( 'page_for_posts' ) ); // Redirects to the Blog page
}
// Example condition 4: Redirect to another page by ID
$another_page_id = 123; // Replace 123 with your specific page ID
if ( /* your condition for specific page */ ) {
return get_permalink( $another_page_id ); // Redirects to the specific page by ID
}
// Default redirect
return $default;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment