Frequently Asked Questions

How to set a default customer on OpenPOS
Some use case, shop want set a default customer . this is guide how to do it for openpos. 

#1. Choose customer you want in admin/user and take note this user email
#2. open your_active_theme/functions.php , add this code to your end of this file;

function custom_default_order_customer($order_data){
    $customer = isset($order_data['customer']) ? $order_data['customer'] : array();
    $customer_id = isset($customer['id']) ? $customer['id'] : 0;
    $customer_email = isset($customer['email']) ? $customer['email'] : '';
    $customer_phone = isset($customer['phone']) ? $customer['phone'] : '';
    $customer_name = isset($customer['name']) ? $customer['name'] : '';
    if(!$customer_id && !$customer_name && !$customer_phone)
    {
        if(class_exists('Openpos_Front'))
        {
           global $OPENPOS_SETTING;
           global $OPENPOS_CORE;
            $default_customer_email = '1555780170@mail.com'; // set your default customer email
            $tmp = new Openpos_Front($OPENPOS_SETTING,$OPENPOS_CORE);

            $customer_user = get_user_by('email',$default_customer_email);
            if($customer_user)
            {
                $customer_id = $customer_user->get('ID');
                $customer_data = $tmp->_get_customer_data($customer_id);
                $order_data['customer'] = $customer_data;
            }
        }
    }
    return $order_data;
}
add_filter('op_new_order_data','custom_default_order_customer',30,1);

#3. Change "1555780170@mail.com" to your email you note on step 1.

#4. Done


 Last updated Wed, Sep 19 2018 6:50pm

Please Wait!

Please wait... it will take a second!