Prevent PHP notices while saving meta_data without an id
This commit is contained in:
parent
75b2661ba3
commit
666d1f3c06
|
@ -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;
|
||||
|
|
|
@ -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'] : '' );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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'] : '' );
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue