tried to do a step by step in an edit but i passed the 7 minutes. ugh. here we go again.
download the order.php file from your admin folder.
find the line:
$db->Execute("update " . TABLE_PRODUCTS . " set products_quantity = '" . $stock_left . "' where products_id = '" . zen_get_prid($this->products[$i]['id']) . "'");
directly below that line, copy and pase the following code:
// kuroi: Begin Stock by Attributes additions
// added to update quantities of products with attributes
$attribute_search = array();
$attribute_stock_left = STOCK_REORDER_LEVEL + 1; // kuroi: prevent false low stock triggers
if(isset($this->products[$i]['attributes']) and sizeof($this->products[$i]['attributes']) >0){
foreach($this->products[$i]['attributes'] as $attributes){
$attribute_search[] = $attributes['value_id'];
}
if(sizeof($attribute_search) > 1){
$attribute_search = 'where options_values_id in ("'.implode('","', $attribute_search).'")';
} else {
$attribute_search = 'where options_values_id="' . $attribute_search[0].'"';
}
$query = 'select products_attributes_id from ' . TABLE_PRODUCTS_ATTRIBUTES . ' ' . $attribute_search .' and products_id="' . zen_get_prid($this->products[$i]['id']) . '" order by products_attributes_id';
$attributes = $db->Execute($query);
$stock_attributes_search = array();
while(!$attributes->EOF){
$stock_attributes_search[] = $attributes->fields['products_attributes_id'];
$attributes->MoveNext();
}
if(sizeof($stock_attributes_search) > 1){
$stock_attributes_search = implode(',', $stock_attributes_search);
} else {
foreach($stock_attributes_search as $attribute_search){
$stock_attributes_search1 = $attribute_search;
}
$stock_attributes_search = $stock_attributes_search1;
}
$get_quantity_query = 'select quantity from ' . TABLE_PRODUCTS_WITH_ATTRIBUTES_STOCK . ' where products_id="' . zen_get_prid($this->products[$i]['id']) . '" and stock_attributes="' . $stock_attributes_search . '"';
$attribute_stock_available = $db->Execute($get_quantity_query);
$attribute_stock_left = $attribute_stock_available->fields['quantity'] - $this->products[$i]['qty'];
$attribute_update_query = 'update ' . TABLE_PRODUCTS_WITH_ATTRIBUTES_STOCK . ' set quantity='.$attribute_stock_left.' where products_id="' . zen_get_prid($this->products[$i]['id']) . '" and stock_attributes="' . $stock_attributes_search . '"';
$db->Execute($attribute_update_query);
}
// kuroi: End Stock by Attribute additions
save the file, upload it to your admin folder, test a transaction and see if it's subtracting the stock. after i'd done this, it was.
zen cart 1.3.9, SBA 1.4.12. oh, and if you're wondering, i realised it was only the one file. i'd modified orders.php for a separate reason.