Untitled
unknown
plain_text
a year ago
2.0 kB
6
Indexable
add_filter('salesking_include_subagent_orders','__return_true');
// Add the column headers
add_action('salesking_my_orders_custom_columns', function(){
// Agent column
echo '<th class="nk-tb-col tb-col-md"><span class="sub-text">'. esc_html__('Agent', 'salesking') .'</span></th>';
// Agent Earnings column
echo '<th class="nk-tb-col tb-col-md"><span class="sub-text">'. esc_html__('Agent Earnings', 'salesking') .'</span></th>';
});
// Add the column footers
add_action('salesking_my_orders_custom_columns_footer', function(){
echo '<th class="nk-tb-col tb-col-md">'. esc_html__('agent', 'salesking') .'</th>';
echo '<th class="nk-tb-col tb-col-md">'. esc_html__('agent earnings', 'salesking') .'</th>';
});
// Add the column contents
add_action('salesking_my_orders_custom_columns_content', function($order){
// Agent column content
echo '<td class="nk-tb-col tb-col-md">';
echo '<div>';
echo '<span class="tb-sub">';
$agent_id = $order->get_meta('salesking_assigned_agent');
if ($agent_id) {
$agent = get_user_by('ID', $agent_id);
if ($agent) {
echo esc_html($agent->display_name ?: $agent->user_login);
} else {
echo esc_html__('Unknown Agent', 'salesking');
}
} else {
echo esc_html__('No Agent Assigned', 'salesking');
}
echo '</span>';
echo '</div>';
echo '</td>';
// Agent Earnings column content
echo '<td class="nk-tb-col tb-col-md">';
echo '<div>';
echo '<span class="tb-sub">';
$earning_id = $order->get_meta('salesking_earning_id');
$commission = get_post_meta($earning_id, 'salesking_commission_total', true);
if ($commission !== '') {
echo wc_price($commission, array('currency' => $order->get_currency()));
} else {
echo wc_price(0, array('currency' => $order->get_currency()));
}
echo '</span>';
echo '</div>';
echo '</td>';
}, 10, 1);Editor is loading...
Leave a Comment