Reputation: 4807
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"
I am not sure how to approach this as I am pretty new to this kind of modification.
Upvotes: 0
Views: 540
Reputation: 11861
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;
}
Upvotes: 1
Reputation: 5639
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 );
Upvotes: 0