I'm using the Shopify Ajax Cart Api and trying to add an item with a discount. Does anyone know if this is possible? I know I can just add an item at the discounted price, but that's not the experience I want.
Current request looks like this:
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)
})
}
Ideally I would like to send a discount code with the quantity and id, but I don't see that anywhere in their documentation for this specific resource.
Thanks!