gpt4 book ai didi

magento - 在 Magento2 中获取当前货币符号

转载 作者:行者123 更新时间:2023-12-01 07:18:07 25 4
gpt4 key购买 nike

如何在 Magento2 的 .phtml 文件中编写使用货币符号打印购物车总数的代码?

最佳答案

protected $_currency;

public function __construct(
\Magento\Backend\Block\Template\Context $context,
\Magento\Directory\Model\Currency $currency,
array $data = []
)
{
$this->_currency = $currency;
parent::__construct($context, $data);
}

/**
* Get currency symbol for current locale and currency code
*
* @return string
*/
public function getCurrentCurrencySymbol()
{
return $this->_currency->getCurrencySymbol();
}

关于magento - 在 Magento2 中获取当前货币符号,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34349247/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com