Prestashop currentLocale is null in module

Viewed 173

When I try to call in my module Context::getContext()->currentLocale->formatPrice($price, $currency); or $this->context->currentLocale->formatPrice($price, $currency); code fails because the Locale object is null.

Prestashop is updated to 1.7.8.3 version.

Any suggestion? Thanks

1 Answers

Try something like this:

Tools::getContextLocale($this->context)->formatPrice($price, $this->context->currency->iso_code);
Related