Looking for help?
< All Topics
Print

How to addition field for Order in POS

I got some use case, they want add more field to order via POS. 
Since version 3.3.2, we support add more order field API. So, it look like this image 

To do it . we need add those code into wp-content/themes/YOUR_ACTIVE_THEME/function.php or a snippet code in snippet plugin

//order custom data
if(!function_exists('custom_order_field'))
{
    function custom_order_field($session_response_data){
        $addition_checkout_fields = array();
        $addition_checkout_fields[] = array(
            'code' => 'po',
            'type' => 'text',
            'label' => 'Test PO',
            'description' => '',
            'require' => 'yes', // yes or no
            'default' => '',
        );
        $session_response_data['setting']['pos_addition_checkout_fields'] = $addition_checkout_fields;
        return $session_response_data;
    }
}
add_filter('op_get_login_cashdrawer_data','custom_order_field',20,1);
if(!function_exists('custom_order_field_data'))
{
    // this function use to save or interactive with other system
    function custom_order_field_data($order,$order_data){
        $order_id = $order->get_id();
        $addition_information = isset($order_data['addition_information']) ? $order_data['addition_information'] : array();
        // continue logic from here to save or interactive with other system
    }
}
add_action('op_add_order_after','custom_order_field_data',10,2);

To display this field in receipt template,  you can use this shortcode in receipt template composer

<% addition_information.forEach(function(info){ %>
  <%- info.label %>:<%- info.value %>
<% }); %>

Table of Contents