Hide Price If Product Is Not in Stock

add_filter( 'woocommerce_get_price_html', 'ab_hide_price_if_out_stock_product', 9999, 2 );
 
function ab_hide_price_if_out_stock_product( $price, $product ) {
   if ( is_admin() ) return $price; 
   if ( ! $product->is_in_stock() ) {
      $price = apply_filters( 'woocommerce_empty_price_html', '', $product );
   }
   return $price;
}

Leave a Reply

Your email address will not be published.