Automattic\WooCommerce\Internal\DataStores\Orders

OrdersTableDataStore::read()publicWC 1.0

Method to read an order from custom tables.

{} Это метод класса: OrdersTableDataStore{}

Хуков нет.

Возвращает

null. Ничего.

Использование

$OrdersTableDataStore = new OrdersTableDataStore();
$OrdersTableDataStore->read( $order );
$order(\WC_Order) (обязательный) (передается по ссылке — &)
Order object.

Код OrdersTableDataStore::read() WC 6.6.1

public function read( &$order ) {
	$order->set_defaults();
	if ( ! $order->get_id() ) {
		throw new \Exception( __( 'ID must be set for an order to be read', 'woocommerce' ) );
	}
	$order->read_meta_data();
	$order_data = $this->get_order_data_for_id( $order->get_id() );
	foreach ( $this->get_all_order_column_mappings() as $table_name => $column_mapping ) {
		foreach ( $column_mapping as $column_name => $prop_details ) {
			if ( ! isset( $prop_details['name'] ) ) {
				continue;
			}
			$prop_setter_function_name = "set_{$prop_details['name']}";
			if ( is_callable( array( $order, $prop_setter_function_name ) ) ) {
				$order->{$prop_setter_function_name}( $order_data->{$prop_details['name']} );
			} elseif ( is_callable( array( $this, $prop_setter_function_name ) ) ) {
				$this->{$prop_setter_function_name}( $order, $order_data->{$prop_details['name']} );
			}
		}
	}

	$order->set_object_read();
}