Home / Admin / Add order status to commissions table
Duplicate Snippet

Embed Snippet on Your Site

Add order status to commissions table

Code Preview
php
<?php
/**
 * Add order status to commissions table
 *
 * @param  Array $columns array stored column names 
 * @return Array $columns
 */
function wcv_custom_commissions_columns( $columns ) {
    $columns['order_status'] = __( 'Order Status', 'wc-vendors' );
    return $columns;
}
add_filter( 'wcvendors_commissions_columns', 'wcv_custom_commissions_columns', 10, 1 );
 
/**
 * Add custom columns value
 *
 * @param  mixed  $value current value in loop
 * @param  Object $item current item in loop
 * @param  mixed  $column_name name of column in query result
 * @return mixed .
 */
function wcv_add_custom_commission_column( $value, $item, $column_name ) {
    switch ( $column_name ) {
        case 'order_status':
			$order = wc_get_order( $item->order_id );
			if ( $order ) {
				return wc_get_order_status_name( $order->get_status() ); 
			} 
			// Order has been deleted.
            return  __( 'Order not found.', 'wc-vendors' );
		break;
    }
}
add_filter( 'wcvendors_commissions_column_default_order_status', 'wcv_add_custom_commission_column', 10, 3 );

Comments

Add a Comment