WC_Order_Item::offsetSet()publicWC 1.0ReturnTypeWillChange

OffsetSet for ArrayAccess.

Method of the class: WC_Order_Item{}

No Hooks.

Return

null. Nothing (null).

Usage

$WC_Order_Item = new WC_Order_Item();
$WC_Order_Item->offsetSet( $offset, $value );
$offset(string) (required)
Offset.
$value(mixed) (required)
Value.

WC_Order_Item::offsetSet() code WC 8.9.0

public function offsetSet( $offset, $value ) {
	if ( 'item_meta_array' === $offset ) {
		foreach ( $value as $meta_id => $meta ) {
			$this->update_meta_data( $meta->key, $meta->value, $meta_id );
		}
		return;
	}

	if ( array_key_exists( $offset, $this->data ) ) {
		$setter = "set_$offset";
		if ( is_callable( array( $this, $setter ) ) ) {
			$this->$setter( $value );
		}
		return;
	}

	$this->update_meta_data( $offset, $value );
}