Created
December 7, 2023 06:25
-
-
Save SirDarcanos/200b5e99b80984340313da46ee5d7252 to your computer and use it in GitHub Desktop.
How to Change the Continue Shopping Redirect URL on the Cart
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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