Hiding blog_id in WooMultiDomain Order Details
When WooCommerce records order items it often stores extra metadata that helps identify where a product came from, how it was configured, or which internal system created it. One of those hidden-but-useful fields you may see on the order item page is blog_id — a small numeric value that identifies the origin site for that product when you run a multi-domain or multisite setup.
If you use the WPCommerce WooMultiDomain solution, the blog_id becomes meaningful: it holds the product’s origin blog/site ID inside the multisite or multi-domain network. That means every order line can carry a direct reference to the exact site where the product record lives, which simplifies reconciliation, inventory tracing, and any cross-site fulfillment logic.
Be mindful that blog_id is an internal identifier: it’s best used in administrative views and developer tools rather than shown to customers. When monitoring multi-domain stores, keeping the blog_id visible in admin order items speeds debugging and makes multi-site commerce workflows much easier to manage.
To hide the blog_id meta field, a custom code can be used. The following code example can be added within theme functions.php or a custom file in /mu-plugins/ folder.
/**
* Remove 'blog_id' from formatted order item meta shown in admin/emails/frontend.
*
* @param array $formatted_meta Array of formatted meta objects/arrays.
* @param WC_Abstract_Item $item The order item object.
* @return array Modified $formatted_meta without 'blog_id' entries.
*/
function hide_order_item_blog_id_meta( $formatted_meta, $item )
{
foreach ( $formatted_meta as $index => $meta )
{
// Support both object and array shaped meta entries (defensive)
if ( is_object( $meta ) ) {
$key = isset( $meta->key ) ? $meta->key : ( isset( $meta->display_key ) ? $meta->display_key : '' );
} elseif ( is_array( $meta ) ) {
$key = isset( $meta['key'] ) ? $meta['key'] : ( isset( $meta['display_key'] ) ? $meta['display_key'] : '' );
} else {
$key = '';
}
if ( '' !== $key && strtolower( $key ) === 'blog_id' ) {
unset( $formatted_meta[ $index ] );
}
}
// Reindex numeric keys and return
return array_values( $formatted_meta );
}
add_filter( 'woocommerce_order_item_get_formatted_meta_data', 'hide_order_item_blog_id_meta', 10, 2 );
