Change the name of the currency in currency selector in LUMA theme
-
15-04-2021 - |
質問
I am triying to do the solution in the link below
I am using Magento 2.4 but i cant find the files, my directory is empty
app/design/frontend/{vendore}/{theme}/Magento_Directory/templates/currency.phtml
I changed the USD symbol to REF but the currency selector did not.
解決
- To change the currency symbol on the product page and other store front pages there is no need to modify template files. There is a setting
Store → Currency → Currency Symbols
- The store switcher is a different story
Here I think you will have to modify the currency switcher like this in your local theme (note I used SEK you will have to replace this to your currency)
app/design/frontend/Custom/default/Magento_Directory/templates/currency.phtml
<?php if ($block->getCurrencyCount() > 1) : ?>
<?php $currencies = $block->getCurrencies(); ?>
<?php $currentCurrencyCode = $block->getCurrentCurrencyCode(); ?>
<?php $id = $block->getIdModifier() ? '-' . $block->getIdModifier() : '' ?>
<div class="switcher currency switcher-currency" id="switcher-currency<?= $block->escapeHtmlAttr($id) ?>">
<strong class="label switcher-label"><span><?= $block->escapeHtml(__('Currency')) ?></span></strong>
<div class="actions dropdown options switcher-options">
<div class="action toggle switcher-trigger"
id="switcher-currency-trigger<?= $block->escapeHtmlAttr($id) ?>"
data-mage-init='{"dropdown":{}}'
data-toggle="dropdown"
data-trigger-keypress-button="true">
<strong class="language-<?= $block->escapeHtml($block->getCurrentCurrencyCode()) ?>">
<span><?= $currentCurrencyCode == 'SEK' ? 'REF' : $block->escapeHtml($currentCurrencyCode) ?> - <?= $currencies[$currentCurrencyCode] ? $block->escapeHtml($currencies[$currentCurrencyCode]) : '' ?></span>
</strong>
</div>
<ul class="dropdown switcher-dropdown" data-target="dropdown">
<?php foreach ($currencies as $_code => $_name) : ?>
<?php if ($_code != $currentCurrencyCode) : ?>
<li class="currency-<?= $block->escapeHtmlAttr($_code) ?> switcher-option">
<a href="#" data-post='<?= /* @noEscape */ $block->getSwitchCurrencyPostData($_code) ?>'><?= $_code == 'SEK' ? 'REF' : $block->escapeHtml($_code) ?> - <?= $block->escapeHtml($_name) ?></a>
</li>
<?php endif; ?>
<?php endforeach; ?>
</ul>
</div>
</div>
<?php endif; ?>
所属していません magento.stackexchange