Hello I'm building an app using shopify storefront api, I want to create a currency selector, but haven't found a way to update checkout currency code.
Seems that the only way to set up checkout currency is to pass in buyer identity when creating a checkout.
Is there any way to update checkout buyer identity or currency code?
It's possible to call the checkoutCreate mutation passing it a currency that's been enabled on a store using presentmentCurrencyCode - feel free to check out here for more info.
There's a mutation to associate customers to the checkout - checkoutcustomerassociatev2 - that you might like to check out here.
There's a recently released mutation on Storefront API to update Buyer Identity on the Cart too (docs), though the Cart API is unstable at the moment. Not sure if the latter quite fits your use case. Hope that helps at least!
How would you change the buyer's Identity or country connected to checkout or Presentment currencies(going to be deprecated) after checkout is created?
The use case is User added a product to the cart (checkoutCreate Mutation) and then decided to change the country/currency.
International Pricing supercedes the deprecated Presentment Currencies which will be deprecated July 2022.
In terms of checkout creation with the newer International Pricing features, you'd be using the @incontext directive (which takes a Country Code Argument) on a mutation or query to run the mutation/query in context of the country code.
As International Pricing is determined on the Shipping Address, if customer changes to a different country checkoutShippingAddressv2 should return the new country's prices - or if a country is not enabled in the store, the store's default price.
You may also wish to checkout the Price List API too, which is another means of controlling Pricing based on a buyers location. I'd encourage you to check out those docs I've linked above. Hope that helps!
Changing the country in the shippingAddress for checkoutShippingAddressv2 did not change the currency for me. I ended up creating a new cart with a different @inContext directive language and the same line items as in the previous cart.