Frequently Asked Questions

How to add more field in add new customer / edit customer on POS
I got many my customer request about add more field to add / edit customer form in POS . And since version 2.3.6 , you can add more field to pos customer form by this way.
Add those code to end of file : your_theme/function.php


and in this sample, i will add company field to add/edit customer form in POS
#1 : Add customer custom field (company) to POS
if(!function_exists('pricechangeable_op_get_login_cashdrawer_data'))
{
    function pricechangeable_op_get_login_cashdrawer_data($session_response_data){
        $text_field = array(
            'code' => 'test_new_field',
            'type' => 'text',
            'label' => 'Company',
            'placeholder' => 'Enter New Field',
            'description' => '',
            'allow_shipping' => 'no' // value yes / no to allow display on shipping field
          );
      /*
        $date_field = array(
            'code' => 'dob',
            'type' => 'date',
            'label' => 'DOB',
            'placeholder' => 'Enter birthday',
            'description' => '',
            'allow_shipping' => 'no' // value yes / no to allow display on shipping field
        );
        $select_field = array(
            'code' => 'gender',
            'type' => 'select',
            'label' => 'Gender',
            'options' => array(
                ['value' => 'male','label' => 'Male'],
                ['value' => 'female','label' => 'Female'],
            ),
            'placeholder' => 'Gender',
            'description' => ''
        );
        $multiselect_field = array(
            'code' => 'multiselect',
            'type' => 'multi_select',
            'label' => 'Multi Select',
            'options' => array(
                ['value' => 'male','label' => 'Male'],
                ['value' => 'female','label' => 'Female'],
            ),
            'placeholder' => 'Multi Select',
            'description' => ''
        );
        $radio_field = array(
            'code' => 'radio',
            'type' => 'radio',
            'label' => 'Radio',
            'options' => array(
                ['value' => 'male','label' => 'Male'],
                ['value' => 'female','label' => 'Female'],
            ),
            'placeholder' => 'Radio Sample',
            'description' => ''
        );
        $checkbox_field = array(
            'code' => 'checkbox',
            'type' => 'checkbox',
            'label' => 'Checkbox',
            'options' => array(
                ['value' => 'male','label' => 'Male'],
                ['value' => 'female','label' => 'Female'],
            ),
            'placeholder' => 'Checkbox Sample',
            'description' => ''
        );
       */
        $session_response_data['setting']['openpos_customer_addition_fields'] = array(
            $text_field,
           // $date_field,$select_field,$multiselect_field,$radio_field,$checkbox_field
        );
        return $session_response_data;
    }
}
add_filter('op_get_login_cashdrawer_data','pricechangeable_op_get_login_cashdrawer_data',10,1);
#2: get customer custom field (company) when get customer data

function pricechangeable_op_customer_data($data){
    $customer_id = isset($data['id']) ? $data['id'] : 0;
    if($customer_id)
    {
        $customer = new WC_Customer($customer_id);
        $data['test_new_field'] = get_user_meta( $customer_id, 'test_new_field', true );
    }
    return $data;
}
add_filter('op_customer_data','pricechangeable_op_customer_data',10,1);
#3: Save new customer custom field (company)

function pricechangeable_op_add_customer_after($customer_id){
    $test_new_field = ( isset($_REQUEST['test_new_field']) && $_REQUEST['test_new_field'] != null ) ? $_REQUEST['test_new_field'] : '';
    update_user_meta( $customer_id, 'test_new_field', $test_new_field  );
}
add_action('op_add_customer_after','pricechangeable_op_add_customer_after',10,1);

#4: Update customer custom field (company)

function pricechangeable_op_update_customer_after($customer_id){
    $test_new_field = ( isset($_REQUEST['test_new_field']) && $_REQUEST['test_new_field'] != null ) ? $_REQUEST['test_new_field'] : '';
    update_user_meta( $customer_id, 'test_new_field', $test_new_field  );
}
add_action('op_update_customer_after','pricechangeable_op_update_customer_after',10,1);
And this is the result . Please take note logout and login POS again to get effect.

image


 Last updated Thu, Sep 20 2018 12:50am

Please Wait!

Please wait... it will take a second!