通过JS购物按钮购物-购物车显示错误的货币 [英] Shopify Buy Button via JS — Cart shows wrong currency

查看:23
本文介绍了通过JS购物按钮购物-购物车显示错误的货币的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经通过Buy Button JS Library集成了Shopify。 一切正常,但是购物车显示了错误的货币(它显示的是美元而不是欧元)。 我已经通过Shopify Admin Dashboard(位于https://domain.myshopify.com/admin)正确设置了所有内容。商店的主要币种设置为EURas mentioned in the docs可以通过cart.text.currency参数设置币种。我这么做了,但什么也改变不了。这是错误吗?

到目前为止我的JS代码:

<script src="//sdks.shopifycdn.com/buy-button/1.0.0/buybutton.js"></script>
<script>
var client = ShopifyBuy.buildClient({
  domain: 'domain.myshopify.com',
  storefrontAccessToken: '2b3xxxxxxxxjh5', // previously apiKey, now deprecated
});

ui = ShopifyBuy.UI.init(client);

ui.createComponent('product', {
  id: 23xxxxxx56,
  node: document.getElementById('my-product'),
  options: {
    "product": {
      "iframe": true
    },
    toggle: {
      "iframe": true
    },
    cart: {
      "iframe": true,
      "popup": false,
      "text": {
        "title": 'Warenkorb',
        "empty": 'Dein Warenkorb ist leer.',
        "button": 'Jetzt bestellen',
        "total": 'Gesamt',
        "currency": 'EUR',
     }
  }
});
</script>

但如附件中所示,购物车仍显示$,而不是


编辑

我认为这是Shopify方面的错误,但我想出了如何克服它的方法。

我已经向createComponent函数添加了moneyFormat选项,它覆盖所有声明的货币指示。

shopifyUI.createComponent('product', {
  id: 23xxxxxx56,
  node: document.getElementById('shopify-button-buy-regular'),
  moneyFormat: '€{{amount_no_decimals}}',
  options: shopifyOptions
});

推荐答案

您需要将货币格式添加到组件中,如下所示:

ui.createComponent('product', {
  id: 23xxxxxx56,
  node: document.getElementById('my-product'),
  moneyFormat: '%E2%82%AC%7B%7Bamount%7D%7D',
...

以上代码将为您提供欧元(欧元)符号。

这篇关于通过JS购物按钮购物-购物车显示错误的货币的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆