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.
View Comments (6)
Comment or Ask a Question
Quick Links