shopify - 向 Shopify ajax 购物车添加折扣

标签 shopify shopify-template shopify-api

我正在使用 Shopify Ajax Cart Api并尝试添加有折扣的商品。有谁知道这是否可能?我知道我可以以折扣价添加商品,但这不是我想要的体验。

当前请求如下所示:

const order = []

addToCart() {
        if(this.unlimitedAdded === true){
          console.log("pushing order w/ unlimited")
          this.order.push({
            quantity: this.quantity,
            id: this.productID,
      },
      {
        quantity: 1,
        id: 31095169613901
      })
      this.$store.commit('cart/add', this.unlimited)
        } else {
          this.order.push({
            quantity: this.quantity,
            id: this.productID,
            })
        }
      this.$store.commit('cart/add', this.planName)
      if (window.ShopifyAnalytics) {
        console.log('Firing Shopify track data from Nuxt')
        window.ShopifyAnalytics.lib.track(
            'monorail://trekkie_storefront_added_product/1.0',
            {
              'currency': 'USD',
              'productId': this.productID,
              'name': this.planName,
              'price': this.salePrice,
              'brand': 'Shine Bathroom',
              'variant': this.planName,
              'category': 'Bathroom Assistant',
              'nonInteraction': true,
            },
        )
      }

      console.log(`Adding ${this.productID} to cart. Quantity: ${this.quantity}`)
      this.$axios.post('/cart/add.js', {items: this.order},)
      .then((response) => {
        console.log(response)
        window.location.href = '/pages/direct-checkout'
      }, (error) => {
        console.log(error)
      })
    }

理想情况下,我想发送一个带有数量和 ID 的折扣代码,但我在他们的文档中没有看到这个特定资源的任何地方。

谢谢!

最佳答案

关于shopify - 向 Shopify ajax 购物车添加折扣,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/66813411/

相关文章:

graphql - 如何根据在 python 中动态给出的多个不同标签获取 shopify 产品?

node.js - 使用 shopify-api-node 从本地计算机上传文件(图像)

javascript - 通过 postman/Shopify API 创建 Shopify 订单

不使用 Hosted Payment SDK 的 Shopify 自定义支付网关

javascript - lodash 过滤器在 Shopify 订单的多维数组中找不到值

Shopify 将多个具有不同属性的产品添加到购物车

javascript - Shopify 触发变体选择功能,但不覆盖现有功能

Shopify Plus 启用 Checkout.liquid

html - 产品页面 - 分屏滚动

Shopify 在部分块中选择 SVG