Looking for help?
Add custom field in add custom product form
Snippet code to show field on pos panel
if(!function_exists('openpos_product_addition_fields'))
{
function openpos_product_addition_fields($session_response_data){
//custom product fields
$session_response_data['setting']['openpos_product_addition_fields'] = array();
$session_response_data['setting']['openpos_product_addition_fields'][] = array(
'code' => 'text_field',
'type' => 'text',
'required' => 'yes',
'label' => 'Text Field Label',
'placeholder' => 'Enter text field',
'description' => ''
);
$session_response_data['setting']['openpos_product_addition_fields'][] = array(
'code' => 'checkbox',
'type' => 'checkbox',
'label' => 'Checkbox',
'options' => array(
['value' => 'male','label' => 'Male'],
['value' => 'female','label' => 'Female'],
),
'placeholder' => 'Checkbox Sample',
'description' => '',
'default' => array('male'),
);
$session_response_data['setting']['openpos_product_addition_fields'][] = array(
'code' => 'radio',
'type' => 'radio',
'label' => 'Radio',
'options' => array(
['value' => 'radio1','label' => 'Value 1'],
['value' => 'radio2','label' => 'value 2'],
),
'placeholder' => 'Checkbox Sample',
'description' => '',
'default' => array('radio2'),
);
$session_response_data['setting']['openpos_product_addition_fields'][] = array(
'code' => 'select',
'type' => 'select',
'label' => 'Select Fields',
'options' => array(
['value' => 's1','label' => 'select 1'],
['value' => 's2','label' => 'select 2'],
),
'placeholder' => 'Checkbox Sample',
'description' => '',
'default' => array('s2'),
);
return $session_response_data;
}
}
add_filter('op_get_login_cashdrawer_data','openpos_product_addition_fields',10,1);
Code to handle data submit by add custom product form
add_action('openpos_after_add_custom_product',function($product_id,$product_data){
$text_field = isset($product_data['text_field']) ? trim($product_data['text_field']) : '';
$radio_field = isset($product_data['radio']) ? trim($product_data['radio']) : '';
//implement your logic to product with custom data as you want
},10,2);