• Resolved JasperPress

    (@jasperpress)


    Hi!

    I’m having trouble getting the decimal separator and thousands separator correct for the currency and local settings I’m using (Euro, notation for the Netherlands).

    Problem: All prices are displayed with a comma as thousands separator and dots as decimal separator, but it should be the other way around.
    I can find no way or setting to change this.

    Does anyone have a good fix for this?

Viewing 3 replies - 1 through 3 (of 3 total)
  • Hello @jasperpress,

    Thanks for getting in touch with us.

    You can simply add the comma and dot separator as you want – https://www.loom.com/share/e15065300de6444b8c4ab7be27097b8b.

    I hope that helps.

    Thread Starter JasperPress

    (@jasperpress)

    Hi Frank,

    Well, to be honest, this doesn’t seem like a proper solution, since it does not deal with automatic markup of currency.

    I’ve managed to fix it for now with this function:

    function nl_cost_format($cost) {
      $number = floatval(str_replace(',', '', $cost));
      $formatted_cost = str_replace(',00', '', number_format($number, 2, ',', '.') );
      $cost = $formatted_cost;
      return $cost;
    }
    add_filter( 'tribe_currency_cost', 'nl_cost_format' );

    This moves the comma seperators (for tousands), converts it to a php float value, then formats the number with the number_format function, and then replaces the decimals when it’s a round number.

    Hello @jasperpress,

    Terrific! I’m glad you were able to get it to work to how you want.

    I’d be closing this thread, and please do not hesitate to bump a new thread on our way. This is for us to track down topics/issues efficiently and for us to follow the WordPress Forum Guidelines.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Price / cost decimal and thousand separator’ is closed to new replies.