Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- // WooCommerce - Add extra columns to the shop order table
- // since v3.3
- add_filter( 'manage_shop_order_posts_columns', 'set_shop_order_posts_columns', 99 );
- function set_shop_order_posts_columns( $columns ) {
- // $columns['unwanted_column'] = 'Unwanted column'; // comment out any unwanted columns
- $columns['order_items'] = 'Order items';
- $columns['order_notes'] = 'Order notes';
- $columns['payment_method'] = 'Payment<br>Method';
- return $columns;
- }
- add_action( 'manage_shop_order_posts_custom_column' , 'show_custom_columns', 10, 2 );
- function show_custom_columns( $column_name, $post_id ) {
- switch ( $column_name ) {
- case 'order_items':
- $order = new WC_Order( $post_id );
- $order_items = $order->get_items();
- $nr = 1;
- foreach( $order_items as $order_item ) {
- print $nr.') '.$order_item->get_name().'<br>';
- $nr++;
- }
- break;
- case 'order_notes':
- $order = new WC_Order( $post_id );
- $note = $order->get_customer_note();
- // choose one of the following print statements
- // print $note;
- print $note ? 'Yes' : '';
- break;
- case 'payment_method':
- $order = new WC_Order( $post_id );
- print $order->get_payment_method();
- break;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement