Hi
I have had a requirement to create a custom column within the products_with_attributes_stock so that stock level could be automatically updated based on my suppliers product codes.
What I need to do now is to incorporate something that populates this column when adding quantities to variants.
Its very simple really, my codes are always just a number, my suppliers are this number plus a letter on the end Dependant on the size, for example:
1000 would be my code so in the modified table there would be:
stock_id products_id stock_attributes quantity suppier_id
6 1 7 12 1000S
where product id 1's model id is 1000
stock_attributes 7 = small
thus creating 1000S
I see in the products_with_attributes_stock.php file the query is:
PHP Code:
$query = 'insert into `'.TABLE_PRODUCTS_WITH_ATTRIBUTES_STOCK.'` (`products_id`,`stock_attributes`,`quantity`) values ('.$products_id.',"'.$attributes.'",'.$quantity.')';
So I would need something like this:
PHP Code:
$query = 'insert into `'.TABLE_PRODUCTS_WITH_ATTRIBUTES_STOCK.'` (`products_id`,`stock_attributes`,`quantity`,`supplier_id`) values ('.$products_id.',"'.$attributes.'",'.$quantity.','.$supplier_id.')';
to obtain the variable $supplier_id I need two variables
The first being the model_id - easy enough as it can be taken from the products_id already obtained for the page
The second is the option_value_id based on the section made in the form.
From these I can run an if string to get the $supplier_id value - a bit like this:
PHP Code:
if ($options_value_id == 4){
$supplier_id = $product_model.'S';
}
if ($options_value_id == 5){
$fullprodid = $product_model.'M';
}
if ($options_value_id == 6){
$fullprodid = $product_model.'L';
}
if ($options_value_id == 7){
$fullprodid = $product_model.'XL';
}
I am having trouble working out where I need to call the values etc. If anyone is willing to give me pointers I would very much appreciate it :o)
Cheers,
Phil
Bookmarks