WooCommerce 11.4 introduces built-in support for manufacturer part numbers (MPNs). Products and variations gain an MPN field, with support for product editing, REST API requests, CSV imports and exports, and product structured data.
If your extension already reads, writes, or displays MPNs, review its integration before upgrading. The change was introduced in PR #60286.
Who is affected?
This affects extensions and custom code that:
- Read or write the
_mpnproduct metadata key. - Add an MPN field to the product editor.
- Store MPNs under another key and want to integrate with WooCommerce’s new field.
- Add MPNs to product structured data.
What is changing?
WooCommerce now treats _mpn as an internal product property, accessed through get_mpn() and set_mpn().
Existing values stored under _mpn are read by the new property. Editing or clearing the value through WooCommerce updates that same stored value.
Calls such as $product->get_meta( '_mpn' ) continue to return the value, but now trigger a doing_it_wrong warning. The same applies to add_meta_data() and update_meta_data() for this key.
In REST and AJAX requests, WooCommerce also writes these diagnostics to the PHP error log.
The editor interface uses the names (and hence POST parameters) _mpn for the product input and variable_mpn[<index>] for variation inputs.
What action should developers take?
Use the product getter and setter
If you support older WooCommerce versions, check that the new methods exist.
// Reading the MPN
$mpn = method_exists( $product, 'get_mpn' ) ? $product->get_mpn() : $product->get_meta( '_mpn' );
// Writing the MPN
if ( method_exists( $product, 'set_mpn' ) ) {
$product->set_mpn( $mpn );
} else {
$product->update_meta_data( '_mpn', $mpn );
}
$product->save();To clear the value, pass an empty string to set_mpn() and save the product. delete_meta_data( '_mpn' ) does not clear the new product property.
Direct WordPress metadata writes, such as update_post_meta(), do not trigger the internal-meta diagnostic, but bypass WooCommerce’s product save logic and lookup-table updates. Use the setter and product save instead.
Review your editor fields and save handlers
If your extension adds its own MPN input, use WooCommerce’s field when the new methods are available. Update the corresponding save handler too, so it does not interpret an omitted extension field as a request to clear the value.
Duplicate inputs can cause more than a confusing editor: if two inputs share the same submitted name, PHP keeps one value. This is particularly risky when an extension uses _mpn as its input name but stores the value under a different metadata key: the fields can contain different values, and an empty input can overwrite a populated value when the product is saved.
Handle data stored under another key
WooCommerce does not automatically import MPNs from extension-specific keys.
If your extension uses another key, provide a migration or compatibility layer appropriate to your integration. Preserve populated Core values, cover variations, and ensure that clearing an MPN does not unexpectedly restore an older value.
Extensions already storing MPN strings under _mpn do not need to copy those values to a new key.
Review structured data output
WooCommerce includes the MPN in its product structured data. The existing woocommerce_structured_data_product filter still runs afterward, so extension callbacks can replace that value.
Review callbacks that set mpn unconditionally, particularly if they read from a separate legacy field. WooCommerce does not automatically merge independently generated JSON-LD from other plugins.
Testing your integration
Test with WooCommerce 11.4 and an older version you support. Check existing MPNs, saving and clearing values, variations, editor fields, and any feeds or structured data your extension generates.
Confirm that existing values survive the upgrade, only the intended editor input is submitted, and your integration produces no internal-meta diagnostics.
Leave a Reply