Automattic\WooCommerce\Internal\DataStores\Orders
LegacyDataHandler::order_meta_to_array()
Returns all metadata in an order object as an array.
Method of the class: LegacyDataHandler{}
No Hooks.
Return
Array
. Array of metadata grouped by meta key.
Usage
// private - for code of main (parent) class only $result = $this->order_meta_to_array( $order ): array;
- $order(\WC_Order) (required)
- Order instance.
LegacyDataHandler::order_meta_to_array() LegacyDataHandler::order meta to array code WC 9.3.3
private function order_meta_to_array( \WC_Order &$order ): array { $result = array(); foreach ( ArrayUtil::select( $order->get_meta_data(), 'get_data', ArrayUtil::SELECT_BY_OBJECT_METHOD ) as &$meta ) { if ( array_key_exists( $meta['key'], $result ) ) { $result[ $meta['key'] ] = array( $result[ $meta['key'] ] ); $result[ $meta['key'] ][] = $meta['value']; } else { $result[ $meta['key'] ] = $meta['value']; } } return $result; }