Showing SKU column in woocommerce orders page
-
I’m trying to show SKU column for each order in WooCommerce > Orders
I did add the following code
// Add the SKU column to the orders page add_filter( 'manage_edit-shop_order_columns', 'add_sku_column' ); function add_sku_column( $columns ) { ? ? $columns['sku'] = __( 'SKU', 'custom-order-page' ); ? ? return $columns; } add_action( 'manage_shop_order_posts_custom_column' , 'display_sku_column_value', 10, 2 ); function display_sku_column_value( $column, $post_id ) { ? ? if ( $column === 'sku' ) { ? ? ? ? $order = wc_get_order( $post_id ); ? ? ? ? $items = $order->get_items(); ? ? ? ? foreach ( $items as $item ) { ? ? ? ? ? ? $product = $item->get_product(); ? ? ? ? ? ? echo $product->get_sku(); ? ? ? ? } ? ? } }
but it still not showing ?!
On the other hand when I show Orders notes on the same page it did work
add_filter('manage_edit-shop_order_columns', 'custom_order_column_header'); function custom_order_column_header($columns) { $columns['order_notes'] = __('Orderz Notes', 'custom-order-page'); return $columns; } // Populate custom column with order notes add_action('manage_shop_order_posts_custom_column', 'custom_order_column_content', 10, 2); function custom_order_column_content($column, $post_id) { if ($column == 'order_notes') { $order = wc_get_order($post_id); if ($order) { echo $order->get_customer_note(); } } }
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
- The topic ‘Showing SKU column in woocommerce orders page’ is closed to new replies.