Change “No Product” message in Woocommerce

|▌冷眼眸甩不掉的悲伤 提交于 2021-02-07 09:25:20

问题


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?

enter image description here

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:

  1. 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/)

  2. (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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!