简体   繁体   English

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

[英]Shopify Buy Button via JS — Cart shows wrong currency

I've integrated Shopify via the Buy Button JS Library .我已经通过Buy Button JS Library集成了 Shopify。 Everythings works correctly, but the cart shows the wrong currency (it shows $ instead of €).一切正常,但购物车显示的货币错误(显示的是 $ 而不是 €)。 I've set up everything correctly via the Shopify Admin Dashboard (at https://domain.myshopify.com/admin ).我已通过 Shopify 管理仪表板(位于https://domain.myshopify.com/admin )正确设置了所有内容。 The main currency of the store is set to EUR , and, as mentioned in the docs , I can set the currency via the cart.text.currency parameter.商店的主要货币设置为EUR ,并且如文档中所述,我可以通过cart.text.currency参数设置货币。 I did this, but it changes nothing.我这样做了,但它没有任何改变。 Is this a bug?这是一个错误吗?

My JS code so far:到目前为止我的 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>

But as visible in the attached image, the cart still shows $ instead of .但如附图所示,购物车仍显示$而不是

Shopify 购物车显示错误的货币


EDIT编辑

I think it's a bug on the side of Shopify, but I figured out how to overcome it.我认为这是 Shopify 方面的一个错误,但我想出了如何克服它。

I've added the moneyFormat option to my createComponent function, which overrides all declared currency indications.我已经在我的createComponent函数中添加了moneyFormat选项,它覆盖了所有声明的货币指示。

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

Check to ensure that the theme code displaying the cart respects currency settings.检查以确保显示购物车的主题代码符合货币设置。 Your theme may be showing the dollar symbol simply due to the theme code not respecting currency.您的主题可能只是因为主题代码不尊重货币而显示美元符号。 The Liquid filter money_with_currency is usually used for this purpose. Liquid 过滤器 money_with_currency 通常用于此目的。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM