Here is the basic flow of how inventory calculations work in Version 1.3+
Product Page Calendar #
1. On the product page there is an ajax request that gets the inventory available per day and appends it to the calendar. If all inventory is reserved than that day is disabled. See app/code/community/ITwebexperts/Payperrentals/controllers/AjaxController.php where it makes the call to getBookedQtyForProducts()
2. In the app/code/community/ITwebexperts/Payperrentals/Helpers/Inventory.php getBookedQtyForProducts() returns the inventory_serialized array if we are not in a quote or completes the inventory_serialized array with the quote ones (quotes are items in a shopping cart usually but not completed in an order yet). inventory_serialized is a product EAV field that stores by date how many quantity are available.
3. On order completion, an observer app/code/community/ITwebexperts/Payperrentals/Model/Observer.php function reserveInventory() is called, which in turn calls app/code/community/ITwebexperts/Payperrentals/Helper/Data.php reserveOrder, which then calls app/code/community/ITwebexperts/Payperrentals/Helper/Inventory.php updateInventory() function which updates the inventory_serialized EAV field.
Inventory Helper updateInventory() Function #
1. calls getAllBookedQtyForProduct which does the filtering of reservation orders for specific products
2. getAllBookedQtyForProduct calls getBooked which creates the actual booked array for every date.
3. saves result to inventory_serialized
Using Events To Modify Inventory #
You will notice that in the getQuantity and getBooked functions there are events dispatched that allow you to modify the returned inventory levels. You can use this with observers to modify your inventory levels dynamically.