Why am I saying “the most correct way”? Because there are plenty of tutorials where it is recommended to do with
woocommerce_get_price_html filter hook. I disagree with that approach, because this hook is intended to edit the html of the price element lol 😁
Maybe somebody doesn’t like WooCommerce much but I am happy with it, everything coded in an awesome way. Just take a look at this article as an example – we do not have to edit any of the theme templates – just turn off the appropriate action hook!
WooCommerce product prices are connected to
woocommerce_after_shop_loop_item_title (product archive pages) and
woocommerce_single_product_summary (single product pages)
The detailed examples are below.
Shop Page, Product Categories, Product Tags, Search Page, Related Products, Upsells, Cross-Sells
The code below can be inserted to your current theme
functions.php file. Please consider using child themes if necessary.
remove_action( 'woocommerce_after_shop_loop_item_title', 'woocommerce_template_loop_price', 10 );
This hook affects:
- Shop page,
- Search results page,
- Product categories,
- Product tags,
- Related products,
- Upsells (on the Cart page);
Single Product Pages
remove_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_price', 10 );
Hmm… looking at this screenshot I also have a feeling, that we do not need a “Sale” badge after all, you can read here how to remove it.
If you have any questions – maybe you would like to hide prices in certain product categories only or only for some user roles – feel free to ask in comments below.