问题
I have the problem at the first Woocommerce page. I don't have any product at the shop. For this reason, Woocommerce shows "No Products" message on the first page. Now I want to change this message. How do I do this?
Shop address: http://shahroodantenna.ir/shop/
回答1:
Try the following, where you can customize the "No Product" message:
add_action( 'woocommerce_no_products_found', function(){
remove_action( 'woocommerce_no_products_found', 'wc_no_products_found', 10 );
// HERE change your message below
$message = __( 'No products were found matching your selection.', 'woocommerce' );
echo '<p class="woocommerce-info">' . $message .'</p>';
}, 9 );
Code goes in function.php file of your active child theme (or active theme). Tested and works.
回答2:
Hi you could achieve this in two ways:
overriding the no-products-foun2 template on your child theme (see: https://docs.woocommerce.com/document/template-structure/ - https://woocommerce.com/2015/12/site-search-nothing-found/)
(easier) use "Say What" plugin - https://wordpress.org/plugins/say-what/ - It allows you to replace the desired string with the text you desire
With the second option, you can customize only the copy. Going with the first one, you have more freedom to insert pictures, a search form, etc...
来源:https://stackoverflow.com/questions/50177110/change-no-product-message-in-woocommerce