Support » Plugin: WooCommerce PPOM » Better Display of Negative Numbers

Viewing 5 replies - 1 through 5 (of 5 total)
  • chrishe

    (@chrishe)

    Hi, I am sure NMedia can fix it, but if you have access to the plugin code, it’s a one-line change to plugin file /inc/functions.php:
    find line
    $formatted_price = ( $negative ? '-' : '' ) . sprintf( $price_format, get_woocommerce_currency_symbol(), $wc_price );
    in function ppom_price($price) at about line 1140
    and remove the extra negative bit to give:
    $formatted_price = sprintf( $price_format, get_woocommerce_currency_symbol(), $wc_price );
    This will keep it in line with the WooCommerce price settings.
    Hope that helps.
    Chris

    selabie68

    (@selabie68)

    Thanks Chris,

    Your solution helped. I solved it specifically with the following code:

    $wc_price = number_format( abs($price), $decimals, $decimal_separator, $thousand_separator );

    on line 1140 which now outputs -$5.00

    Now would be nice to have a css class applied to negative numbers to allow styling.

    • This reply was modified 5 months ago by  selabie68.
    Plugin Author N-Media

    (@nmedia)

    Hi,

    Thanks for suggesting fix, we have updated PPOM for a better control for negative number in version 16.0 with more major features and it will be released in couple of days.

    chrishe

    (@chrishe)

    @selabie68
    Hi, well that was the way I changed it to begin with – further testing showed that this gives different display to the woocommerce format in the product prices at the bottom
    (e.g. (-$30.00) in option, but £-30.00 in the product option price, so I changed it to the version I posted above, (removing the negative bit). But it is your choice!
    Chris

    Plugin Author N-Media

    (@nmedia)

    Version 16.0 is released.

Viewing 5 replies - 1 through 5 (of 5 total)
  • You must be logged in to reply to this topic.