• ResolvedPlugin Contributor rudolfl

    (@rudolfl)


    Hi,

    Existing code for displaying price is incorrect. It is incompatible with other plugins, like currency switching and code that plays with prices on the fly.

    Current code is:

    if($single_variation->is_on_sale()):
                    $options['price_html'][] = get_woocommerce_currency_symbol().$single_variation->get_sale_price()." <del>".get_woocommerce_currency_symbol().$single_variation->get_regular_price()."</del>";
            else:
                    $options['price_html'][] = get_woocommerce_currency_symbol().$single_variation->get_regular_price();
            endif;

    It should be:

    if($single_variation->is_on_sale()):
                    $options['price_html'][] = wc_price($single_variation->get_sale_price())." <del>". wc_price($single_variation->get_regular_price())."</del>";
            else:
    wc_price($single_variation->get_regular_price());
            endif;

    Use of wc_price() means that all relevant filters are triggered and compatibility is maintained through the whole site.

    • This topic was modified 4 years, 2 months ago by rudolfl.
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Bug in displaying price’ is closed to new replies.