Shopify / js-buy-sdk

The JS Buy SDK is a lightweight library that allows you to build ecommerce into any website. It is based on Shopify's API and provides the ability to retrieve products and collections from your shop, add products to a cart, and checkout.
https://shopify.github.io/js-buy-sdk
MIT License
984 stars 259 forks source link

How to handle International pricing with shopify-buy (deprecated presentmentPrices) #886

Open moreguppy opened 2 years ago

moreguppy commented 2 years ago

Hello Shopify—

Myself (and I think many others) are a bit lost with the deprecated presentmentPrices and the move to the International pricing API

Are there methods in the shopify-buy sdk to handle this now?

For example, when initialising the client do we need to set the currency? Or do we need to somehow set the currency per fetching method?

  client.collection
    .fetchWithProducts(collectionId, { 
      productsFirst: 120,
      currency: 'USD' // Is there an option here we need to pass in order to get the right price? 
    })
    .then((collection) => {
        // do something
    });

Or do we need to use the graphql API instead and move away from the the buy sdk?

Thanks

sblackstone commented 2 years ago

I am also looking for guidance on this issue - can we issue the raw graphql query for creating the cart and then use the rest of the API as is?

sjelfull commented 2 years ago

You have to use raw GraphQL queries for all calls, since things like line items won't be fetched in the correct context without continuing to specify the inContext directive.

Related to #884