Support multiple currencies on storefronts
Merchants who use Shopify Payments can sell products and accept payments in multiple currencies, known as presentment currencies, on the Shopify platform. Prices are displayed in a customer's preferred currency on all storefront and checkout pages.
This tutorial shows you how to support multiple currencies on a storefront.
Requirements
Anchor link to section titled "Requirements"- You've reviewed and met the requirements on the Querying data with the Storefront API page.
- You've created products and product variants in your store.
- You've queried the Shopify card vault to obtain the session ID, which allows you to complete the checkout in this tutorial. For a detailed tutorial on how to create and complete checkouts, refer to Create a checkout with the Storefront API.
Query the store for supported currencies
Anchor link to section titled "Query the store for supported currencies"Shopify stores have a store currency, which is the default currency that's used to display prices on a storefront.
Merchants can enable multiple presentment currencies from their Shopify Payments settings. Presentment currencies are the currencies that can be used to display prices to customers on a storefront and checkout.
The following example shows how to query a shop's paymentSettings
object to return a list of enabled presentment currencies:
POST /api/2022-04/graphql.json
View response
JSON response
Return presentment prices on a product variant
Anchor link to section titled "Return presentment prices on a product variant"You can query specific product variants to return pricing information in different presentment currencies. By default, all currencies are returned, or you can use the presentmentCurrencies
argument as part of the presentmentPrices
object to return a specific currency.
When merchants set sale prices for products, the price is the sales price and original price is the compare at price.
The following query returns the compareAtPrice
and price
for the product variant's Australian (AUD) presentment currency:
POST /api/2022-04/graphql.json
View response
JSON response
Query products for the presentment price ranges
Anchor link to section titled "Query products for the presentment price ranges"You can query products to return the range of variant prices for presentment currencies. To get a price in a specific presentment currency you can query node
for a given product variant.
You can return the presentmentPriceRanges
by querying products
. By default, all currencies are returned, or you can use the presentmentCurrencies
argument on presentmentPriceRanges
to return a specific currency.
The following query returns the presentmentPriceRanges
for all of the store's supported currencies:
POST /api/2022-04/graphql.json
View response
JSON response
The following query only returns the presentmentPriceRanges
for the AUD currency code:
POST /api/2022-04/graphql.json
View response
JSON response
Create a checkout by specifying the currency
Anchor link to section titled "Create a checkout by specifying the currency"Apps can create checkouts using any of the enabled presentment currencies on a merchant's store.
To create a checkout using a specific currency, include the currency code as an input argument in the checkoutCreate mutation:
POST /api/2022-04/graphql.json
View response
JSON response
Complete the checkout
Anchor link to section titled "Complete the checkout"When you complete a checkout, you can provide the currency code of the created checkout as an input argument on the checkoutCompleteWithCreditCardV2 mutation.
To complete the payment, send the payment information, including the amount
, currencyCode
and billingAddress
fields. Send the payment session ID as the vaultID
.
The following mutation completes the checkout using Australian currency by sending the AUD currency code as part of the payment
object. The example uses the session ID from the Shopify card vault to complete the mutation.
POST /api/2022-04/graphql.json
GraphQL variables:
View response
JSON response
The response includes the payment ID of the completed checkout:
- Learn how to manage a cart in Shopify with the Storefront API.
- Learn how to manage customer accounts with the Storefront API.
- Support multiple languages on a custom storefront with the Storefront API.
- Retrieve metafields with the Storefront API to access additional information from different types of resources.
- Learn about the different tools that you can use to create unique buying experiences anywhere your customers are, including websites, apps, and video games.