liquid + js 自定义添加购物车

本文介绍了如何结合Shopify的Ajax API和JavaScript实现自定义购物车功能。通过调用API并指定商品变体的数量和ID,可以将多个商品添加到用户购物车。同时,文章也提到了Shopify的liquid语法在后台配置中的应用。
摘要由CSDN通过智能技术生成

 1.首先结合Shopify提供的Shopify Ajax API来实现;

Shopify Ajax API


<div class="promotionDiscount" data-id="{
  { section.settings.promotionDiscount_id }}">
    <div class="promotionDiscount_conter container">
      <div class="promotionDiscount_title">{
  { section.settings.promotionDiscount_title }}</div>
      <div class="promotionProduct_box">
        {% for block in section.blocks %}
            <div class="promotionProduct_list" >
                <div class="promotion">{
  { block.settings.promotion }}</div>
               {%- render 'product-item', product: block.settings.promotionProduct -%}
                <div class="promotionProduct_list_bottom">
                <div class="promotionProduct_list_num">
                 <button type="button" class="promotion_reduce promotion_icon" disabled >-</button>
                 <input id="promotion_num" class="promotion_num" name="quantity" type="text" value="1">
                 <button type="button" class="promotion_add promotion_icon">+</button>
               </div>
               {% if block.settings.promotionProduct.available == true %}
                 {% if block.settings.method == 'cart' %}
                 <div class="promotionButton promotionButton_cart" data-variants="{
  { block.settings.promotionProduct.variants[0].id }}">
                    {
  { block.settings.button }}
                    <svg
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值