Create Orders

It’s now time to allow the user to place some orders. This will add complexity to the application, but don’t worry. We’ll do it all one step at a time. Before launching this feature, let’s take the time to think about the implications of creating an order in the application. There are a few things to consider:

  • How to manage out-of-stock products.
  • How to handle a decrease in product inventory.
  • How to validate order placement to ensure that there are enough products at the time of the order placement.

It seems like there’s still a lot to do but we are closer than it looks. For now, let’s keep it simple and assume that we still have enough products to place any number of orders. We are just concerned about the server’s response at the moment.

Remember that, for the Order model, we need the following three things:

  • The total amount for the order.
  • The user who placed the order.
  • The products included in the order.

Get hands-on with 1200+ tech skills courses.