How to add a size attribute to a listing in the marketplace tutorial?

Hello, I have successfully completed the marketplace tutorial, and everything appears to be working as it should, however I would like to sell t-shirts within my marketplace. T-shirts come in various sizes, so I'm a little confused as to how I could setup a size attribute for t-shirt listings. Any help on this subject would greatly be appreciated.

Posted over 4 years ago by Chris
Posted over 4 years ago by Alex Yang

It really depends on how you want to implement it. The way I would approach it is to add a 'quantity' field to your Listing table for each size of T-shirt you're offering, so 'xs_quantity', 's_quantity', 'm_quantity', etc. This will allow sellers to record their available inventory for each size. Next, you'll need to add a 'size' field to your Order table as well. Finally, make sure you think through each of the ripple effects. For example, when a large T-shirt is sold, the available inventory for that listing should decrease by 1. When there are zero available shirts in a particular size, the view page must indicate that they're sold out. Hope that helps!

Posted over 4 years ago by Chris

Thanks for the reply, Alex Yang.