723 viewsMern Amazona
0 Comments

Love your tutorials and im learning a lot! I really want to learn how we can add sizing and color options to the shopping cart. From what I researched online we may need a unique ID but I can not find out how to implement it into the shopping cart project you posted.

Bassir Changed status to publish November 26, 2023

hello there,
thanks for your interest.
product variants size color
it is a big feature and I have a plan to implement it like this:

in product model add this:

<code>items: [
     {
       price: Number,
       size: String,
       color: String,
       countInStock: Number,
       isDefault: Boolean,
     },
   ],
   defaultItem: {
     price: Number,
     size: String,
     color: String,
     countInStock: Number,
   },
</code>

and handle it in the product edit screen. for listing price use the default item

instead of product.price use product.defaultItem.price and etc.

Bassir Answered question October 12, 2022