In this episode, we're kicking off a mini-series all about the order creation process in our project. We're going to focus on handling everything that needs to happen when a user places an order—setting up our database models and structure. No payment handling just yet—we'll get to that later!
Here's what we do:
Order
model and its migration. You’ll see how we choose the different fields it needs, like a UUID (for easy referencing, especially for guest checkouts), linking the order to a user if logged in, or just storing an email if not.placed_at
, packaged_at
, and shipped_at
) so the order progress can be tracked and notifications can be sent at each stage.placed_at
timestamp when an order is created. We specify fillable fields and set up casting for our new timestamp columns.By the end, we’re all set up to create an order with all the needed details, both for guests and logged-in users. In the next episode, we’ll move on to actually triggering this when the checkout button is clicked!