#Ninja man-coupons

1 messages ยท Page 1 of 1 (latest)

grizzled sequoia
hushed trellis
#

Hmm well i just want to add products, and if there is 3 products, then apply a 10% discount to the total price etc

#

You understand what i mean

grizzled sequoia
#

Are you asking how to guarantee that a certain price is always discounted 10%? What are you using to collect payments? Checkout?

hushed trellis
#

No, i want to be able to add like a field to the checkout, like discount: 10% . So when i call this i would just want to specify a discount on the whole price

grizzled sequoia
#

Ahhh gotcha - you just want to be able to discount the full cost of a Checkout Session by 10%?

hushed trellis
#

Yep

grizzled sequoia
#

And do you want this to be like a Promotion code that your customers will enter in the Checkout Session UI, or is this something you want to set when the checkout session is created?

hushed trellis
#

So basically it will work like this:

You add 2 products, then it says, "add 1 more to get a 10% discount on everything" So i want to be able to just set a discount value dynamically.

And if they add 10 products, then they would get 30% discount on everything.

Yeah you get it..

grizzled sequoia
hushed trellis
#

Ahhhh cool! So: I make request to my server, i create that coupon, and then i start the checkout session, and i should pass the coupon, but where do i get the coupon from after i created it?

grizzled sequoia
#

It depends on your integration - if you only need a couple of coupons, then your server could have logic to check how many items are going to be added to the session and hardcode which coupon IDs correspond to the number of items

hushed trellis
#

Alright, is it some way to pre make coupons in the dashboard, and then check in the code like (if 3 items then use this coupon) etc?

scarlet inlet
#

Hi there ๐Ÿ‘‹ taking over for @grizzled sequoia

You can create coupons in the dashboard here: https://dashboard.stripe.com/test/coupons

As for the logic required to check for the items, you would need to perform the check before the API call and then either apply the coupon or not. That should be totally doable

hushed trellis
scarlet inlet
#

That seems like a reasonable way to go. You would want to make sure to store something in your coupon (either via metadata or as a naming convention) in order to make sure you're applying the correct coupon.

#

For example metadata: {product_total: 1} for the coupon that will only apply to single product orders, then metadata: {product_total: 2} for the coupon that will only apply to 2-product orders, etc.

hushed trellis
#

Ahhh okay perfect. And just to make sure, the coupon stuff works for subscriptions right?

scarlet inlet
#

Yup!

hushed trellis
#

Ohh great! I think I will write a few articles about all this once I have made it to help others that wanna implement something similar!