Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Full-featured multi-currency support in a single channel #1691

Closed
jpetrich opened this issue Jul 28, 2022 · 2 comments
Closed

Full-featured multi-currency support in a single channel #1691

jpetrich opened this issue Jul 28, 2022 · 2 comments
Labels
design 📐 This issue deals with high-level design of a feature @vendure/core
Milestone

Comments

@jpetrich
Copy link

Is your feature request related to a problem? Please describe.
When you want to support multiple currencies, the "right" way is with multiple channels, creating a 1:1 mapping of channels to currencies, even if you don't want to take advantage of any of the other features of channels. Then, if you care about the pricing in one currency (e.g. USD if your company is US-based), you need to update the pricing on every channel every time the exchange rate changes.

Describe the solution you'd like
As a P0, I would like to see support for multiple currencies per product variant.

As a P1, my ideal solution would allow setting a default currency for a channel, make the price denominated in that currency, and allow setting a list of alternate currencies and exchange rates. An admin API mutation could be updateCurrencyExchangeRates so a developer could create a separate currency exchange rate server that fetches exchange rates from wherever the developer desires, and updates the exchange rates in Vendure so pricing can be automatically updated by a shop frontend.

As a P2, extend this functionality to allow setting a preferred currency on a user, to make it easier to show a user's preferred currency on a shop frontend.

Describe alternatives you've considered
The frontend can fetch exchange rates and display prices in any currency, but this is only safe if the payment is going to be processed in the currency used in Vendure, because otherwise there's no way to ensure that an order is completely paid for.

A secondary server can be set up, or an custom extension built into Vendure to add an API that essentially acts as middleware implementing this functionality. The storefront would call Vendure directly for product and order information, but then make a second call to this custom API to convert prices to the user's preferred currency. Then for payment, a custom payment provider would need to be written as well to handle ensuring payment made in the currency not stored in Vendure is handled appropriately.

Additional context
I saw a conversation about this on Slack a few months ago where a feature request was suggested for V2, but then I didn't find one here, so I'm creating this. Happy to collaborate on the design if this seems like a reasonable general direction.

@michaelbromley michaelbromley added @vendure/core design 📐 This issue deals with high-level design of a feature labels Jul 29, 2022
@michaelbromley michaelbromley added this to the v2.0 milestone Jul 29, 2022
@michaelbromley
Copy link
Member

Hi Joe,

Thanks for the detailed write-up on this. I agree that it would be good to support this, since Channels have additional overheads that one should not need to take on just to support multiple currencies.

In theory we already have much of the data model in place to support this, since ProductVariant -> ProductVariantPrice is already a one-to-many relationship. This is how we support price-per-channel currently. It should not take too much work to make this price-per-channel-currency, i.e. adding a currencyCode property to the ProductVariantPrice entity.

I like the idea of a configurable exchange rate update mechanism too. I think this could be done either via a mutation as you suggest, or also by exposing a service so that e.g. a CLI script can do this as a cron job directly without the need for a network call. That aspect would be another use-case for #1425.

@michaelbromley michaelbromley modified the milestones: v2.0, v2.1 Oct 4, 2022
@michaelbromley michaelbromley modified the milestones: v2.1, v2.0 Dec 20, 2022
michaelbromley added a commit that referenced this issue Feb 23, 2023
Relates to #1691
This change puts in place a data model which will allow us to support multiple currencies per
channel, and will remove the requirement that a new price be set for
each channel that a variant is assigned to.

BREAKING CHANGE: The `Channel.currencyCode` field has been renamed to `defaultCurrencyCode`, and a
new `currencyCode` field has been added to the `ProductVariantPrice` entity. This will require
a database migration with care taken to preserve exiting data.
michaelbromley added a commit that referenced this issue Feb 23, 2023
Relates to #1691
This adds a new configurable strategy which allows you to define the logic by which a variant price
is selected based on factors like active channel and currency code.
@michaelbromley
Copy link
Member

Implemented in v2.0!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
design 📐 This issue deals with high-level design of a feature @vendure/core
Projects
Archived in project
Development

No branches or pull requests

2 participants