Move set_meta_data

This commit is contained in:
Mike Jolley 2019-06-17 13:53:18 +01:00
parent 836ece76b1
commit f8a28ae1a9
2 changed files with 15 additions and 15 deletions

View File

@ -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'] : '' );
}
}
}
}

View File

@ -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.
*