theUnforgiven's avatar

Help.... [E-Commerce, multiple items, stock, colors, sizes]

I'm building a ecommerce system and I have clothing items that can be the same item, but with 3/4 different colours, sizes and stock.

I'm struggling to get my head around how I can make this work, to show all colours that have stock then display all the size available for these items that have stock. I also don't know how I should setup the database to allow for this, so any help greatful here.

0 likes
2 replies
d3xt3r's avatar

Any mature e-commerce framework, has this feature. Study their schema. As for your use case, additional stock model could solve the purpose

A very simple example :

table (stocks/varinants)
    - id : primaryKey(SKU)
    - product_id
    - color_id
    - size_id 
    - qty_available
    - price (if applicable)

// then 
product hasMany stocks/variants
1 like
theUnforgiven's avatar

@d3xt3r Thanks for the advice although I ended up it doing it a slightly different way and using joins in the DB facade for easier use.

Please or to participate in this conversation.