Our cart is now full with the correct number of the desired products, so it's now time to place our order. For that, we need to call another controller—OrdersController.
The following two tables are responsible for the ordering process:
- Orders: This stores the shipping address details, customer details, order status, and so on
- OrdersProducts: This stores the products added to the cart, their price, and their quantity
The Orders class is generated by the scaffolding we did initially, which contains all the necessary information. Let's generate the controller with this class. Follow the same process to generate the controller as we did for ProductsController, ProductsdetailsController, and CartsController.
The model and controller class can be found in the GitHub repository.
Now it's time to call the POST action of OrdersController to save...