diff --git a/includes/api/class-wc-rest-coupons-controller.php b/includes/api/class-wc-rest-coupons-controller.php index ae86cc07824..245f398b6be 100644 --- a/includes/api/class-wc-rest-coupons-controller.php +++ b/includes/api/class-wc-rest-coupons-controller.php @@ -119,7 +119,7 @@ class WC_REST_Coupons_Controller extends WC_REST_Coupons_V1_Controller { case 'meta_data' : if ( is_array( $value ) ) { foreach ( $value as $meta ) { - $coupon->update_meta_data( $meta['key'], $meta['value'], $meta['id'] ); + $coupon->update_meta_data( $meta['key'], $meta['value'], isset( $meta['id'] ) ? $meta['id'] : '' ); } } break; diff --git a/includes/api/class-wc-rest-customers-controller.php b/includes/api/class-wc-rest-customers-controller.php index e8d4cbbf930..7fbe1507bbd 100644 --- a/includes/api/class-wc-rest-customers-controller.php +++ b/includes/api/class-wc-rest-customers-controller.php @@ -85,7 +85,7 @@ class WC_REST_Customers_Controller extends WC_REST_Customers_V1_Controller { if ( isset( $request['meta_data'] ) ) { if ( is_array( $request['meta_data'] ) ) { foreach ( $request['meta_data'] as $meta ) { - $customer->update_meta_data( $meta['key'], $meta['value'], $meta['id'] ); + $customer->update_meta_data( $meta['key'], $meta['value'], isset( $meta['id'] ) ? $meta['id'] : '' ); } } } diff --git a/includes/api/class-wc-rest-orders-controller.php b/includes/api/class-wc-rest-orders-controller.php index 727a381f3d2..fa1c205660c 100644 --- a/includes/api/class-wc-rest-orders-controller.php +++ b/includes/api/class-wc-rest-orders-controller.php @@ -189,7 +189,7 @@ class WC_REST_Orders_Controller extends WC_REST_Orders_V1_Controller { case 'meta_data' : if ( is_array( $value ) ) { foreach ( $value as $meta ) { - $order->update_meta_data( $meta['key'], $meta['value'], $meta['id'] ); + $order->update_meta_data( $meta['key'], $meta['value'], isset( $meta['id'] ) ? $meta['id'] : '' ); } } break; diff --git a/includes/api/class-wc-rest-products-controller.php b/includes/api/class-wc-rest-products-controller.php index f4771bd4413..4a6e489412e 100644 --- a/includes/api/class-wc-rest-products-controller.php +++ b/includes/api/class-wc-rest-products-controller.php @@ -241,8 +241,7 @@ class WC_REST_Products_Controller extends WC_REST_Products_V1_Controller { // Allow set meta_data. if ( is_array( $request['meta_data'] ) ) { foreach ( $request['meta_data'] as $meta ) { - $meta_id = isset( $meta['id'] ) ? $meta['id'] : ''; - $product->update_meta_data( $meta['key'], $meta['value'], $meta_id ); + $product->update_meta_data( $meta['key'], $meta['value'], isset( $meta['id'] ) ? $meta['id'] : '' ); } }