Home Forums WoodMart support forum Remove price from out of stock products Reply To: Remove price from out of stock products

#535904

av_admin_1984
Participant

Hi
I asked in woo community and they give me this code


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

add_filter( 'woocommerce_sale_flash', 'woodmart_no_sale_badge_if_out_of_stock', 9999, 3 );
function woodmart_no_sale_badge_if_out_of_stock( $html, $post, $product ) {
   if ( ! $product->is_in_stock()) return;
   return $html;
}

these code removed the percent in storefront theme but wont work in your theme