diff --git a/src/Controllers/Version4/Schema/AbstractRequest.php b/src/Controllers/Version4/Schema/AbstractRequest.php index fbd4a200384..e7b64799477 100644 --- a/src/Controllers/Version4/Schema/AbstractRequest.php +++ b/src/Controllers/Version4/Schema/AbstractRequest.php @@ -46,4 +46,19 @@ abstract class AbstractRequest { * @throws \WC_REST_Exception Will throw an exception if the resulting product object is invalid. */ abstract public function prepare_object(); + + /** + * Set meta data. + * + * @param mixed $object Product object reference. + */ + protected function set_meta_data( &$object ) { + $meta_data = $this->get_param( 'meta_data', null ); + + if ( ! is_null( $meta_data ) ) { + foreach ( $meta_data as $meta ) { + $object->update_meta_data( $meta['key'], $meta['value'], isset( $meta['id'] ) ? $meta['id'] : '' ); + } + } + } } diff --git a/src/Controllers/Version4/Schema/ProductRequest.php b/src/Controllers/Version4/Schema/ProductRequest.php index 8bc30c3aa18..b4f01d34922 100644 --- a/src/Controllers/Version4/Schema/ProductRequest.php +++ b/src/Controllers/Version4/Schema/ProductRequest.php @@ -236,21 +236,6 @@ class ProductRequest extends AbstractRequest { } } - /** - * Set meta data. - * - * @param \WC_Product_Simple|\WC_Product_Grouped|\WC_Product_Variable|\WC_Product_External $object Product object reference. - */ - protected function set_meta_data( &$object ) { - $meta_data = $this->get_param( 'meta_data', null ); - - if ( ! is_null( $meta_data ) ) { - foreach ( $meta_data as $meta ) { - $object->update_meta_data( $meta['key'], $meta['value'], isset( $meta['id'] ) ? $meta['id'] : '' ); - } - } - } - /** * Set product object's attributes. *