1

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>
3

1 Answer 1

2

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..

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.