问题描述
使用Shopify购买按钮向网络应用的用户发布免费产品。需要确保用户最多只能订购1件商品。关于如何执行此操作的任何想法?
Shopify扩展程序是不行的,因为购买按钮不会加载它们。还对结帐链接进行了实验,这些链接将无法防止出现双重订单。
以下是“购买”按钮的代码:
<script type="text/javascript">
/*<![CDATA[*/
(function () {
var scriptURL = 'https://sdks.shopifycdn.com/buy-button/latest/buy-button-storefront.min.js';
if (window.ShopifyBuy) {
if (window.ShopifyBuy.UI) {
ShopifyBuyInit();
} else {
loadScript();
}
} else {
loadScript();
}
function loadScript() {
var script = document.createElement('script');
script.async = true;
script.src = scriptURL;
(document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(script);
script.onload = ShopifyBuyInit;
}
function ShopifyBuyInit() {
var client = ShopifyBuy.buildClient({
domain: 'heavysoundlabs.myshopify.com',storefrontAccessToken: '28703a091818546612d47f7c83047f6f',});
ShopifyBuy.UI.onReady(client).then(function (ui) {
ui.createComponent('product',{
id: '4713512665151',node: document.getElementById('product-component-1598466400618'),moneyFormat: '%24%7B%7Bamount%7D%7D',options: {
"product": {
"styles": {
"product": {
"@media (min-width: 601px)": {
"max-width": "calc(25% - 20px)","margin-left": "20px","margin-bottom": "50px"
}
},"title": {
"font-family": "PT Sans,sans-serif","font-weight": "normal"
},"button": {
"font-family": "PT Sans,"font-size": "14px","padding-top": "15px","padding-bottom": "15px",":hover": {
"background-color": "#e3ac00"
},"background-color": "#fcbf00",":focus": {
"background-color": "#e3ac00"
},"padding-left": "14px","padding-right": "14px"
},"quantityInput": {
"font-size": "14px","padding-bottom": "15px"
},"price": {
"font-family": "PT Sans,sans-serif"
},"compareAt": {
"font-family": "PT Sans,"unitPrice": {
"font-family": "PT Sans,sans-serif"
}
},"buttonDestination": "checkout","contents": {
"img": false,"title": false,"price": false
},"text": {
"button": "Get it now!"
},"googleFonts": [
"PT Sans"
]
},"productSet": {
"styles": {
"products": {
"@media (min-width: 601px)": {
"margin-left": "-20px"
}
}
}
},"modalProduct": {
"contents": {
"img": false,"imgWithCarousel": true
},"styles": {
"product": {
"@media (min-width: 601px)": {
"max-width": "100%","margin-left": "0px","margin-bottom": "0px"
}
},"padding-bottom": "15px"
}
},"googleFonts": [
"PT Sans"
],"text": {
"button": "Add to cart"
}
},"option": {
"styles": {
"label": {
"font-family": "PT Sans,"select": {
"font-family": "PT Sans,"cart": {
"styles": {
"button": {
"font-family": "PT Sans,":focus": {
"background-color": "#e3ac00"
}
}
},"text": {
"total": "Subtotal","button": "Checkout"
},"toggle": {
"styles": {
"toggle": {
"font-family": "PT Sans,":focus": {
"background-color": "#e3ac00"
}
},"count": {
"font-size": "14px"
}
},"googleFonts": [
"PT Sans"
]
}
},});
});
}
})();
/*]]>*/
</script>```
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)