get_add_to_cart_message filter needed
-
What filter hook could I use to replace this function:
protected static function get_add_to_cart_message( $quantity, $product_title ) { $product_title = '"' . $product_title; if ( $quantity > 1 ) { $product_title = $quantity . ' × ' . $product_title; } return sprintf( esc_html__( '%s" added to your order. Complete your order below.', 'wcopc' ), $product_title ); }
with this:
protected static function get_add_to_cart_message( $quantity, $product_title ) { $product_title = $product_title; if ( $quantity > 1 ) { $product_title = $quantity . ' × ' . $product_title; } return sprintf( __( '<span class="added_to_order_ul">%s</span><br>added to your order.<br><br>Complete your order below.', 'wcopc' ), $product_title ); }
?
I already did the replacement in the woocommerce-one-page-checkout.php file, and it works fine, but after an update it will be rewritten and putting the edited file together with its folder in my child theme broke my site (needed to restore my site from a backup).
So I need a proper filter hook.
I wrote the following filter hook but it doesn’t work:
add_filter( 'get_add_to_cart_message', function( $html ) { $string_to_replace = '%s" added to your order. Complete your order below.'; $replace_with = '<span class="added_to_order_ul">%s</span><br>added to your order.<br><br>Complete your order below.'; $html = str_replace( $string_to_replace, $replace_with, $html ); return $html; }, 10, 1);
and I repeated this function to replace the
$product_title = '"' . $product_title;
part with$product_title = $product_title;
as well.No errors but it don’t do anything.
By any chance can someone advise how to proceed?
Thank you!
Viewing 6 replies - 1 through 6 (of 6 total)
Viewing 6 replies - 1 through 6 (of 6 total)
- The topic ‘get_add_to_cart_message filter needed’ is closed to new replies.