$column_info) { $new_columns[$column_name] = $column_info; if ($column_name === 'order_total') { $new_columns['to_print_date'] = __('To Print Date', 'studiou-wc-ord-print-statuses'); $new_columns['in_print_date'] = __('In Print Date', 'studiou-wc-ord-print-statuses'); $new_columns['external_order_number'] = __('External Order Number', 'studiou-wc-ord-print-statuses'); } } return $new_columns; } /** * Render cell content. Under HPOS WC passes the WC_Order object as the * second argument; under legacy CPT it passes the post ID. wc_get_order() * normalises both forms, so we accept either. */ public function add_custom_shop_order_column_content($column, $order_or_id) { $order = wc_get_order($order_or_id); if (!$order) { echo '—'; return; } switch ($column) { case 'to_print_date': echo $this->format_meta_date($order->get_meta('to_print_date')); break; case 'in_print_date': echo $this->format_meta_date($order->get_meta('in_print_date')); break; case 'external_order_number': $value = $order->get_meta('external_ref_ord_no'); echo $value !== '' ? esc_html($value) : '—'; break; } } private function format_meta_date($value) { if (empty($value)) { return '—'; } $timestamp = strtotime($value); if (!$timestamp) { return '—'; } return esc_html(date_i18n(get_option('date_format') . ' ' . get_option('time_format'), $timestamp)); } }