#joe.i

1 messages ยท Page 1 of 1 (latest)

stuck solarBOT
serene bobcat
#

You may add the description to the product, so that the size information can be shown in the checkout page: https://stripe.com/docs/api/checkout/sessions/create#create_checkout_session-line_items-price_data-product_data-description

For internal size referencing, this can be sent through metadata field of checkout session: https://stripe.com/docs/api/checkout/sessions/create#create_checkout_session-metadata

crimson sable
#

so If I were using node.js the metadata key2pair would be like `sizes`: {selectedSize}?

serene bobcat
#

It'll be:

metadata: {
  'size': 'M'
},
crimson sable
#

but I dont want it to be static sizes, I want it to be like if someone chose that size, it shows in the metadata as that size they chose, because there would be more than one size.

serene bobcat
#

Yup! You can set it as the input parameter for the value. The above code is just an example code of how the hard-coded metadata will be like. Dynamic variable can be used

crimson sable
#

ok thank you!

serene bobcat
#

No problem! Happy to help ๐Ÿ˜„

crimson sable
#

quick question, really sorry to interrupt but I would put in the dynamic variable like {selectedsize} right? not like `{selectedsize}`

serene bobcat
#

In node, it should just be the variable name without including any bracket.

For example,

metadata: {
  'size': selectedsize
},
crimson sable
#

thank you, but I think im doing something wrong, could I show you a two pieces of my code? I am really stuck.

serene bobcat
#

Sure!

crimson sable
#

ok, I am using a library for a hook to stripe called "use-shopping-cart" thats why it might look a little different. neverless, this is my product.js ``` const addToCart = () => {
const item = {
...product,
'size': selectedSize,
};

const metadata = {
  'size': selectedSize, // Use the selected size as dynamic metadata
};

addItem(item, { count: quantity, product_metadata: metadata });
setQuantity(1);

};and this is my other page containing what it sends the cart and holds it there: addItem: (
product: Product,
options?: {
count: number
price_metadata?: { [propName: string]: any }
product_metadata?: { [propName: string]: any }
}
) => undefinedthen it will send it to stripe with this (still on the page that is not the product.js): /**

  • Redirects customers to the Stripe checkout. Works in both
  • CheckoutSession and ClientOnly mode.
  • @param sessionId Used in CheckoutSession mode, it is the ID of the
  •              checkout session created by your server/serverless function.
    
  • @returns Nothing or an error wrapped in a promise if an error occurred
    */
    redirectToCheckout: (sessionId?: string) => Promise<any>```
serene bobcat
#

What is the issue or error you're facing?

#

I don't see any code related to Checkout Session creation here

crimson sable
#

I dont see one either in my code, so idk how it is working

#

its a different library tho so ima ask them instead, thanks for trying tho

serene bobcat
#

Do you use third-party or direct Stripe integration?