Hi! I am using fieldMethods
option in my plugin to format price properly.
Like this
'fieldMethods' => [
'price' => function ($field) {
return number_format((float)$field->value, 2, ',', '.');
}
]
But I would like to add an option in the panel to choose a custom separator.
Price options are in the page, not in the site blueprint.
I tried this approach, but it doesn’t work:
'fieldMethods' => [
'price' => function ($site, $field) {
$shop = $site->children()->findBy('intendedTemplate', 'shop');
return number_format((float)$field->value, 2, ',', $shop->thousandSeparator());
}
]
Any help is highly appreciated.