1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
| <?php
function custom_wc_order_preview_table_content($item, $args) {
if ($item->is_type('line_item')) {
$random_text = substr(str_shuffle("abcdefghijklmnopqrstuvwxyz"), 0, 5);
if ('new' === $args['column_id']) {
echo '<td class="wc-order-preview-table__column--new">';
echo $random_text;
echo '</td>';
}
}
}
add_action('woocommerce_admin_order_preview_line_item_column', 'custom_wc_order_preview_table_content', 10, 2);
function custom_wc_order_preview_table_header($columns) {
$new_columns = array('new' => __('Nouvelle colonne', 'woocommerce'));
$columns = array_slice($columns, 0, 1, true) + $new_columns + array_slice($columns, 1, count($columns) - 1, true);
return $columns;
}
add_filter('woocommerce_admin_order_preview_line_item_columns', 'custom_wc_order_preview_table_header');
function custom_wc_order_preview_table_css() {
echo '<style>.wc-order-preview-table__column--new { width: 20%; }</style>';
}
add_action('admin_head', 'custom_wc_order_preview_table_css'); |
Partager