#Explore variations by options split

2 messages · Page 1 of 1 (latest)

plush timber
#

I have a question, is it possible to explore each option of a variation on product ?

The endpoint give :
variations :{
'1 part / green',
'2 part / green',
'1 part / blue',
'2 part / blue'
}

But I would like 2 selects (one part and one color) in my html.
Not 1 select ( part/color). I don't have idea how to do that. Maybe someone have idea or example ? Thank you so much

blazing yoke
#

You can take a look at one of our starters, they both split option selections so you select each option individually and then returns the correct variant based on the combination of options. Here it is in the Next starter:

Template component -> https://github.com/medusajs/nextjs-starter-medusa/blob/main/src/modules/products/components/product-actions/index.tsx

Hook that holds the logic for selecting options -> https://github.com/medusajs/nextjs-starter-medusa/blob/018acb925465c68f88d70104803af30cb63c131f/src/lib/context/product-context.tsx#L171

Option renderer -> https://github.com/medusajs/nextjs-starter-medusa/blob/main/src/modules/products/components/option-select/index.tsx