Hide price on out-of-stock products in WooCommerce

Hide price on out-of-stock products in WooCommerce on child sites.

Snippet Type

Execute on Child Sites

Snippet

add_filter( 'woocommerce_get_price_html', 'remove_price_ofs', 10, 2 );

function remove_price_ofs( $price, $product ) {
   if ( ! $product->is_in_stock() && ! is_admin() ) {$price = '';}
   return $price;
}