> For the complete documentation index, see [llms.txt](https://docs.digitalriver.com/woocommerce/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.digitalriver.com/woocommerce/woocommerce-extension-2.0/support/productmetafields-module.md).

# Product Meta Fields module support

Digital River requires products to have certain fields that are not present in the WooCommerce product. Add these fields to the `WC_Product` by using the concept of meta fields by using the `ProductMetaFields` module.

### Add a new field to the metabox&#x20;

To add a new field to the metabox:&#x20;

1. Grab the **Field array** from the filter: `add_filter( 'digitalriver.meta_fields', 'filter_method' )`
2. Pass the array as the first argument to `filter_method()`.
3. Add or remove fields from the array and then return it.

### Product Meta Fields Methods

#### Product Meta Fields class&#x20;

This class acts as the module's entry point.

| Method                                       | Args, Returns, and Descriptions                                                                                                                                                                                                    |
| -------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| name                                         | <p><strong>Arg</strong>: -</p><p><strong>Return</strong>: string</p><p><strong>Description</strong>: Returns the name of the module</p>                                                                                            |
| \_\_construct                                | <p><strong>Arg:</strong> <code>MetaFieldsContainer</code> $container</p><p><strong>Return</strong>: void</p><p><strong>Description</strong>: Constructs the object by passing in the dependencies</p>                              |
| init                                         | <p><strong>Arg:</strong> -</p><p><strong>Return</strong>: void</p><p><strong>Description</strong>: Initializes the module, register necessary hooks, and defines the fields</p>                                                    |
| admin\_enqueue\_scripts                      | <p><strong>Arg</strong>: String $hook\_suffix</p><p><strong>Return</strong>: void</p><p><strong>Description</strong>: Enqueue the scripts and stylesheets in the <code>admin\_enqueue\_scripts</code> hook</p>                     |
| woocommerce\_product\_data\_tabs             | <p><strong>Arg</strong>: array $product\_data\_tabs</p><p><strong>Return</strong>: array</p><p><strong>Description</strong>: Add a new tab to enter the Digital River product details in the product create/edit page.</p>         |
| woocommerce\_product\_data\_panels           | <p><strong>Arg</strong>: -</p><p><strong>Return</strong>: void</p><p><strong>Description</strong>: Renders HTML of Digital River tab under the WooCommerce Product Data metabox</p>                                                |
| woocommerce\_admin\_process\_product\_object | <p><strong>Arg</strong>: <code>WC\_Product</code> $product</p><p><strong>Return</strong>: void</p><p><strong>Description</strong>: Saves the <code>digitalriver</code> meta values in metadata when a product is saved/created</p> |
| field                                        | <p><strong>Arg</strong>: String $key</p><p><strong>Return</strong>: Field</p><p><strong>Description</strong>: Gets a field name as an argument and returns the field object</p>                                                    |

#### Meta Fields Container class

This class acts as a Dependency Injection container for providing dependencies to classes present in the ProductMetaFields module.

| Method           | Args, Returns, and Descriptions                                                                                                                                                                                                   |
| ---------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| \_\_construct    | <p><strong>Arg</strong>: <code>PimpleContainer</code></p><p><strong>Return</strong>: void</p><p><strong>Description</strong>: Accepts a Dependency Injection container as an argument and assigns it to a container attribute</p> |
| define\_services | <p><strong>Arg</strong>: -</p><p><strong>Return</strong>: void</p><p><strong>Description</strong>: Defines all the classes present within the module</p>                                                                          |

### Field interface

The interface must be implemented by all the meta fields.

| Method    | Args, Returns, and Descriptions                                                                                                                                                     |
| --------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| meta\_key | <p><strong>Arg</strong>: -</p><p><strong>Return</strong>: string</p><p><strong>Description</strong>: Returns the meta key</p>                                                       |
| render    | <p><strong>Arg</strong>: -</p><p><strong>Return</strong>: void</p><p><strong>Description</strong>: Renders the meta field to the metabox</p>                                        |
| value     | <p><strong>Arg</strong>: int $post\_id</p><p><strong>Return</strong>: mixed</p><p><strong>Description</strong>: Retrieves meta value of the post with id <code>$post\_id</code></p> |
| save      | <p><strong>Arg</strong>: int $post\_id, mixed $value</p><p><strong>Return</strong>: void</p><p><strong>Description</strong>: Saves the meta value to the post</p>                   |

### Field classes

This module has the following field classes:

| Field class       | Description                                                                                                                                                                                                                                                             |
| ----------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `CountryOfOrigin` | The `CountryOfOrigin` field refers to the location where the product originated. The `CountryOfOrigin` is a two-letter Alpha-2 country code as described in the ISO 3166 international standard. Here is a list of [country codes](https://www.iban.com/country-codes). |
| `ECCN`            | Exports Control Classification Number (ECCN). A list of pre-approved ECCNs is found [here](https://www.digitalriver.com/legal-other/approved-eccns/).                                                                                                                   |
| `HSCode`          | Read more [here](https://docs.digitalriver.com/digital-river-api/product-management/creating-and-updating-skus#harmonized-system-code) about the Harmonized Commodity Description and Coding System (HS Code).                                                          |
| `TaxCode`         | See a list of supported [tax codes](https://docs.digitalriver.com/digital-river-api/product-management/creating-and-updating-skus#tax-code) here.                                                                                                                       |
| `SkuGroupId`      | Refer to [SKU group identifier](https://docs.digitalriver.com/digital-river-api/product-management/creating-and-updating-skus#sku-group-identifier) for more information.                                                                                               |
| `Description`     | Provides a  description of the [SKU group](https://docs.digitalriver.com/digital-river-api/product-management/setting-up-sku-groups).                                                                                                                                   |
| `ItemBreadcrumb`  | A hierarchical classification system that organizes and categorizes your products. Refer to [Item breadcrumb](https://docs.digitalriver.com/digital-river-api/product-management/creating-and-updating-skus#item-breadcrumb) for more information.                      |


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.digitalriver.com/woocommerce/woocommerce-extension-2.0/support/productmetafields-module.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
