Description:
Added the ability to view the current quantity available of the product on the product detail page. This is the original quantity available minus the amount that have appeared on a closed order. I did this by adding the following to the productDetail view: A query to count how many times that product id appears on a ProductOrder join model where the oder id has a payment id (meaning it's complete). I then subtract that amount from the product quantity from the original product query and set that to a variable inventory, and pass that as context to the template.
Steps to Test:
Checkout to my branch jb-product-quantity
Go to localhost.8000/products/1 (or any product id you have)
The quantity available should be the total available minus the amount that have been ordered. If you really want to be sure, you can put a product on an order, complete the order with a payment type, and see if the quantity decreases by 1.
Description: Added the ability to view the current quantity available of the product on the product detail page. This is the original quantity available minus the amount that have appeared on a closed order. I did this by adding the following to the productDetail view: A query to count how many times that product id appears on a ProductOrder join model where the oder id has a payment id (meaning it's complete). I then subtract that amount from the product quantity from the original product query and set that to a variable inventory, and pass that as context to the template.
Steps to Test: Checkout to my branch jb-product-quantity Go to localhost.8000/products/1 (or any product id you have) The quantity available should be the total available minus the amount that have been ordered. If you really want to be sure, you can put a product on an order, complete the order with a payment type, and see if the quantity decreases by 1.
Link to Ticket #37 View Updated Product Inventory