Hiding the price of a product in WooCommerce is easy to do with a few lines of code. Simply add the following to your theme’s functions.php file:
Hiding the price of a product is fairly easy to do with WooCommerce. However, it is important to note that hiding the price of a product will also hide the “Add to Cart” button for that product. This means that customers will not be able to purchase the product unless they add it to their cart first.
If you are selling products on your WooCommerce site and you want to hide the price of a product on the product page, you can follow these steps:
1. Log into your WooCommerce site.
2. Go to Products > All Products.
3. Find the product you want to hide the price for and click Edit.
4. In the General tab, scroll down to the Pricing section.
5. In the Regular Price field, enter 0 (zero).
6. In the Sale Price field, enter 0 (zero).
function my_custom_price_html( $price, $product ) {
if ( $product->get_price() == 0 ) {
$price = '';
}
return $price;
}
add_filter( 'woocommerce_get_price_html', 'my_custom_price_html', 100, 2 );
With this code in place, any products that have a price of zero will have their price hidden on the front-end of your store. If you want to hide the price of all products, regardless of price, you can use this instead:
function my_custom_price_html( $price, $product ) {
return '';
}
add_filter( 'woocommerce_get_price_html', 'my_custom_price_html', 100, 2 );
Hiding the price can be useful if you want to discourage people from buying certain products, or if you’re running a sale and don’t want people to know the regular prices. It’s also helpful if you’re selling products that are only available through a specific process, like bidding or negotiation. Whatever your reason for hiding prices, it’s easy to do with WooCommerce.