Contacts
Get in touch

Add a Currency Selector to the Hydrogen Theme

hydrogen

In Shopify, the available currencies are linked to the country selection, which is determined by the buyer’s identity in the cart object. To change the currency, we need to update the buyer identity in the cart object with the relevant country code.

Adding a currency selector component is straightforward. You can place it in your header or footer.

First, we create a CurrencyData object and store the selected value in a cookie. The currency selection is done via a link to an endpoint. We retrieve the currency value from the URL and update the buyer identity using a GraphQL mutation. Ensure that the CurrencyData object is correctly configured, and all country and currency relationships are set up in your Shopify portal (in the market configuration section).

Component

Endpoint

Leave a Comment

Your email address will not be published. Required fields are marked *