diff --git a/includes/api/class-wc-rest-orders-controller.php b/includes/api/class-wc-rest-orders-controller.php index 5350bf42628..b42e8c97e9c 100644 --- a/includes/api/class-wc-rest-orders-controller.php +++ b/includes/api/class-wc-rest-orders-controller.php @@ -597,8 +597,9 @@ class WC_REST_Orders_Controller extends WC_REST_Legacy_Orders_Controller { protected function maybe_set_item_meta_data( $item, $posted ) { if ( ! empty( $posted['meta_data'] ) && is_array( $posted['meta_data'] ) ) { foreach ( $posted['meta_data'] as $meta ) { - if ( isset( $meta['key'], $meta['value'] ) ) { - $item->update_meta_data( $meta['key'], $meta['value'], isset( $meta['id'] ) ? $meta['id'] : '' ); + if ( isset( $meta['key'] ) ) { + $value = isset( $meta['value'] ) ? $meta['value'] : null; + $item->update_meta_data( $meta['key'], $value, isset( $meta['id'] ) ? $meta['id'] : '' ); } } }