Combining an onchange event, for product lookup, with inventory control?
We have an onchange event on our product detail (add to cart) page which is linked to a separate ajax file, pricelookup.php. The onchange event allows users to make selections from drop-down menus for each product (colour, etc) and then updates the product code and price on the page accordingly.
Initially I wanted to hide product variables from the drop-down menus, should that product be marked as hidden from the website in my clients admin however, with help from Ray and yourself Jason, we changed this to display a warning message and to hide the Add to Cart button when the corresponding unavailable selection was made by the customer. Great!
However, products that were marked as hidden were still being able to be selected so I added "AND LEDdelete = 2" (2 = No) to the SELECT statement on the pricelookup.php page and, would you believe it, it worked! (a first for me on this project)
So, now, I'm faced with trying to do the same thing but have it respond to the inventory listed for each product which is where I'm stuck.
Following the inventory control tutorials I've got the following code sorted out, and it's working correctly in my clients admin area.
LEDstock - (SELECT Coalesce(SUM(LEDDetailQuantity),0) FROM LEDorder INNER JOIN LEDdetail ON LEDdetail.LEDDetailOrderID = LEDorder.LEDOrderID WHERE LEDOrderDate > LEDProductUpdateDate AND LEDDetailLEDid = LEDid) AS RemainingInventory
My question...
Can I add the above code to the recordset on the pricelookup.php ajax file and, from there, how do I change the onchange event so that it also detects when stock level (RemainingInventory) is listed as 0?
If that's not the correct approach I'd appreciate guidance on how best to acheive this.
Thank you
NJ