Last active
October 15, 2021 05:24
-
-
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.
This file contains 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( '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; | |
} ); |
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
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