Skip to content

Instantly share code, notes, and snippets.

@jbpapp
Forked from passatgt/shop_order_info_column.php
Last active May 29, 2020 21:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jbpapp/68b6ae43608a40ddad4137e27d7a54cc to your computer and use it in GitHub Desktop.
Save jbpapp/68b6ae43608a40ddad4137e27d7a54cc to your computer and use it in GitHub Desktop.
Add order item details into the order manager table in WooCommerce
<?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