I am creating orders programmatically in Magento 2. I wanted to change the order base currency. The current currency is my custom currency, irrespective of currency available in Store as I don't want to have any impact on to frontend.
I have tried the following on Quote
but failed.
/** @var \Magento\Quote\Model\Quote $quote */
$quote = $this->cartRepositoryInterface->get($cartId);
$quote->setStore($store);
/** @var \Magento\Quote\Model\Cart\Currency */
$currency = $this->currencyFactory->create()
->setGlobalCurrencyCode($order->getCurrencyCode())
->setBaseCurrencyCode($order->getCurrencyCode())
->setStoreCurrencyCode($order->getCurrencyCode())
->setQuoteCurrencyCode($order->getCurrencyCode())
->setStoreToBaseRate(1.00)
->setStoreToQuoteRate(1.00)
->setBaseToGlobalRate(1.00)
->setBaseToQuoteRate(1.00);
$quote->setCurrency($currency);
Best Answer
I did a lot of trial and error and was able to override the
base_currency
.The above code did the job but If anyone can suggest a better way to do the job, it will be highly appreciated.
Also, this may not be the standard way.