Shopify脚本中的预填充数量

时间:2018-11-06 02:49:40

标签: php e-commerce shopify-javascript-buy-sdk

我有一个网站使用的表单,访客可以选择“成员/成员+ 1位访客/成员+ 2位访客等...”

会员价格为10美元,每位客人额外支付10美元。

该表单将重定向到网站上相应的“购买页面”。

我们使用不同的“产品”来区分成员,成员+1,成员+2等...

我想知道是否可以将“购买”按钮配置为自动添加数量,以便我们可以在Shopify中使用1种产品来使报告更加整洁。我知道我可以在“添加到购物车”旁边有一个“数量”按钮,但是我不想让访问者来选择并支付适当数量的客人。

    <div id='product-component-9e4fc19b90c'></div>
    <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: 'DOMAIN.myshopify.com',
          storefrontAccessToken: 'API-KEY',
        });

        ShopifyBuy.UI.onReady(client).then(function (ui) {
          ui.createComponent('product', {
            id: [1445220614189],
            node: document.getElementById('product-component-9e4fc19b90c'),
            moneyFormat: '%24%7B%7Bamount%7D%7D',
            options: {
  "product": {
    "variantId": "all",
    "width": "240px",
    "contents": {
      "imgWithCarousel": false,
      "variantTitle": false,
      "description": false,
      "buttonWithQuantity": false,
      "quantity": true

    },
    "styles": {
      "product": {
        "@media (min-width: 601px)": {
          "max-width": "100%",
          "margin-left": "0",
          "margin-bottom": "50px"
        }
      },
      "compareAt": {
        "font-size": "12px"
      }
    }
  },
  "cart": {
    "contents": {
      "button": true
    },
    "styles": {
      "footer": {
        "background-color": "#ffffff"
      }
    }
  },
  "modalProduct": {
    "contents": {
      "img": false,
      "imgWithCarousel": true,
      "variantTitle": false,
      "buttonWithQuantity": true,
      "button": false,
      "quantity": false
    },
    "styles": {
      "product": {
        "@media (min-width: 601px)": {
          "max-width": "100%",
          "margin-left": "0px",
          "margin-bottom": "0px"
        }
      }
    }
  },
  "productSet": {
    "styles": {
      "products": {
        "@media (min-width: 601px)": {
          "margin-left": "-20px"
        }
      }
    }
  }
}
          });
        });
      }
    })();
    /*]]>*/
    </script>

Shopify screenshot

0 个答案:

没有答案