Skip to content

API check promotions available for customer before it gets added to the cart ? #228

Discussion options

You must be logged in to vote

@balanh-development when you pass $promotions: true to a cart or order, it will automatically calculate which promotions can be applied and add them to the record. You could use that functionality and remove them immediately if you want.

Something like this:

const cart = await swell.put('/carts/{id}', {
  id: ...,
  $promotions: true,
})

if (cart.promotions?.results) {
  // do something with promotions
  for (const promo of cart.promotions.results) {
    ...
  }
}

// remove promotions from the cart
const cart = await swell.put('/carts/{id}', { id: ..., promotion_ids: null })

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by logeshswell
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Help
2 participants