如何在 PrestaShop 1.7 模板中获取语言环境对象?
How to get locale object in PrestaShop 1.7 template?
我在我的模板文件中使用 Tools::displayPrice()
函数来显示带货币的格式化价格,但是新版本 (1.7.6.0) 中关于此函数的文档说:
* @deprecated Since 1.7.6.0. Please use Locale::formatPrice() instead
* @see PrestaShop\PrestaShop\Core\Localization\Locale
那么如何在我的模板中使用 Locale
对象?
--
P.S。
PrestaShop 官方文档位于:https://devdocs.prestashop.com/1.7/ 是一团糟,所以如果有人可以 link 分享一些完整可靠的资源,我(以及更多)将非常感激
Google 个结果:
Context::getContext()->currentLocale->formatPrice(123.45, 'EUR');
或例如在模块中
$this->context->currentLocale->formatPrice($price, $currencyCode);
来自 https://devdocs.prestashop.com/1.7/modules/core_updates/1.7.6/
我在我的模板文件中使用 Tools::displayPrice()
函数来显示带货币的格式化价格,但是新版本 (1.7.6.0) 中关于此函数的文档说:
* @deprecated Since 1.7.6.0. Please use Locale::formatPrice() instead * @see PrestaShop\PrestaShop\Core\Localization\Locale
那么如何在我的模板中使用 Locale
对象?
-- P.S。 PrestaShop 官方文档位于:https://devdocs.prestashop.com/1.7/ 是一团糟,所以如果有人可以 link 分享一些完整可靠的资源,我(以及更多)将非常感激
Google 个结果:
Context::getContext()->currentLocale->formatPrice(123.45, 'EUR');
或例如在模块中
$this->context->currentLocale->formatPrice($price, $currencyCode);
来自 https://devdocs.prestashop.com/1.7/modules/core_updates/1.7.6/