Customize the Item Meta Included in E-Documents

This guide explains how to use the wpo_ips_edi_get_item_meta filter to customize which product meta fields are included in your generated E-Documents (such as UBL or CII XML invoices).

Each order item can contain additional attributes — like color, size, or warranty — and this filter lets you modify or extend that data before it’s inserted into the XML structure.

Filter overview #

apply_filters( 'wpo_ips_edi_get_item_meta', $rows, $item, $args, $this );
ParameterTypeDescription
$rowsarrayList of meta rows, each as ['name' => string, 'value' => string].
$item\WC_Order_ItemThe WooCommerce order item object.
$argsarrayArguments used when collecting the meta (see below).
$thisobjectThe calling class instance, in case you need access to helpers or context.

Return the modified $rows array from your callback.

add_filter( 'wpo_ips_edi_get_item_meta', 'myplugin_customize_item_meta', 10, 4 );
function myplugin_customize_item_meta( array $rows, \WC_Order_Item $item, array $args, $that ) {
	// Your logic here.
	return $rows;
}

What this filter controls #

The filtered data is used when building the XML representation of your invoice lines:

  • UBL: inserted as
    <cac:AdditionalItemProperty><cbc:Name>...</cbc:Name><cbc:Value>...</cbc:Value></cac:AdditionalItemProperty>
  • CII: inserted as
    <ram:ApplicableProductCharacteristic><ram:Description>...</ram:Description><ram:Value>...</ram:Value></ram:ApplicableProductCharacteristic>

The function automatically:

  • Removes HTML and shortcodes
  • Normalizes whitespace
  • Converts arrays and objects to JSON text
  • Ensures all values are plain text ready for XML escaping at output

Example use cases #

1. Include only selected meta keys #

add_filter( 'wpo_ips_edi_get_item_meta', function( $rows ) {
	$allowed = array( 'Color', 'Size', 'Warranty' );
	return array_values( array_filter( $rows, fn( $r ) => in_array( $r['name'], $allowed, true ) ) );
}, 10, 4 );

2. Rename meta labels #

add_filter( 'wpo_ips_edi_get_item_meta', function( $rows ) {
	foreach ( $rows as &$r ) {
		if ( 'Warranty months' === $r['name'] ) {
			$r['name'] = 'WarrantyMonths';
		}
	}
	return $rows;
}, 10, 4 );

3. Add a custom attribute to every product line #

add_filter( 'wpo_ips_edi_get_item_meta', function( $rows, $item ) {
	$rows[] = array(
		'name'  => 'ExportedBy',
		'value' => 'WooCommerce PDF Invoices & Packing Slips',
	);
	return $rows;
}, 10, 4 );

4. Remove internal fields #

add_filter( 'wpo_ips_edi_get_item_meta', function( $rows ) {
	return array_values( array_filter( $rows, fn( $r ) => ! str_starts_with( $r['name'], '_' ) ) );
}, 10, 4 );

Tips #

  • Filtering empty values: If you need to include empty meta, call get_item_meta() with 'include_empty' => true.
  • Preserve raw keys: Use 'use_display_label' => false when retrieving meta if you prefer internal meta keys (e.g., pa_color).