buy-button-js icon indicating copy to clipboard operation
buy-button-js copied to clipboard

Parameter to set the shopify checkout language

Open Zanz2 opened this issue 5 years ago • 2 comments

First of all, its projects like this that make me really appreciate javascript, I absolutely love it.

But as a developer and part store owner, I imagine the shopify support is just creating tickets that the dev team has 10000 of in the backlog? Thats why I came here directly to ask the question.

Im wondering whether there are any plans to integrate a language parameter to the javascript object (the create component thing), where the attribute would be set to like "en-us, de-ger " etc to determine which language the checkout is in? As of now, this isnt possible, and it makes having multilingual sites with one shopify portal a nightmare.

Zanz2 avatar Jun 28 '20 20:06 Zanz2

Yes please, we need this!

JakobG-dev avatar Aug 18 '20 14:08 JakobG-dev

You can set the checkout language like this:

var shopifyClient = ShopifyBuy.buildClient({});
var shopifyBuyUI = ShopifyBuy.UI.init(shopifyClient);

shopifyBuyUI.createComponent("", {
  options: {
    cart: {
      events: {
        beforeInit: function (cart) {
          var actualOpen = cart.checkout.open;
          cart.checkout.open = function (url) {
            var newUrl = new URL(url);
            newUrl.searchParams.set("locale", "es-UY");
            actualOpen.call(this, newUrl.toString());
          };
        }
      }
    }
  }
});

gabrielmaldi avatar Sep 24 '20 14:09 gabrielmaldi