Looking for help?
Update customer email via POS
enable email editable
function custom_op_basic_customer_field($session_response_data){
$openpos_customer_basic_fields = $session_response_data['setting']['openpos_customer_fields'];
foreach($openpos_customer_basic_fields as $key => $field)
{
if($field['code'] == 'email')
{
$openpos_customer_basic_fields[$key]['editable'] = 'true';
}
}
$session_response_data['setting']['openpos_customer_fields'] = $openpos_customer_basic_fields;
return $session_response_data;
}
add_filter('op_get_login_cashdrawer_data','custom_op_basic_customer_field',20,1);
update email data
add_action('op_update_customer_after',function($customer_id,$session_data,$customer_request_data){
$email = isset($customer_request_data['email']) && $customer_request_data['email'] ? $customer_request_data['email'] : '';
$user_obj = get_user_by('email', $email);
if(!$user_obj){
wp_update_user( array( 'ID' => $customer_id, 'user_email' => $email ) );
}else{
if($user_obj->ID != $customer_id)
{
throw new Exception('Email has beem used by other customer');
}
}
},10,3);