#ziwengames_checkout-discounts-dynamic-promos
1 messages ยท Page 1 of 1 (latest)
๐ Welcome to your new thread!
โฒ๏ธ We'll be here soon! Typically we respond in a few minutes, but sometimes we might take a bit longer if the server is busy or if you have a particularly tricky question.
โฑ๏ธ We close idle threads, which makes them read-only. Once a thread is closed it won't be reopened, but you can always start a new thread if you have another question.
๐ This thread will always be available, even after it's closed. You can find it again using Discord's search, or you can save this link: https://discord.com/channels/841573134531821608/1346168499881639949
๐ Have more to share? Add more details, code, screenshots, videos, etc. below.
const session = await stripe.checkout.sessions.create({ line_items: [ { price: subscriptionPriceId, quantity: 1 }, { price: dnaKitId, quantity: 1 } ], automatic_tax: { enabled: true }, allow_promotion_codes: promoId ? undefined : true, discounts: promoId ? [{ promotion_code: promoId }] : undefined, mode: 'subscription', ui_mode: 'embedded', return_url: process.env.NODE_ENV === 'development' ? 'http://localhost:3000/signup/thank-you?session_id={CHECKOUT_SESSION_ID}&email=' + encodeURIComponent(email) : `https://${req.headers.host}/signup/thank-you?session_id={CHECKOUT_SESSION_ID}&email=` + encodeURIComponent(email), customer_email: email, custom_text: { // submit: { message: 'Testing submit' }, // after_submit: { message: 'Testing after submit' }, terms_of_service_acceptance: { message: 'I agree to the [Terms of service](https://mynucleus.com/terms-of-service) and [Privacy policy](https://mynucleus.com/privacy-policy), including [Cookie policy](https://arc.net/l/quote/vkqlsyni).' } }, consent_collection: { terms_of_service: 'required' }, subscription_data: { metadata: { source: 'guest-checkout', firstName, lastName, dateOfBirth, addressLine1, addressLine2, city, state, country, zipCode, phone, utm_source, utm_medium, utm_campaign } } })
Hi ๐
So you include the Promo code in the Checkout Session creation and that disables editing of the promo field, right?
Something I tried: setting
allow_promotion_codes: true
but I get an error when also applying the discount:
You may only specify one of these parameters: allow_promotion_codes, discounts.
yes!
Correct. If you provide the discounts then the Customer does not get to modify them.
But if you do not include a discounts parameter but specify instead allow_promotion_codes: true, then the customer can enter promo codes
Honestly that does strike me as a little silly now that you mention it.
Can you describe your user case more thoroughly?
Yes, we're exploring an option where we want to auto apply a promo-code for all users. But if they know a different code that has a higher discount, we want to let them use that one instead.
Okay. That isn't available currently but I can flag it as a feature request
ok great, thank you!
and yea I don't want to make any assumptions on the implementation, but I don't really see it that different from a customer being able to change the code themselves (without an initial code auto-applied)
Okay, feedback filed! I cannot guarantee if/when it will get implemented but you can track changes we make to our products in our Changelog
ok thanks!
I think that use case makes perfect sense and hopefully it'll be an easy change.