In Woocommerce, when a product has zero price it will display ‘Free’ instead. In this tutorial we’ll learn how to remove price of a product when it is zero.
Here is what our category and archive page looks like when a product has price equal to zero.
Shop page will look like:
The category page will look like:
And product page:
Now we want to remove ‘Free’ label on category and shop page. To do this add the following lines of code at the end of 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); } }
You can access functions.php file here:
Save the file after placing code.
Now refresh the category and shop page and you’ll see ‘Free’ text removed.
Shop page will be:
And category page will look like:
However ‘Free’ text will still be displayed at product page.