add_filter( 'woocommerce_get_price_html', 'wpcb_hide_regular_price_for_sale_products', 10, 2 ); if ( ! function_exists( 'wpcb_hide_regular_price_for_sale_products' ) ) { /** * wpcb_hide_regular_price_for_sale_products. * * @see https://wpcodebook.com/snippets/hide-regular-price-for-products-on-sale-in-woocommerce/ */ function wpcb_hide_regular_price_for_sale_products( $price, $product ) { if ( $product->is_on_sale() ) { if ( $product->is_type( 'variable' ) ) { // Variable products $prices = $product->get_variation_prices( true ); if ( ! empty( $prices['price'] ) ) { $min_price = current( $prices['price'] ); $max_price = end( $prices['price'] ); $min_reg_price = current( $prices['regular_price'] ); $max_reg_price = end( $prices['regular_price'] ); if ( $min_price === $max_price && $min_reg_price === $max_reg_price ) { return wc_price( $min_price ) . $product->get_price_suffix(); } } } elseif ( ! $product->is_type( 'grouped' ) ) { // Simple etc. products (i.e. all except grouped) return wc_price( wc_get_price_to_display( $product ) ) . $product->get_price_suffix(); } } // No changes return $price; } }