Automattic\WooCommerce\Internal\DataStores\Orders
OrdersTableDataStore::get_orders_type()
Fetch order type for orders in bulk.
Method of the class: OrdersTableDataStore{}
No Hooks.
Return
Array
. array( $order_id1 => $type1, ... ) Array for all orders.
Usage
$OrdersTableDataStore = new OrdersTableDataStore(); $OrdersTableDataStore->get_orders_type( $order_ids );
- $order_ids(array) (required)
- Order IDs.
OrdersTableDataStore::get_orders_type() OrdersTableDataStore::get orders type code WC 9.3.3
public function get_orders_type( $order_ids ) { global $wpdb; if ( empty( $order_ids ) ) { return array(); } $orders_table = self::get_orders_table_name(); $order_ids_placeholder = implode( ', ', array_fill( 0, count( $order_ids ), '%d' ) ); // phpcs:disable WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare $results = $wpdb->get_results( $wpdb->prepare( "SELECT id, type FROM {$orders_table} WHERE id IN ( $order_ids_placeholder )", $order_ids ) ); // phpcs:enable $order_types = array(); foreach ( $results as $row ) { $order_types[ $row->id ] = $row->type; } return $order_types; }