Decrementing Product Quantity
Learn how to keep a record of products' stock.
This chapter will take care of some validations on the Order model that make sure it is placeable. We will think about the following concerns:
- How to decrement the current product quantity when an order is placed.
- What happens when products are not available?
We’ll probably need to update the JSON output for the orders a little, but we can save that for now. Let’s dive in and get coding.
Add quantity
attribute to products
Define and run migration
We will update the product quantity on this first stop to ensure every order will deliver the actual product. Currently, the Product
model ...
Get hands-on with 1400+ tech skills courses.