Skip to content

Instantly share code, notes, and snippets.

@sybrew
Last active October 15, 2021 05:24
Show Gist options
  • Save sybrew/ad9ae08724f05c7edb10e780d642cb8d to your computer and use it in GitHub Desktop.
Save sybrew/ad9ae08724f05c7edb10e780d642cb8d to your computer and use it in GitHub Desktop.
Removes "Continue Shopping" message from WooCommerce after item has been added to cart.
<?php
\add_filter( 'wc_add_to_cart_message', function( $string, $product_id = 0 ) {
$start = strpos( $string, '<a href=' ) ?: 0;
$end = strpos( $string, '</a>', $start ) ?: 0;
return substr( $string, $end ) ?: $string;
} );
@babakfp
Copy link

babakfp commented Dec 9, 2019

Thanks

@Preciousomonze
Copy link

Preciousomonze commented Aug 3, 2021

Thanks for this @sybrew , to avoid deprecated notices, use wc_add_to_cart_message_html .
wc_add_to_cart_message has been deprecated as of 3.0 i think 🤔.
More info here : https://stackoverflow.com/a/55738046/5510038

@joanpla
Copy link

joanpla commented Oct 14, 2021

Thanks. Here's the updated snippet (credit to mayersdesign from Stackoverflow):

//remove message CONTINUE SHOPPING after an item has been added to cart
function filter_wc_add_to_cart_message_html( $message, $products ) { 
  return "<span>".$message."</span>"; 
}; 
add_filter( 'wc_add_to_cart_message_html', 'filter_wc_add_to_cart_message_html', 10, 2 ); 

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment