OrdersTableDataStore::get_order_id_by_order_key()publicWC 1.0

Finds an Order ID based on an order key.

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

Хуков нет.


int. The ID of an order, or 0 if the order could not be found


$OrdersTableDataStore = new OrdersTableDataStore();
$OrdersTableDataStore->get_order_id_by_order_key( $order_key );
$order_key(строка) (обязательный)
An order key has generated by.

Код OrdersTableDataStore::get_order_id_by_order_key() WC 8.9.0

public function get_order_id_by_order_key( $order_key ) {
	global $wpdb;

	$orders_table = self::get_orders_table_name();
	$op_table     = self::get_operational_data_table_name();

	// phpcs:disable WordPress.DB.PreparedSQL.InterpolatedNotPrepared
	return (int) $wpdb->get_var(
			"SELECT {$orders_table}.id FROM {$orders_table}
			INNER JOIN {$op_table} ON {$op_table}.order_id = {$orders_table}.id
			WHERE {$op_table}.order_key = %s AND {$op_table}.order_key != ''",
	// phpcs:enable