#LUKE-checkout

1 messages ยท Page 1 of 1 (latest)

golden prairie
#

Hello! Starting up a thread for you

#

I don't believe there's a great way to do this - is there any way for you to use a one-time price with an exisiting product instead of a one-time product?

grizzled canopy
#

the problem is that depending on the quantity the price decreases, I don't see any way to do this using a one-time price

#

just using a subscription it seems to be possible

#

currect me if I'm wrong ๐Ÿ˜„

#

Basically I would need Volume Pricing I guess

golden prairie
#

Can you clarify "depending on the quantity the price decreases"

grizzled canopy
#

so for example if a customer wants to purchase 5 units of a product it would cost 10โ‚ฌ per unit. If he wants to buy 20 units the price decreases to 8โ‚ฌ

#

per unit

#

I guess this would be the 'Volume Pricing' option

#

but as far as I can see it's only possible with a subscription

golden prairie
#

Gotcha - yeah tiered pricing is only doable with recurring prices. How are you correcting for this with one-time products though?

grizzled canopy
#

I'm using a one-time product along with a one-time price, the price in cents per unit is declared in our database

#
stripe_session = stripe.checkout.Session.create(
                    success_url="https://example.com/thankyou",
                    cancel_url="https://example.com/cancel",
                    line_items=[
                        {
                            "price_data": {
                                "currency": "eur",
                                "product_data": {
                                    "name": f"{amount} x {selected_variant_info['variantName']}",
                                },
                                "unit_amount": unit_amount,
                                "tax_behavior": "inclusive"
                            },
                            "quantity": amount,
                            "adjustable_quantity": {
                                "enabled": False
                            },
                        },
                    ],
                    mode="payment",
                    automatic_tax={
                        'enabled': True,
                    },
                    billing_address_collection= 'required',
                    allow_promotion_codes=True,
                    metadata=metadata
                )
#

this is the code for creating the session, it might be easier to understand than describing it ๐Ÿ˜„

golden prairie
#

Are you working with a set number of variants? You could create a Product for each variant and pass those in as product instead of setting product_data

grizzled canopy
#

that's actually an amazing idea

#

I will try it and let you know

#

but it should work I guess

golden prairie
#

๐Ÿ‘ that'll allow you to configure coupons to only work with certain products and should get you what you want

grizzled canopy
#

is there a way to do this while still setting a custom product name like above?

#

I mean this part: "name": f"{amount} x {selected_variant_info['variantName']}",

#

Okay never mind it's not possible

#

but still this should be a good workaround for my problem thanks ๐Ÿ™‚

golden prairie
#

Yeah you lose the ability to customize the name

grizzled canopy
#

Okay well that's not a big deal, thank you so much for your help. You saved me a lot of work ๐Ÿ™‚