Closed drewroberts closed 3 years ago
Cart Item could have sellable_type
with sellable_id
referencing to model that must have Sellable interface.
Yes, that is in issue #28 and will also be included in Order Item #33
I'm leaning towards something close - but slightly different. The root of sellability is a product, the root table of which has very basic info (maybe just "sku") along with the morph to the sellable thing (physical product, booking, etc). The product id is then used by cart item, order item, etc. More details in notion soon.
(edit -- keeping the morph in the product realm in exchange for a product id prevents having to propagate the morph fields every where you're dealing it later on).
After some experimentation, I think it may be too far a leap to move immediately to catalog | product | inventory concepts. So, it is now looking like CartItem (and OrderItem) will contain a morph to sellable
. The transition from CartItem => OrderItem will allow for the CartItem sellable to be replaced with a different OrderItem sellable, but it won't require it. This could allow for one type of model/DB table to be used during checkout and a different model/DB table to handle things after the order is created.
Thank you. I like this approach. Let's move forward with it.
Sellable Trait - Issue #28
Added as a morph to a model implementing the Sellable
interface.
https://github.com/tipoff/checkout/blob/main/database/migrations/2020_05_05_060000_create_cart_items_table.php https://github.com/tipoff/checkout/blob/main/src/Models/CartItem.php
Sellable Items that belong to a Cart #34