Webkul
Services
Technologies Bagisto QloApps
iOS Android SAP BigCommerce Wix
Trusted by
Samsung Intel Toyota Walmart Disney Nokia Nestlé Decathlon
See all customers
Back to Top
ARTICLE

Programmatically change/set the current currency of store in Magento 2.

In this Article I am going to explain, how to change the current currency of the store.
Need : If you are developing Api’s or creating the custom module, the situation may come, when you need to change the current currency of store.
To get the right behaviour for the target.

Here we go :

$objectManager = \Magento\Framework\App\ObjectManager::getInstance();
$storeManager = $objectManager->get(\Magento\Store\Model\StoreManagerInterface::class);
$currency = "USD";
if ($currency) {
   $storeManager->getStore()->setCurrentCurrencyCode($currency);
}

$currency is a currency code in which you want to set the current currency to your store.

. . .

Leave a Comment

Your email address will not be published. Required fields are marked*


6 comments

  • Satish V
    • Prabhat Rawat (Moderator)
  • Patrick van Bergen
    • Prabhat Rawat (Moderator)
  • Rajesh Gohil
    • Prabhat Rawat (Moderator)
  • Back to Top

    Message Sent!

    If you have more details or questions, you can reply to the received confirmation email.

    Back to Home