<p>In your plugin have you tried updating the currency and paymentCurrency fields in the craft_commerce_orders database table?</p>

<p>Depending on when you want to set the currency and how you are determining it, you could either do this by a direct database query, or modify the values in the order model before it is saved using this hook: <a href="https://craftcommerce.com/docs/events-reference#commerce_orders.onbeforesaveorder" rel="nofollow noreferrer">https://craftcommerce.com/docs/events-reference#commerce_orders.onbeforesaveorder</a></p>

CC BY-SA 3.0
2017-04-26T19:11:17.110Z
I have tried modifying those columns manually. But as far as I know, that doesn't affect the displayed prices.
Fred Carlsen
CC BY-SA 3.0
2017-04-25T09:13:49.673Z
2017-04-25T09:13:49.673Z
Matt Shearing
<p>You can set the <code>COMMERCE_PAYMENT_CURRENCY</code> in your index.php file. This defaults the <code>order.paymentCurrency</code>. The price attributes on the order are still stored in the primary store currency so you will still need to convert to the current payment currency with the <code>commerceCurrency</code> filter: <a href="https://craftcommerce.com/docs/twig-filters#commercecurrency" rel="nofollow noreferrer">https://craftcommerce.com/docs/twig-filters#commercecurrency</a></p>

CC BY-SA 3.0
2017-05-03T20:00:58.623Z
This wouldn't work as I need to conditionally set it from my plugin. Feature request? Say that becomes possible. Would I use the `order.paymentCurrency` through the `commerceCurrency` in the order confirmation etc. to keep it the same everywhere? Will that mean, that if I update the exchange rates, and a customer then goes to look at their order on the site, the price will look different from what they paid? It doesn't take into the exchange rate on the day they ordered, right?
Fred Carlsen
CC BY-SA 3.0
2017-05-01T16:24:17.433Z
2017-05-01T16:24:17.433Z
Luke Holder
<p>Is it possible to change the store currency from a plugin?</p>

<p>I know about <code>COMMERCE_PAYMENT_CURRENCY</code>, but I'm not sure how to set that one early enough.</p>

<p>It also seems like it doesn't affect the displayed price. Do I need to use the <code>commerceCurrency</code> in combination with the <code>cart.paymentCurrency</code> everywhere I display a price?</p>

<plugin-craftcommerce>
Changing store currency from a plugin
# Changing store currency from a plugin

(Asked by: username_0 on 2017-04-25)

Is it possible to change the store currency from a plugin?

I know about `COMMERCE_PAYMENT_CURRENCY`, but I'm not sure how to set that one early enough.

It also seems like it doesn't affect the displayed price. Do I need to use the `commerceCurrency` in combination with the `cart.paymentCurrency` everywhere I display a price?

**Tags:** plugin-craftcommerce


---

## 2 answers

### Answer by username_1 on 2017-04-25. Score: 1

In your plugin have you tried updating the currency and paymentCurrency fields in the craft\_commerce\_orders database table?

Depending on when you want to set the currency and how you are determining it, you could either do this by a direct database query, or modify the values in the order model before it is saved using this hook: <https://craftcommerce.com/docs/events-reference#commerce_orders.onbeforesaveorder>

> **Comments:**
> **username_0**: I have tried modifying those columns manually. But as far as I know, that doesn't affect the displayed prices.  

---

### Answer by username_2 on 2017-05-01. Score: 1

You can set the `COMMERCE_PAYMENT_CURRENCY` in your index.php file. This defaults the `order.paymentCurrency`. The price attributes on the order are still stored in the primary store currency so you will still need to convert to the current payment currency with the `commerceCurrency` filter: <https://craftcommerce.com/docs/twig-filters#commercecurrency>

> **Comments:**
> **username_0**: This wouldn't work as I need to conditionally set it from my plugin. Feature request? Say that becomes possible. Would I use the `order.paymentCurrency` through the `commerceCurrency` in the order confirmation etc. to keep it the same everywhere? Will that mean, that if I update the exchange rates, and a customer then goes to look at their order on the site, the price will look different from what they paid? It doesn't take into the exchange rate on the day they ordered, right?  

---

