Custom notice message and continue Shopping Button Woocommerce

Custom notice message and continue Shopping Button Woocommerce

Are you looking for a way to change the default notice when product “Added to cart”  in WooCommerce? and you can add  “Continue Shopping” button

STEPS TO CHANGE DEFAULT NOTICE TEXT

  1. Open WordPress admin panel, go to Appearance > Theme Editor 
  2. Open functions.php theme file
  3. Add the following code at the bottom of function.php file
  4. Save the changes and check your website. The custom text in add to cart button should show up now.
				
					function your_add_to_cart_message() {
if ( get_option( 'woocommerce_cart_redirect_after_add' ) == 'yes' ) :
    $message = sprintf( '%s<a href="%s" class="button wc-forward">%s</a>', __( 'successfully added to shopping cart.', 'woocommerce' ), esc_url( get_permalink( woocommerce_get_page_id( 'shop' ) ) ), __( 'Continue shopping', 'woocommerce' ) );
else :
    $message = sprintf( '%s<a href="%s" class="button wc-forward">%s</a>', __( 'successfully added to shopping cart.' , 'woocommerce' ), esc_url( get_permalink( woocommerce_get_page_id( 'cart' ) ) ), __( 'Continue shopping', 'woocommerce' ) );
	
endif;
return $message;
}
add_filter( 'wc_add_to_cart_message', 'your_add_to_cart_message' );

add_filter( 'wc_add_to_cart_message_html', 'my_custom_add_to_cart_message' );
function my_custom_add_to_cart_message( $message ) {
    $message .= sprintf( '<a href="%s" class="button wc-backword back-btn">%s</a>', get_permalink( woocommerce_get_page_id( 'shop' ) ), 'Continue shopping');
    return $message;
}
				
			

Subscribe to get latest updates !

Need Help? Chat with me
Please accept our privacy policy first to start a conversation.