如何在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(); }