Skip to content

Instantly share code, notes, and snippets.

@WPDevHQ
Forked from SiR-DanieL/functions.php
Created January 3, 2017 12:21
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 WPDevHQ/c6c9dac4de8ef6814125992d24755c06 to your computer and use it in GitHub Desktop.
Save WPDevHQ/c6c9dac4de8ef6814125992d24755c06 to your computer and use it in GitHub Desktop.
/**
* Redirect to a specific page when clicking on Continue Shopping in the single product page
*
* @return void
*/
function wc_custom_redirect_continue_shopping( $message ) {
if ( strpos( $message, __( 'View Cart', 'woocommerce' ) ) !== false ) {
$message = str_replace( esc_url( wc_get_page_permalink( 'cart' ) ), esc_url( wc_get_page_permalink( 'shop' ) ), $message );
$message = str_replace( __( 'View Cart', 'woocommerce' ), esc_html__( 'Continue Shopping', 'woocommerce' ), $message );
}
return $message;
}
add_filter( 'wc_add_to_cart_message', 'wc_custom_redirect_continue_shopping' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment