• I’m trying to add a field (CPF) in the creation of the customer. This field already appears in the billing data at the ONLINE STORE checkout. Using the support’s guidance, the Field appears in the creation form in the POS but is not saved in the user’s registration. I’m using the guide I found on support:

    https://support.openswatch.com/kb/faq.php?id=17

    Can you help me!

    My code added in the theme’s function.php:

    if(!function_exists(‘pricechangeable_op_get_login_cashdrawer_data’))
    {
    function pricechangeable_op_get_login_cashdrawer_data($session_response_data){
    $text_field = array(
    ‘code’ => ‘billing_cpf’,
    ‘type’ => ‘text’,
    ‘label’ => ‘CPF’,
    ‘placeholder’ => ‘Enter New Field’,
    ‘description’ => ”,
    ‘required’ => ‘yes’,
    ‘allow_customer’ => ‘no’, // no if not hide on billing
    ‘allow_shipping’ => ‘yes’ // value yes / no to allow display on shipping field
    );

    $session_response_data[‘setting’][‘openpos_customer_addition_fields’][] = $text_field;

    return $session_response_data;
    }
    }
    add_filter(‘op_get_login_cashdrawer_data’,’pricechangeable_op_get_login_cashdrawer_data’,10,1);

    function pricechangeable_op_customer_data($data){
    $customer_id = isset($data[‘id’]) ? $data[‘id’] : 0;
    if($customer_id)
    {
    $customer = new WC_Customer($customer_id);
    $data[‘billing_cpf’] = get_user_meta( $customer_id, ‘billing_cpf’, true );
    }
    return $data;
    }
    add_filter(‘op_customer_data’,’pricechangeable_op_customer_data’,10,1);

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

    function pricechangeable_op_update_customer_after($customer_id){
    $billing_cpf = ( isset($_REQUEST[‘billing_cpf’]) && $_REQUEST[‘billing_cpf’] != null ) ? $_REQUEST[‘billing_cpf’] : ”;
    update_user_meta( $customer_id, ‘billing_cpf’, $billing_cpf );
    }
    add_action(‘op_update_customer_after’,’pricechangeable_op_update_customer_after’,10,1);`

Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
  • The topic ‘How to add field in customer billing on POS’ is closed to new replies.