Skip to content

Instantly share code, notes, and snippets.

@brunoalvarenga
Forked from SirDarcanos/functions.php
Created September 30, 2016 20:43
Show Gist options
  • Save brunoalvarenga/19e623b1bf0171dff32311e12457fa48 to your computer and use it in GitHub Desktop.
Save brunoalvarenga/19e623b1bf0171dff32311e12457fa48 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