通过JS的Shopify购买按钮-购物车显示错误的货币

时间:2019-12-18 14:00:29

标签: javascript shopify shopify-app shopify-javascript-buy-sdk

我已经通过Buy Button JS Library集成了Shopify。 一切正常,但购物车显示错误的货币(显示$而不是€)。 我已经通过Shopify管理控制台(位于https://domain.myshopify.com/admin上正确设置了所有内容。商店的主要货币设置为EUR,并且as 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 Cart displaying wrong currency


编辑

我认为这是Shopify的错误,但我想出了解决方法。

我在moneyFormat函数中添加了createComponent选项,该选项将覆盖所有声明的货币指示。

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

1 个答案:

答案 0 :(得分:0)

检查以确保显示购物车的主题代码遵守货币设置。您的主题可能只是由于主题代码不尊重货币而显示美元符号。液体过滤器money_with_currency通常用于此目的。