Admin Services Tab
Admin Services Tab functions allow definition of extra fields to appear on the product details in the admin area. Used for informational output, or for settings and values stored in custom tables or outside WHASOLS.
WHASOLS uses this in the core system for our licensing addon module. The license specific fields of the allowed system are set and viewed from the product details.
There are 2 functions relating to the services tab -
AdminServicesTabFields
and AdminServicesTabFieldsSave
. The first of these allows definition of the extra fields to output. The latter allows handling any input on submission/save, if required.So on to an example, below we show you how to define 4 extra fields. This example shows an input, dropdown, textarea and info only output. The examples continues to update them in a custom table of the database via the save event.
Example Admin Services Tab Function
function yourmodule_AdminServicesTabFields($params) {
//Now your code perform here and return array in pairs of keys and values
$fieldsarray = [
'Field 1' => '<input type="text" name="additionalField["field1"]" class="form-control" value="'.$var1.'">',
'Field 2' => '<select name="additionalField["field2"]" class="form-control"><option value="key1">Val1</option></select>',
'Field 3' => '<textarea name="additionalField["field3"]" rows="2" cols="80" class="form-control">'.$var3.'</textarea>',
'Field 4' => "only text here if required", # Info Output Only
];
return $fieldsarray;
}
function yourmodule_AdminServicesTabFieldsSave($params)
{
$serviceid = $params["serviceid"];
$additionalField = $params["additionalField"];
$field1 = $additionalField["field1"];
$field2 = $additionalField["field2"];
$field3 = $additionalField["field3"];
update_query("yourmodule_customtable",
[
"field1"=>$field1,
"field2"=>$field2,
"field3"=>$field3,
],
[
"serviceid"=>$serviceid
]);
}