WooCommerce has a field for a product’s barcode number. It sits in the Inventory tab, labeled “GTIN, UPC, EAN, or ISBN”, and it works for variations too. Then you open an order, and the number is nowhere. You get the product name and the SKU, and that’s it.
I checked why in the WooCommerce source. The order item template, includes/admin/meta-boxes/views/html-order-item.php, prints the SKU and the variation ID and nothing else. The order preview builds its rows in class-wc-admin-list-table-orders.php and does the same. Store owners have asked for it in a feature request, and it’s still not there in WooCommerce 11.2.
If you pick and pack against barcodes, or match orders to a supplier’s catalog, that’s a lot of clicking back to the product. So I wrote a snippet that puts the number next to the SKU in both places.
The snippet
Add this to your child theme’s functions.php or a code snippets plugin like Code Snippets:
/**
* Display Global ID (GTIN) in WooCommerce Order Admin
* Works for both simple and variable products (variations)
*
* @since 1.0.0
*/
// Display Global ID in regular order view (order details page)
add_action( 'woocommerce_after_order_itemmeta', function( $item_id, $item, $product ) {
// Only show in admin and for line items
if ( ! is_admin() || ! $item->is_type( 'line_item' ) ) {
return;
}
// Get the product (for variable products, this returns the variation)
$product = $item->get_product();
if ( ! $product || ! method_exists( $product, 'get_global_unique_id' ) ) {
return;
}
$unique_id = $product->get_global_unique_id();
if ( $unique_id ) {
echo '<div class="wc-order-item-global-id" style="color: #888; font-size: 12px; margin-top: 4px;">';
echo '<strong>' . esc_html__( 'Global ID:', 'woocommerce' ) . '</strong> ' . esc_html( $unique_id );
echo '</div>';
}
}, 10, 3 );
// Filter the order preview HTML to add Global ID after SKU for each product
add_filter( 'woocommerce_admin_order_preview_get_order_details', function( $order_details, $order ) {
// Get order items
$line_items = $order->get_items();
// Build a map of item_id => global_id (using item_id, not product_id)
$item_global_ids = array();
foreach ( $line_items as $item_id => $item ) {
$product = $item->get_product();
if ( ! $product || ! method_exists( $product, 'get_global_unique_id' ) ) {
continue;
}
$unique_id = $product->get_global_unique_id();
if ( $unique_id ) {
$item_global_ids[ $item_id ] = $unique_id;
}
}
// Only proceed if we found any Global IDs
if ( empty( $item_global_ids ) ) {
return $order_details;
}
$html = $order_details['item_html'];
// For each item with a Global ID, find its specific row and add the Global ID
foreach ( $item_global_ids as $item_id => $global_id ) {
// Each item row has a unique class: wc-order-preview-table__item--{item_id}
// Find the SKU div within this specific row and add Global ID after it
$row_pattern = '/(<tr[^>]*wc-order-preview-table__item--' . preg_quote( $item_id, '/' ) . '[^>]*>.*?<div class="wc-order-item-sku">.*?<\/div>)/s';
$global_id_div = '<div class="wc-order-item-global-id" style="color: #888; font-size: 12px;"><strong>Global ID:</strong> ' . esc_html( $global_id ) . '</div>';
// Replace by adding Global ID div after the SKU div for this specific item
$html = preg_replace(
$row_pattern,
'$1' . $global_id_div,
$html,
1 // Only replace once per item
);
}
// Update the item HTML in the order details
$order_details['item_html'] = $html;
return $order_details;
}, 10, 2 );How it works
The first part handles the full order page. WooCommerce fires woocommerce_after_order_itemmeta once for each line item, after the SKU, the variation ID and the item meta, like a variation’s color. The snippet gets the product from the item, so a variation gives you the variation’s own number, not the parent’s. If get_global_unique_id() returns a value, it prints it in a small gray line.
The order preview is harder. It has no hook per item. WooCommerce builds the whole items table as one HTML string, then passes it through the woocommerce_admin_order_preview_get_order_details filter as item_html.
So the second part works on that string. Every preview row has a class with the item ID, wc-order-preview-table__item--{item_id}, and holds a <div class="wc-order-item-sku">. The snippet finds the row for each item that has a number and adds the Global ID right after its SKU div. It matches rows by item ID, so each number lands on its own row.

What I tested
I ran it on a fresh site with WordPress 7.1.4 and WooCommerce 11.2.1, with the default HPOS order storage. The test order had three lines:
- A simple product with an ISBN, 9780306406157.
- A variation of a variable product with its own UPC, 0012345678905.
- A product with an SKU and no global ID.
On the order edit screen, the first two lines showed “Global ID:” with the right number below the item details, and the third showed only its SKU. In the preview from the orders list, the number sat right under the SKU, and the third line again had none.
Things to know
The number comes from the product as it is now. WooCommerce doesn’t copy it into the order. If you change a product’s GTIN later, old orders show the new one, and if you delete the product, the line shows no Global ID at all.
The preview part depends on WooCommerce’s own markup. If a future version renames the wc-order-item-sku class or the row class, the preview stops showing the number. The order edit screen keeps working, because it uses a hook. I’d check the preview after each major WooCommerce update.
Customers never see it. Both hooks run only in the admin.
The same field also feeds the gtin value in WooCommerce’s product structured data, in includes/class-wc-structured-data.php, when the number is valid. That’s part of what product data search engines get from your store, so fill it in even if you never need it in orders.
If your team works in the orders list all day, showing company names in the orders list is another small change in the same spirit.
Did this fix work on your site?
If it didn't, tell me what happened. I re-test reported fixes and update the post.




No comments yet. Ask the first question.