A space to discuss GraphQL queries, mutations, troubleshooting, throttling, and best practices.
Hi,
We are about to launch an international version of our website. We have offered AUD, NZD, and USD pricing on our site for some time, however we are now splitting our pricing model so that AUD and NZD is used on our Australian site, and USD is used on our international site. We have been using the live conversion feature historically to calculate the NZD/USD equivalent, however we now want to be able to set unique pricing for USD.
We followed this guide: https://help.shopify.com/en/manual/payments/shopify-payments/multi-currency/international-pricing#se... and uploaded a spreadsheet with USD prices for our AUD products - so they are now going to be the exact same figure for USD and AUD.
I've since noticed some weirdness with the way it calculates totals. When I create a checkout using the GraphQL API, I send it a presentmentCurrencyCode of USD.
mutation checkoutCreate($checkoutCreate: CheckoutCreateInput!) {
checkoutCreate(input: $checkoutCreate) {
checkout {
id
}
checkoutUserErrors {
code
field
message
}
}
}
CheckoutCreateInput:
{
"checkoutCreate": {
"presentmentCurrencyCode": "USD"
}
},
I then add an item to my cart:
mutation addToCart($checkoutId: ID!, $lineItems: [CheckoutLineItemInput!]!) {
checkoutLineItemsReplace(checkoutId: $checkoutId, lineItems: $lineItems) {
checkout {
...CheckoutFragment
__typename
}
userErrors {
code
field
message
__typename
}
__typename
}
}
{
"checkoutId": "Z2........x=",
"lineItems": [
{
"quantity": 1,
"variantId": "Z2..........=="
}
]
}
This returns the following response:
{
"data": {
"node": {
"id": "Z2...=",
"currencyCode": "USD",
"lineItems": {
"edges": [
{
"node": {
"variant": {
"title": "My Variant",
"presentmentPrices": {
"edges": [
{
"node": {
"price": {
"amount": "359.0",
"currencyCode": "AUD"
}
}
},
{
"node": {
"price": {
"amount": "378.0",
"currencyCode": "NZD"
}
}
},
{
"node": {
"price": {
"amount": "359.0",
"currencyCode": "USD"
}
}
}
]
},
"priceV2": {
"amount": "359.0",
"currencyCode": "AUD"
}
}
}
}
]
},
"lineItemsSubtotalPrice": {
"amount": "306.0",
"currencyCode": "USD"
}
}
}
}
As you can see the total for the cart comes to $306, when it should be $359.
Now I know presentmentPrices are deprecated, but due to the way our site has been created we do not easily have the ability to change the GraphQL queries. I have also tried using the @inContext directive, but get the same result - however the priceV2 node is correct:
{
"data": {
"node": {
"id": "Z2....=",
"currencyCode": "USD",
"lineItems": {
"edges": [
{
"node": {
"variant": {
"title": "My Variant",
"presentmentPrices": {
"edges": [
{
"node": {
"price": {
"amount": "359.0",
"currencyCode": "AUD"
}
}
},
{
"node": {
"price": {
"amount": "378.0",
"currencyCode": "NZD"
}
}
},
{
"node": {
"price": {
"amount": "359.0",
"currencyCode": "USD"
}
}
}
]
},
"priceV2": {
"amount": "359.0",
"currencyCode": "USD"
}
}
}
}
]
},
"lineItemsSubtotalPrice": {
"amount": "306.0",
"currencyCode": "USD"
}
}
}
}
I spent an hour on live chat last night only to be told to come here, any help would be appreciated!
Solved! Go to the solution
This is an accepted solution.
Hi!
To use international pricing when creating a checkout from the Storefront API, you need to pass the country code in the input for the checkout's buyer identity.
While queries use the
@inContext
directive to contextualize the response from the server, checkout uses an explicitbuyerIdentity
argument as an input to the mutation that will be persisted. Context within the checkout is progressive and can change as customers input their address or additional information.To create a checkout in the context of a specific country, the checkoutCreate mutation takes an optional
buyerIdentity.countryCode
input argument which sets the checkout’s country field.When an address is updated on the checkout to include a different country using the checkoutShippingAddressUpdateV2 mutation, the prices that are returned reflect the new country’s prices, or the store's default prices if the new country isn't enabled.
(From these docs: https://shopify.dev/custom-storefronts/products/international-pricing#create-a-checkout)
Try instead passing this input to checkoutCreate:
{
"checkoutCreateInput": {
"buyerIdentity": {
"countryCode": "US"
}
}
}
Because it's not possible to infer a specific country from every currency (e.g. EUR) presentmentCurrencyCode is not sufficient information to use international pricing.
Still, thank you for the feedback. Your example shows that we're being inconsistent in the way presentmentPrices and presentmentCurrencyCode are interacting with international pricing and we'll see how we can improve this to make it easier to adopt international pricing incrementally.
To learn more visit the Shopify Help Center or the Community Blog.
Hey @bared-david
Thanks for raising this! By chance did you have an x-request-id from the headers for this request/any similar request like this? We'll take a look into it.
@Luke_K Yes! caf5902c-a5b1-4d74-a665-02585529682d - thank you for looking into this
This is an accepted solution.
Hi!
To use international pricing when creating a checkout from the Storefront API, you need to pass the country code in the input for the checkout's buyer identity.
While queries use the
@inContext
directive to contextualize the response from the server, checkout uses an explicitbuyerIdentity
argument as an input to the mutation that will be persisted. Context within the checkout is progressive and can change as customers input their address or additional information.To create a checkout in the context of a specific country, the checkoutCreate mutation takes an optional
buyerIdentity.countryCode
input argument which sets the checkout’s country field.When an address is updated on the checkout to include a different country using the checkoutShippingAddressUpdateV2 mutation, the prices that are returned reflect the new country’s prices, or the store's default prices if the new country isn't enabled.
(From these docs: https://shopify.dev/custom-storefronts/products/international-pricing#create-a-checkout)
Try instead passing this input to checkoutCreate:
{
"checkoutCreateInput": {
"buyerIdentity": {
"countryCode": "US"
}
}
}
Because it's not possible to infer a specific country from every currency (e.g. EUR) presentmentCurrencyCode is not sufficient information to use international pricing.
Still, thank you for the feedback. Your example shows that we're being inconsistent in the way presentmentPrices and presentmentCurrencyCode are interacting with international pricing and we'll see how we can improve this to make it easier to adopt international pricing incrementally.
To learn more visit the Shopify Help Center or the Community Blog.