Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /* visit us - https://wpgenie.org */
- if ( is_admin() ) {
- add_filter( 'manage_edit-shop_order_columns', 'wpgenie_show_product_order', 15 );
- function wpgenie_show_product_order($columns){
- //add column
- $columns['product-display'] = __( 'Products in Order');
- return $columns;
- }
- add_action( 'manage_shop_order_posts_custom_column' , 'wpgenie_custom_shop_order_column', 10, 2 );
- function wpgenie_custom_shop_order_column( $column ) {
- global $post, $woocommerce, $the_order;
- switch ( $column ) {
- case 'product-display' :
- $terms = $the_order->get_items();
- if ( is_array( $terms ) ) {
- foreach($terms as $term){
- $product = wc_get_product( $term['product_id'] );
- if ( is_object($product) && !(get_post_status( $term['product_id'] ) == "trash") ) {
- echo $term->get_quantity() .' x <a href="'.$product->get_permalink().'" target="_blank">' . $term['name'] .'</a><br>';
- } else {
- echo $term->get_quantity() .' x ' . $term['name'] .' (in trash or deleted) <br>';
- }
- }
- } else {
- _e( 'Unable get the products', 'woocommerce' );
- }
- break;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment