Finally I figured out a way to do the conversion with the open cart currency class. I have mentioned below what I have done to solve this issue.
- I created the USD currency in the admin panel of the opencart & make it as the sub currency. (it will automatically update the conversion rate)
- In the opencart payment controller (catalog\controller\payment\twocheckout.php) and I did the following changes
After $order_info = $this->model_checkout_order->getOrder($this->session->data['order_id']);
line add the following code
$order_info['currency_code'] = 'USD';
Also changed the following Line
$this->data['total'] = $this->currency->format($order_info['total'], $order_info['currency_code'], $order_info['currency_value'], false);
to
$this->data['total'] = $this->currency->format($order_info['total'], $order_info['currency_code'],'', false);
And also changed the following line
'price' => $this->currency->format($product['price'], $order_info['currency_code'], $order_info['currency_value'], false);
to
'price' => $this->currency->format($product['price'], $order_info['currency_code'], '', false);
After changing those two lines, it was working perfectly and the currency value is changed to USD and the conversion value is also correct.
I hope this would be useful for anyone who have trouble with opencart currencies.