Add custom columns to dashboard Licences interface

Share on FacebookShare on Google+Tweet about this on TwitterShare on LinkedInPrint this page

By woocommerce-sl,posted on February 1, 2019

The dashboard licence interface display all licence keys available for all customers on the site. This is the place where the admin can easily manage keys. As default the interface include the following columns:

  • Order ID
  • Key / Licence Status
  • Product
  • Customer
  • Licence Group
  • Licence Key
  • Expire
  • Key Date
  • Active Domain
  • Actions

Through filters, custom columns can be added to the interface. The following example display the renew price for a licence, if apply:


    add_filter('manage_woocommerce_page_sl-licences_columns',    'manage_woocommerce_page_sl_licences_columns');
    function manage_woocommerce_page_sl_licences_columns( $columns )
        {
            
            $columns['renew_price']  =   'Renew Price';
               
            return $columns;   
        }
        
    add_action ('manage_woocommerce_page_sl-licences_column_renew_price', 'manage_woocommerce_page_sl_licences_column_renew_price');
    function manage_woocommerce_page_sl_licences_column_renew_price( $item )
        {
            global $WOO_SL;
            
            $order_item_woo_sl          =   $WOO_SL->functions->get_order_item_meta( $item->order_item_id, '_woo_sl');
            //use the first group
            reset($order_item_woo_sl['group_title']);
            $use_key    =   key( $order_item_woo_sl['group_title'] );  
            
            if  ( $order_item_woo_sl['product_use_expire'][$use_key] != 'yes' )
                return;
                
            echo wc_price ( $order_item_woo_sl['product_expire_renew_price'][$use_key] ) ;
            
        }

Category: