What can we help you with?

Display Regular Price range for the discounted Variable products using ELEX WooCommerce Dynamic Pricing Plugin (Code Snippet)

Do you want to hide the sale price and display only regular price for Variable products on your WooCommerce store?

If yes, you can simply use the code snippet provided in this article. The code snippet will display regular price range for variable products even if their is sale price or a discount is applied. This code snippet can be used for ELEX WooCommerce Dynamic Pricing plugin as well as for other plugins and general purpose.

Code snippet to display regular price for Variable products on discounts

Add the following code snippet to the functions.php file of activated website theme.

add_filter('woocommerce_get_price_html', 'elex_display_striked_out_price_for_variable', 200, 2);
function elex_display_striked_out_price_for_variable($price='', $product)
    $reg_price = '';
    if($product->is_type( 'variable' ))
        $variations = $product->get_children();
        $reg_prices = array();
        foreach ($variations as $value) {
            $single_variation=new WC_Product_Variation($value);
            array_push($reg_prices, $single_variation->get_regular_price());
        $min_price = $reg_prices[0];
        $max_price = $reg_prices[count($reg_prices)-1];
        if($min_price == $max_price)
            $reg_price = wc_price($min_price);
            $reg_price = wc_format_price_range($min_price, $max_price);
        return $reg_price;
    return $price;


Explore our blog section for more related articles.

You can also check out WooCommerce and WordPress plugins in ELEX.

Previous How to Customize the Pricing Table in Dynamic Pricing Using the Code Snippet?
Next How to alter price HTML for Variable products using Dynamic Pricing and Discounts Plugin for WooCommerce? (Code Snippet)
You must be logged in to post a comment.