Automattic\WooCommerce\Internal\DataStores\Orders

OrdersTableDataStore::get_db_row_from_order()protectedWC 6.8.0

$format parameters. Values are taken from the order changes array and properly formatted for inclusion in the database.

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

Хуков нет.

Возвращает

Массив.

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

// protected - в коде основоного (родительского) или дочернего класса
$result = $this->get_db_row_from_order( $order, $column_mapping, $only_changes );
$order(\WC_Order) (обязательный)
Order.
$column_mapping(массив) (обязательный)
Table column mapping.
$only_changes(true|false)
Whether to consider only changes in the order object or all fields.
По умолчанию: false

Список изменений

С версии 6.8.0 Введена.

Код OrdersTableDataStore::get_db_row_from_order() WC 6.9.4

protected function get_db_row_from_order( $order, $column_mapping, $only_changes = false ) {
	$changes = $only_changes ? $order->get_changes() : array_merge( $order->get_data(), $order->get_changes() );

	// XXX: manually persist some of the properties until the datastore/property design is finalized.
	foreach ( $this->get_internal_data_store_keys() as $key ) {
		$changes[ $key ] = $this->{"get_$key"}( $order );
	}

	// Make sure 'status' is correct.
	if ( array_key_exists( 'status', $column_mapping ) ) {
		$changes['status'] = $this->get_post_status( $order );
	}

	$row        = array();
	$row_format = array();

	foreach ( $column_mapping as $column => $details ) {
		if ( ! isset( $details['name'] ) || ! array_key_exists( $details['name'], $changes ) ) {
			continue;
		}

		$row[ $column ]        = $this->database_util->format_object_value_for_db( $changes[ $details['name'] ], $details['type'] );
		$row_format[ $column ] = $this->database_util->get_wpdb_format_for_type( $details['type'] );
	}

	if ( ! $row ) {
		return false;
	}

	return array(
		'data'   => $row,
		'format' => $row_format,
	);
}