My site there is display price like 20,00 CA$ but i want like this CA$ 20,00

i find the code on

vendor/magento/module-catalog/view/base/templates/product/price/amount/default.phtml

can any buddy suggest which code i change it for

<span class="price-container <?= /* @escapeNotVerified */ $block->getAdjustmentCssClasses() ?>"
        <?= $block->getSchema() ? ' itemprop="offers" itemscope itemtype="http://schema.org/Offer"' : '' ?>>
    <?php if ($block->getDisplayLabel()): ?>
        <span class="price-label"><?= /* @escapeNotVerified */ $block->getDisplayLabel() ?></span>
    <?php endif; ?>

    <span <?php if ($block->getPriceId()): ?> id="<?= /* @escapeNotVerified */ $block->getPriceId() ?>"<?php endif;?>
        <?= ($block->getPriceDisplayLabel()) ? 'data-label="' . $block->getPriceDisplayLabel() . $block->getPriceDisplayInclExclTaxes() . '"' : '' ?>
        data-price-amount="<?= /* @escapeNotVerified */ $block->getDisplayValue() ?>"
        data-price-type="<?= /* @escapeNotVerified */ $block->getPriceType() ?>"
        class="price-wrapper <?= /* @escapeNotVerified */ $block->getPriceWrapperCss() ?>">
        <?= /* @escapeNotVerified */ $block->formatCurrency($block->getDisplayValue(), (bool)$block->getIncludeContainer())  ?>
    </span>
    <?php if ($block->hasAdjustmentsHtml()): ?>
        <?= $block->getAdjustmentsHtml() ?>
    <?php endif; ?>
    <?php if ($block->getSchema()): ?>
        <meta itemprop="price" content="<?= /* @escapeNotVerified */ $block->getDisplayValue() ?>" />
        <meta itemprop="priceCurrency" content="<?= /* @escapeNotVerified */ $block->getDisplayCurrencyCode() ?>" />

    <?php endif; ?>
</span>
有帮助吗?

解决方案

Please try with below code :

app\code\Vendor\Extension\etc\events.xml

<?xml version="1.0"?>    
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Event/etc/events.xsd">
    <event name="currency_display_options_forming">
        <observer name="vendor_extension_change_currency_position" instance="Vendor\Extension\Model\Observer\Changecurrencyposition" />
    </event>
</config>

app\code\Vendor\Extension\Model\Observer\Changecurrencyposition.php

<?php        
namespace Vendor\Extension\Model\Observer;    

    use Magento\Framework\Event\ObserverInterface;    
    class Changecurrencyposition implements ObserverInterface
    {
        public function execute(\Magento\Framework\Event\Observer $observer)
        {    
            $currencyOptions = $observer->getEvent()->getCurrencyOptions();    
            $currencyOptions->setData('position', \Magento\Framework\Currency::RIGHT);  
            return $this;
        }    
    }

than apply below command :

php bin/magento setup:upgrade

hope its work for you..

许可以下: CC-BY-SA归因
scroll top