How really bad do you want to DIY this? There are some really excellent open source and commercial ecommerce packages that well most likely have what you need and then some. Then you can spend more time on design and configuration insted of learning and coding. Check out OS Commerce I haven't used it in a live site myself but have looked it over. It has features and wide user base.