• Resolved neoset

    (@neoset)


    Hello, how could I change the points to commas with a code from functions.php, that is, to the European format in decimals?
    They are dynamic ACF values of type number.
    I have already solved it with Bricks and ACF but the same solution does not work with Generateblocks.
    I have used the filter:

    add_filter('acf/format_value', 'custom_format_european_number', 10, 3);

    Regards, and thank you very much.

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Support ying

    (@yingscarlett)

    Hi@neoset ,

    Can you share the code of function custom_format_european_number?

    Thread Starter neoset

    (@neoset)

    function custom_format_european_number($value, $post_id, $field) {
    // Check if ACF field is of numeric type
    if ($field['type'] === 'number') {
    // Check if the value is numeric
    if (is_numeric($value)) {
    // Round the value to 2 decimal places
    $rounded_value = round($value, 2);
    // Check if the value has decimal places
    if (floor($rounded_value) == $rounded_value) {
    return number_format($rounded_value, 0, ',', '.'); // Format as an integer
    } else {
    return number_format($rounded_value, 2, ',', '.'); // Format with 2 decimal places
    }
    }
    }
    return $value;
    }
    add_filter('acf/format_value', 'custom_format_european_number', 10, 3);

    • This reply was modified 1 year, 5 months ago by neoset.
    • This reply was modified 1 year, 5 months ago by neoset.
    • This reply was modified 1 year, 5 months ago by neoset.
    Plugin Support ying

    (@yingscarlett)

    Hi there,

    in order to return the correct format, it will require GB Pro plugin for additional compatibility with ACF, unforturanly.

    Plugin Support fernandoazarcon2

    (@fernandoazarcon2)

    Hi there! We haven’t heard back from you for a while now so we’re going to go ahead and set this topic as resolved. Feel free to open a new topic if you need assistance with anything else GB free plugin related.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Change dynamic fields from acf to European format’ is closed to new replies.