I have added a custom column in Woocommerce admin side order listing page to display Ordered item Products name and total Quantity like this -> [http://prntscr.com/p11rdl] by using the following code:
add_filter('manage_edit-shop_order_columns', 'misha_order_items_column' );
function misha_order_items_column( $order_columns ) {
$order_columns['order_products'] = "Qty-Products Name-SKU";
return $order_columns;
}
add_action( 'manage_shop_order_posts_custom_column' , 'misha_order_items_column_cnt' );
function misha_order_items_column_cnt( $colname ) {
global $the_order; // the global order object
if( $colname == 'order_products' ) {
// get items from the order global object
$order_items = $the_order->get_items();
if ( !is_wp_error( $order_items ) ) {
foreach( $order_items as $order_item ) {
echo $order_item['quantity'] .' × <a href="' . admin_url('post.php?post=' . $order_item['product_id'] . '&action=edit' ) . '" target="_blank">'. $order_item['name'] .'</a><br />';
}
}
}
}
Now I also want to display ordered product SKU number after the product name. So anyone have solution for this then please provide help me.
Thank you,
Ketan
2
Answers
Just replace with follows code snippets to add SKU –
Thank you so much I’ve found this thread extremely helpful, I couldn’t thank the original poster enough as well the help from @itzmekhokan and various other contributors, this community is awesome.
What I’m needing now is to add product shelve location straight after SKU.
I have the below code for location fields but not sure how to amend to the code above to make it work. I’m new to coding in general, but have found snippets of code and made it work so far.
Your help and guidance would be greatly appreciated.