I need to update the inventory amounts available after an order has been placed.
This is in a repeat group with joined data. Obviously not a php programmer, but trying to learn. I've tried the basic following code in a variety of different ways but can't seem to update the inventory. Any help will be much appreciated!
I should add, I'm using this file to run php on my Form onAfterProcess.
This is in a repeat group with joined data. Obviously not a php programmer, but trying to learn. I've tried the basic following code in a variety of different ways but can't seem to update the inventory. Any help will be much appreciated!
Code:
<?php
$repeatcount = $formModel->_formdata['fabrik_repeat_group'][14];
for($i=0; $i<$repeatcount; $i++ )
{
$batchNum = $formModel->_formdata['join'][26]['order_items___batch_id'][$i];
$ordQty = $formModel->_formdata['join'][26]['order_items___orditems_qty'][$i];
$db =& JFactory::getDbo();
$query = "UPDATE batch SET aval_cases = aval_cases - '$ordQty' WHERE batch_id = '$batchNum'";
$db->setQuery($query);
$db->query();
}
?>
I should add, I'm using this file to run php on my Form onAfterProcess.