function uc_product_views_tables_alter in Ubercart 5
Conditionally add editablefields support.
File
- uc_product/
uc_product.module, line 1173 - The product module for Ubercart.
Code
function uc_product_views_tables_alter(&$tables) {
if (module_exists('editablefields')) {
if (is_array($tables['uc_products']['fields']['model']['option'])) {
$tables['uc_products']['fields']['model']['option']['#options']['editable'] = t('Editable');
}
else {
$tables['uc_products']['fields']['model']['option'] = array(
'#type' => 'select',
'#options' => array(
'display' => t('Display'),
'editable' => t('Editable'),
),
);
}
$tables['uc_products']['fields']['model']['form_parents'] = 'base][model';
if (is_array($tables['uc_products']['fields']['list_price']['option'])) {
$tables['uc_products']['fields']['list_price']['option']['#options']['editable'] = t('Editable');
}
else {
$tables['uc_products']['fields']['list_price']['option'] = array(
'#type' => 'select',
'#options' => array(
'display' => t('Display'),
'editable' => t('Editable'),
),
);
}
$tables['uc_products']['fields']['list_price']['form_parents'] = 'base][prices][list_price';
if (is_array($tables['uc_products']['fields']['cost']['option'])) {
$tables['uc_products']['fields']['cost']['option']['#options']['editable'] = t('Editable');
}
else {
$tables['uc_products']['fields']['cost']['option'] = array(
'#type' => 'select',
'#options' => array(
'display' => t('Display'),
'editable' => t('Editable'),
),
);
}
$tables['uc_products']['fields']['cost']['form_parents'] = 'base][prices][cost';
if (is_array($tables['uc_products']['fields']['sell_price']['option'])) {
$tables['uc_products']['fields']['sell_price']['option']['#options']['editable'] = t('Editable');
}
else {
$tables['uc_products']['fields']['sell_price']['option'] = array(
'#type' => 'select',
'#options' => array(
'display' => t('Display'),
'editable' => t('Editable'),
),
);
}
$tables['uc_products']['fields']['sell_price']['form_parents'] = 'base][prices][sell_price';
if (is_array($tables['uc_products']['fields']['weight']['option'])) {
$tables['uc_products']['fields']['weight']['option']['#options']['editable'] = t('Editable');
}
else {
$tables['uc_products']['fields']['weight']['option'] = array(
'#type' => 'select',
'#options' => array(
'display' => t('Display'),
'editable' => t('Editable'),
),
);
}
$tables['uc_products']['fields']['weight']['form_parents'] = 'base][weight';
}
}