向Shopify ajax购物车添加折扣

向Shopify ajax购物车添加折扣,shopify,shopify-template,shopify-api,Shopify,Shopify Template,Shopify Api,我正在使用Shopify并尝试添加一个折扣商品。有人知道这是否可能吗?我知道我可以以折扣价添加商品,但这不是我想要的体验 当前请求如下所示: const order = [] addToCart() { if(this.unlimitedAdded === true){ console.log("pushing order w/ unlimited") this.order.push({ qua

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

当前请求如下所示:

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 frontend上的checkout外,无法在任何其他页面上添加折扣代码。需要检查API和处理它的应用程序。AJAX API不值得这么做。好吧,我也这么认为。谢谢,我想我只需要使用折扣率的产品。是的,您可以使用折扣产品或自动折扣在结账时自动应用折扣。