Merge branch 'pr/12641'
This commit is contained in:
commit
e974682218
|
@ -241,7 +241,10 @@ class WC_Order_Item extends WC_Data implements ArrayAccess {
|
|||
}
|
||||
|
||||
if ( array_key_exists( $offset, $this->data ) ) {
|
||||
$this->data[ $offset ] = $value;
|
||||
$setter = "set_$offset";
|
||||
if ( is_callable( array( $this, $setter ) ) ) {
|
||||
$this->$setter( $value );
|
||||
}
|
||||
}
|
||||
|
||||
$this->update_meta_data( '_' . $offset, $value );
|
||||
|
@ -263,6 +266,10 @@ class WC_Order_Item extends WC_Data implements ArrayAccess {
|
|||
unset( $this->data[ $offset ] );
|
||||
}
|
||||
|
||||
if ( array_key_exists( $offset, $this->changes ) ) {
|
||||
unset( $this->changes[ $offset ] );
|
||||
}
|
||||
|
||||
$this->delete_meta_data( '_' . $offset );
|
||||
}
|
||||
|
||||
|
@ -301,7 +308,10 @@ class WC_Order_Item extends WC_Data implements ArrayAccess {
|
|||
if ( 'item_meta' === $offset ) {
|
||||
return $meta_values;
|
||||
} elseif ( array_key_exists( $offset, $this->data ) ) {
|
||||
return $this->data[ $offset ];
|
||||
$getter = "get_$offset";
|
||||
if ( is_callable( array( $this, $getter ) ) ) {
|
||||
return $this->$getter();
|
||||
}
|
||||
} elseif ( array_key_exists( '_' . $offset, $meta_values ) ) {
|
||||
// Item meta was expanded in previous versions, with prefixes removed. This maintains support.
|
||||
return $meta_values[ '_' . $offset ];
|
||||
|
|
|
@ -111,7 +111,6 @@ abstract class Abstract_WC_Order_Item_Type_Data_Store extends WC_Data_Store_WP i
|
|||
'type' => $data->order_item_type,
|
||||
) );
|
||||
$item->read_meta_data();
|
||||
$item->set_object_read( true );
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -31,6 +31,7 @@ class WC_Order_Item_Coupon_Data_Store extends Abstract_WC_Order_Item_Type_Data_S
|
|||
'discount' => get_metadata( 'order_item', $item->get_id(), 'discount_amount', true ),
|
||||
'discount_tax' => get_metadata( 'order_item', $item->get_id(), 'discount_amount_tax', true ),
|
||||
) );
|
||||
$item->set_object_read( true );
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -32,6 +32,7 @@ class WC_Order_Item_Fee_Data_Store extends Abstract_WC_Order_Item_Type_Data_Stor
|
|||
'total' => get_metadata( 'order_item', $item->get_id(), '_line_total', true ),
|
||||
'taxes' => get_metadata( 'order_item', $item->get_id(), '_line_tax_data', true ),
|
||||
) );
|
||||
$item->set_object_read( true );
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -35,6 +35,7 @@ class WC_Order_Item_Product_Data_Store extends Abstract_WC_Order_Item_Type_Data_
|
|||
'total' => get_metadata( 'order_item', $item->get_id(), '_line_total', true ),
|
||||
'taxes' => get_metadata( 'order_item', $item->get_id(), '_line_tax_data', true ),
|
||||
) );
|
||||
$item->set_object_read( true );
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -31,6 +31,7 @@ class WC_Order_Item_Shipping_Data_Store extends Abstract_WC_Order_Item_Type_Data
|
|||
'total' => get_metadata( 'order_item', $item->get_id(), 'cost', true ),
|
||||
'taxes' => get_metadata( 'order_item', $item->get_id(), 'taxes', true ),
|
||||
) );
|
||||
$item->set_object_read( true );
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -33,6 +33,7 @@ class WC_Order_Item_Tax_Data_Store extends Abstract_WC_Order_Item_Type_Data_Stor
|
|||
'tax_total' => get_metadata( 'order_item', $item->get_id(), 'tax_amount', true ),
|
||||
'shipping_tax_total' => get_metadata( 'order_item', $item->get_id(), 'shipping_tax_amount', true ),
|
||||
) );
|
||||
$item->set_object_read( true );
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue