wordpress/woocommerce:如果为零则删除价格 [英] wordpress/woocommerce: Remove price if zero
本文介绍了wordpress/woocommerce:如果为零则删除价格的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正忙于一个 wordpress/woocommerce 网站,我想隐藏产品类别/存档页面上为零时的商品价格.
I'm busy with a wordpress/woocommerce site and I'd like to hide the price of an item when it's zero on the product category/archive page.
我试过在网上和 php 文件中查找,但找不到我应该在哪里添加 if 语句.
I've tried looking on the web and in the php files but couldn't find where I should add the if statement.
我的 php 知识非常有限.我想知道其他人是否有这方面的经验或可以以正确的方式帮助我
My php knowledge is pretty limited. I was wondering if someone else has experience with this or could help me in the right way
谢谢!
推荐答案
我还没有测试过,但我希望这样的事情应该可以完成这项工作.将此添加到您的 functions.php 文件中.
I haven't tested it but I expect something like this should do the job. Add this to your functions.php file.
add_action('woocommerce_before_shop_loop_item','custom_remove_loop_price');
function custom_remove_loop_price(){
global $product;
if(!$product->price){
remove_action('woocommerce_after_shop_loop_item_title','woocommerce_template_loop_price',10);
}
}
这篇关于wordpress/woocommerce:如果为零则删除价格的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文