skip to Main Content

I am developing a WordPress site with WooCommerce and the search box displays the text "No products found." text when a product is not available.

How do I change this text to something else "don’t worry try again later"

enter image description here

I am not sure how to approach this as I am pretty new to this kind of modification.

2

Answers


  1. You could use the gettext hook to change the text.

    Place this in your functions.php With the switch, you will only effect text in the "woocommerce" text domain.

    function dd_change_text_strings( $translated_text, $text, $domain ) {
        switch ( $translated_text ) {
            case 'No products found' :
                if ($domain == 'woocommerce'){
                    $translated_text = __( "Don't worry try again later", 'woocommerce' );
                } else {
                    $translated_text = __( 'No products found', $domain );
                }
                break;
        }
        return $translated_text;
    }
    add_filter( 'gettext', 'dd_change_text_strings', 20, 3 );
    
    Login or Signup to reply.
  2. add_filter( 'woocommerce_register_post_type_product', 'woocommerce_register_post_type_product' );
    
    function woocommerce_register_post_type_product( $labels ) {
        $labels[ 'labels' ][ 'not_found' ] = __( 'don't worry, try again later', 'woocommerce' );
        return $labels;
    }
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search