-
-
Save jbpapp/68b6ae43608a40ddad4137e27d7a54cc to your computer and use it in GitHub Desktop.
Add order item details into the order manager table in WooCommerce
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* | |
Plugin Name: Shop Order Info Column | |
Plugin URI: https://example.com | |
Description: Add order details to the order listings. | |
Author: Your name | |
Version: 1.0 | |
Author URI: https://example.com | |
*/ | |
add_filter( 'manage_edit-shop_order_columns', function($columns) { | |
$columns['order_info'] = 'Rendelés infók'; | |
return $columns; | |
}); | |
add_action( 'manage_shop_order_posts_custom_column', function( $column ) { | |
global $the_order; | |
if ( 'order_info' === $column ) { | |
echo $the_order->get_billing_email(); | |
$line_items = $the_order->get_items(); | |
foreach ( $line_items as $item_id => $item ) { | |
$product_object = is_callable( array( $item, 'get_product' ) ) ? $item->get_product() : null; | |
?> | |
<div> | |
<?php echo $item->get_quantity(); ?> x <strong><?php echo esc_html($item->get_name()); ?></strong> | |
<?php if ( $product_object ): ?> | |
(<?php echo esc_html( $product_object->get_sku() ); ?>) | |
<?php endif; ?> | |
</div> | |
<?php | |
} | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment