Magento 2 Oreder Creation other than the base currency

Posted . Visible to the public.

How to create order programmatically other than the basic currency?

Step 1) After create your Quote object set the currency code that you want in the order

$quote = $this->quoteFactory->create();
$store = $order->getStore();
$store->setCurrentCurrencyCode($order->getOrderCurrencyCode()); // Eg: AUD|GRB
$quote->setStore($store);

Step 2) Set again before add the product to Quote

$store->setCurrentCurrencyCode($order->getOrderCurrencyCode());
$quote->setStore($store);

Step 3) Set again before the order creation

$store = $quote->getStore();
$store->setCurrentCurrencyCode($order->getOrderCurrencyCode());
$quote->setStore($store);
$newOrder = $this->quoteManagement->submit($quote);
vasan
Last edit
vasan
Keywords
Order, Magento, 2
Posted by vasan to vasan's deck (2022-09-02 14:39)