I am building an ecommerce site that sells products and services. If someone buys a product (e.g. t-shirt) then I need both their Shipping Address + Billing Address.
However, if they are buying a service (e.g. online subscription) then I only need a Billing Address.
It would be confusing to to customers if the checkout process starts off asking someone for a Shipping Address when it isn’t required. And so I am wondering how to code my website so it is flexible regardless of what is being purchased.
Maybe I could put an attribute in the backend Product table called “isShippable” and if that is checked and their shopping cart has onr or more “isShippable” items, then I would need to have my checkout form ask for a Shipping Address?
Otherwise, the checkout form would just ask for a Billing Address by default.
So you agree with my logic that “isShippable” is an attribute of a Product and my Checkout module can just scan the list of Products in the shopping cart and then determine which addresses to ask for?
Yes, a boolean flag sounds like a simple solution to your problem. There are much complex ways of doing it but if you are designing something specific that is probably fine. If you are designing a more generic system product types might be more appropriate. For example, a product type of downloadable or even going further separate fulfillment strategies for products. Shipping a physical product is the the fullfilment process and fulfillment can differ greatly across products, vendors, distributors, etc. It depends on how flexible you want to make the platform.