Decrementing Product Quantity

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

Get hands-on with 1200+ tech skills courses.