wordpress/woocommerce: Remove price if zero

前端 未结 5 1619
庸人自扰
庸人自扰 2021-02-04 22:38

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.

I\'ve tried looking on the

5条回答
  •  我在风中等你
    2021-02-04 22:49

    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);
        }
    }
    

提交回复
热议问题