Viewing 3 replies - 1 through 3 (of 3 total)
  • Did you ever find a solution to this? I was looking to do the same thing.

    Stagger Lee

    (@stagger-lee)

    I dont have anything behind rounded numbers so i added it simple in template file. Matter of appearance, visitor will never know.

    <div class="invoice-row-right"><?php the_sub_field('net_price'); ?>.00€</div>

    But if you have something like this 59.75 €, it wont work of course.

    When you’re outputting the field in your template, use PHP’s number_format. Example:

    <?php echo number_format( floatval( get_field('price') ), 2, '.', ',' ); ?>

    floatval converts the custom field string into a float, and number_format constrains the number to 2 decimal places, and adds the comma.

    On the admin side there doesn’t seem to be an easy way to add a comma to the “Number” field type.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Add Comma on Number Field’ is closed to new replies.