Skip to content

Instantly share code, notes, and snippets.

@passatgt
Created May 29, 2020 12:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save passatgt/b0c871184c9e03c9c4182e89acf3f71b to your computer and use it in GitHub Desktop.
Save passatgt/b0c871184c9e03c9c4182e89acf3f71b to your computer and use it in GitHub Desktop.
Add order item details into the order manager table in WooCommerce
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