Shopify Buy Button via JS — Cart shows wrong currency(通过JS购物按钮购物-购物车显示错误的货币)
问题描述
我已经通过Buy Button JS Library集成了Shopify。
一切正常,但是购物车显示了错误的货币(它显示的是美元而不是欧元)。
我已经通过Shopify Admin Dashboard(位于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方面的错误,但我想出了如何克服它的方法。
我已经向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购物按钮购物-购物车显示错误的货币的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:通过JS购物按钮购物-购物车显示错误的货币
基础教程推荐
- 最佳动态 JavaScript/JQuery 网格 2022-01-01
- 使用 jQuery 在悬停时交换 DIV 类 2022-01-01
- HTML5 画布调整为父级 2022-01-01
- 当木偶师打开Chrome时,不能使用Chrome扩展 2022-01-01
- 在 Javascript 中使用 Fetch API 上传文件并显示进度 2022-01-01
- 带角度的选项卡:仅使用 $http 在单击时加载选项卡 2022-01-01
- 即使每次插入第一个输入的值不同,第二个输入仍显示相同的输入值 2022-01-01
- 逻辑运算符 ||在 javascript 中,0 代表 Boolean false? 2022-01-01
- 从快速中间件中排除路由 2022-01-01
- CORS:当凭据标志为真时,无法在 Access-Control-Allow-Origin 中使用通配符 2022-01-01
