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
Tried Jared's answer but just as someone stated, it removed every price once the condition was met. Ultimately I went this solution where it removed the action if the price was 0 and added it back if it wasn't. Seems to work.
public function woocommerce_after_shop_loop_item_title_remove_product_price(){
global $product;
$price = floatval( $product->get_price() );
if( $price <= 0 ){
remove_action('woocommerce_after_shop_loop_item_title', 'woocommerce_template_loop_price', 10);
}else{
add_action('woocommerce_after_shop_loop_item_title', 'woocommerce_template_loop_price', 10);
}
}
add_action( 'woocommerce_after_shop_loop_item_title', 'category_page_changes', 0 );