> ## Documentation Index
> Fetch the complete documentation index at: https://docs.global-e.com/llms.txt
> Use this file to discover all available pages before exploring further.

# EU Deforestation Regulation (EUDR)

Part of [EU Deforestation Regulation (EUDR)](https://docs.global-e.com/eu-deforestation-regulation-eudr.md).

On WooCommerce, the Global-e plugin sends `eudrDdsReference` and `eudrTaricCode` to Global-e at checkout. WooCommerce has no built-in field for these values, so a developer adds a short code snippet: the code filter.

## Before you start

| Requirement | Minimum version |
| - | - |
| Global-e WooCommerce plugin | 1.14.0 |

You can check your plugin version by navigating to **Plugins → Installed Plugins**.

![Global-e plugin version under Plugins, Installed Plugins](https://mintcdn.com/globale-enterprise/TSLEJxyEPjRJOJpp/images/eu-product-identifiers/woocommerce-plugin-version.png?fit=max\&auto=format\&n=TSLEJxyEPjRJOJpp\&q=85\&s=493330ee8dfd489d2aedd0f01e8d626e)

## Set up EUDR with the code filter

Requires: Global-e WooCommerce plugin 1.14.0 or later.

1. Store the DDS reference and TARIC document code for each product or variation. Your developer decides where the values come from: for example, a custom field on each variation (added by your developer or a custom fields plugin), or an external system such as your ERP or PIM.
2. **Send both values with the code filter.** Add the code from **The code filter** below.
3. Place a test order and confirm both keys appear when values exist and are omitted when blank.

## The code filter

The plugin's `woocommerce_globale_pro_add_cart_product_meta_attributes` filter adds key/value pairs to each cart line's MetaData. The filter reads the values from the variation when there is one, otherwise from the product, so each variation can send its own pair.

Example for your theme's `functions.php` or a custom plugin. Replace the meta keys with wherever you store the values:

```php theme={null}
add_filter( \GCBWC\Globale\Pro\Model\Cart::FILTER_CART_PRODUCT_META_ATTRIBUTES, 'gcbwc_add_eudr_meta_attributes', 10, 2 );

if ( ! function_exists( 'gcbwc_add_eudr_meta_attributes' ) ) :
	function gcbwc_add_eudr_meta_attributes( $metaAttributes, $cart_item ) {
		// Read from the variation when there is one, otherwise from the product.
		$id = ! empty( $cart_item['variation_id'] ) ? $cart_item['variation_id'] : $cart_item['product_id'];

		// Replace these meta keys with wherever you store the identifiers.
		// Option A: remove the standardcode line.
		$pids = array(
			'eudrDdsReference' => get_post_meta( $id, '_your_eudr_dns_reference_meta_key', true ),
			'eudrTaricCode'  => get_post_meta( $id, '_your_eudr_taric_code_meta_key', true ),
		);

		foreach ( $pids as $key => $value ) {
			if ( '' === trim( (string) $value ) ) {
				continue; // Leave the key out when there is no value.
			}
			$attribute = new \GCBWC\Globale\Pro\Api\Entity\CustomProductAttribute();
			$attribute->setAttributeKey( $key );
			$attribute->setAttributeValue( $value );
			$metaAttributes[] = $attribute;
		}

		return $metaAttributes;
	}
endif;
```

* Use the keys exactly as written, in camelCase: `eudrDdsReference` and `eudrTaricCode`.
* Leave a key out when there is no value. Never send NA, 0 or -.
* Send each key from one source only. Keys sent by the filter do not need to be listed in Extra Product Attributes.
* If you already send EU Product Identifiers with the same filter, add the EUDR keys to the same function. `standardcode` and `mididentifier` keep working unchanged.
* Test on a staging site first and confirm both keys appear on the cart line.

## Reference

**What gets sent**

| Sent as | What it holds | When to leave it out |
| - | - | - |
| `eudrDdsReference` | The Due Diligence Statement (DDS) reference for that product or variation | When the item has no DDS reference |
| `eudrTaricCode` | The TARIC document code for that product or variation | When the item has no TARIC document code |

**Key points**

* **Per variation.** A variation sends its own values. A product without variations sends the product's values.
* **Omit, don't fake.** Leave the value empty when you have none. Never enter NA, 0 or -.
* **Separate from PID.** EUDR keys are sent alongside `standardcode` and `mididentifier` on the same cart line; they do not replace them.

**Quick check before go-live**

| Check | Done |
| - | - |
| Global-e WooCommerce plugin is 1.14.0 or later | ☐ |
| The code filter sends `eudrDdsReference` and `eudrTaricCode` | ☐ |
| Two variations with different values each show their own pair in SendCart | ☐ |
| Keys omitted (not empty) when an item has no value | ☐ |
| `standardcode` and `mididentifier` still appear when configured | ☐ |


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.