WooCommerce Hide Product Price (No Plugin Needed) - React to WordPress

WooCommerce Hide Product Price (No Plugin Needed)

Hello, In this simple tutorial I will show you; how to hide your WooCommerce product price even if it’s not set to zero. You will not need to install any plugins or bang your head around on how to implement the code – everything is explained.

Also look
Remove or hide add to cart button in WooCommerce while disabling / keeping purchase
WooCommerce Hide Products Without Price (Simple Fix)

How to apply “WooCommerce Hide Product Price” Fix?

This is relatively simple; you have two options, choose one:

  1. Edit your functions.php file with your favorite FTP client add these functions to the end of the file.
  2. Edit through the WordPress theme editor located at Appearance > Editor > functions.php and add this functions to the end of the file.

The Fix

add_filter( 'woocommerce_get_price_html', 'react2wp_woocommerce_hide_product_price' );
function react2wp_woocommerce_hide_product_price( $price ) {
    return '';
}

If your theme is built the right way, and working correctly with WooCommerce, this filter should remove any memory of product pricing from the front end and still leave you the option to set up the price in the backend.

  • Function: add_filter( string $tag, callable $function_to_add, int $priority = 10, int $accepted_args = 1 )
  • Description:
    Hook a function or method to a specific filter action.
  • Args:
    • (string) $tag The name of the filter to hook the $function_to_add callback to.
    • (callable) $function_to_add The callback to be run when the filter is applied.
    • (int) $priority Used to specify the order in which the functions associated with a particular action are executed. Lower numbers correspond with earlier execution, and functions with the same priority are executed in the order in which they were added to the action.
    • (int) $accepted_args The number of arguments the function accepts.
  • Return:
    • (true)

More about: Best WordPress web hosting 2019  

7 comments on “WooCommerce Hide Product Price (No Plugin Needed)”

    1. Heyo! Thanks for the reply! you probably can achieve this by changing the returned string.

      Try this:

      add_filter( 'woocommerce_get_price_html', 'react2wp_woocommerce_hide_product_price' );
      function react2wp_woocommerce_hide_product_price( $price ) {
          return 'WooCommerce disabled prices';
      }

      Or add some HTML:

      add_filter( 'woocommerce_get_price_html', 'react2wp_woocommerce_hide_product_price' );
      function react2wp_woocommerce_hide_product_price( $price ) {
          return 'WooCommerce disabled prices. <a href="/contact">Ask for price!</a>';
      }

Leave a Reply

Your email address will not be published. Required fields are marked *