Feature #9840
openworking on e-commerce ui related and functionlity
Subtasks
Related issues
Updated by Karthik Palakonda 18 days ago
- Due date set to 07/16/2026
- Status changed from New to In Progress
- % Done changed from 0 to 100
Updated by Karthik Palakonda 18 days ago
Problem: When a customer buys a product and completes payment, the product quantity was not reducing in the database. So even after buying, the product still showed "Add to Cart" instead of "Sold Out."
Why it happened: The system uses a concept called "Stock Batches" — when products are added through vendor purchases, they are tracked in batches. The inventory deduction logic was written to only work with these batches.
However, the product "pavan" was added directly to inventory without going through any vendor purchase or batch process. So the system had zero batch records for that product.
When payment was completed, the backend tried to find stock batches for the product, found none, and simply returned without doing anything. The product quantity in the database was never reduced.
Where the bug was: Backend file — orderInventory.service.js. The function consumeOrderInventory called consumeStockBatchService. That service returned a flag called fallbackNeeded: true when no batches were found — meaning "handle the deduction yourself." But the calling code was not checking this flag, so no deduction happened at all.
What was fixed: Added a check — if no stock batches exist for a product, directly subtract the purchased quantity from the product's quantity field in the database.
Secondary fix: The product card on the frontend was also showing "Add to Cart" text even when quantity was zero. Changed it to show "Sold Out" text instead.
Updated by Karthik Palakonda 18 days ago
- Status changed from In Progress to Resolved