+91 9737971210
info@wordpressdeveloperonline.com
Facebook
Facebook
Twitter
Twitter
Google+
Google+
LinkedIn
LinkedIn
Instagram
Instagram
WORDPRESS DEVELOPER
Menu
  • HOME
  • SERVICES
    • Free WordPress Setup
      • Free WordPress Website Blog
    • Hire WordPress Developer
      • WordPress Emergency Support
      • Hire PHP Developer
      • Hire WooCommerce Developer
      • Woocommerce Customization
      • Fix WordPress Errors
      • Fix WordPress Security
      • Multi Language Website Blog with WPML
    • Online Shopping Website
    • WordPress Theme Development
      • Avada Theme Experts
      • Divi Expert Services
      • Enfold Theme Expert
      • Jupiter Theme Expert
      • X Theme Expert Services
      • NewsPaper Theme Experts Services
    • PSD to WordPress
    • Speed Performance Optimization
    • WordPress Hosting Migration
    • SEO Link Building
  • PACKAGES
    • Speed Optimization Packages
  • WHY WE
    • PORTFOLIO
    • TESTIMONIALS
    • CAREER
  • BLOG
  • CONTACT

WooCommerce Hide the Product Price When Price Zero

September 17, 2018wordpressdeveloperWoocommerce

By default WooCommerce display product price in archive page and single page but what to do if product price is zero. it’s not look good in your shop page when product price is zero so it’s better to hide the price of an Product when it’s zero on the product category/archive page or single product page.

so here is solution, Add below line of code in your theme’s functions.php file of your active child theme (or theme) and save the file.

function hide_product_price_display( $price ) {
    $clear = trim(preg_replace('/ +/', ' ', preg_replace('/[^A-Za-z0-9 ]/', ' ', urldecode(html_entity_decode(strip_tags($price))))));
    if($clear == "0 00"){
      return '';
    }
    return $price;
  }
  add_filter( 'woocommerce_get_price_html', 'hide_product_price_display' );
  add_filter( 'woocommerce_cart_item_price', 'hide_product_price_display' );