Modify or change Specific Text (Empty Mini Cart Text)

This code came about when a client asked us to change the default empty cart text for the Elementor Header Cart Widget’s Mini Cart Popup. Elementor does not actually provide an easy way to do this.

After searching through forums and Reddit, I found a solution that worked – although it can be a little too powerful for what we used it for.

This function will match and replace any instance of exact strings such as the text “No products in the cart.”

				
					function tb_change_text( $translated_text ) {
    
    if ( $translated_text == 'No products in the cart.' ) {
        $translated_text = 'Choose an Epic bundle to connect wherever you are.';
    }
    
    return $translated_text;
}
add_filter( 'gettext', 'tb_change_text', 20 );