WC_Order_Item::offsetGet( string $offset )
OffsetGet for ArrayAccess.
Description Description
Parameters Parameters
- $offset
-
(Required) Offset.
Return Return
(mixed)
Source Source
File: includes/class-wc-order-item.php
public function offsetGet( $offset ) { $this->maybe_read_meta_data(); if ( 'item_meta_array' === $offset ) { $return = array(); foreach ( $this->meta_data as $meta ) { $return[ $meta->id ] = $meta; } return $return; } $meta_values = wp_list_pluck( $this->meta_data, 'value', 'key' ); if ( 'item_meta' === $offset ) { return $meta_values; } elseif ( 'type' === $offset ) { return $this->get_type(); } elseif ( array_key_exists( $offset, $this->data ) ) { $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 ]; } elseif ( array_key_exists( $offset, $meta_values ) ) { return $meta_values[ $offset ]; } return null; }