WordPress at Your Fingertips
function is not described

Automattic\WooCommerce\Admin\API\Reports\Orders

DataStore::get_coupons_by_order_ids() protected WC 1.0

Get coupon information from order IDs.

{} It's a method of the class: DataStore{}

No Hooks.

Return

Array.

Usage

// protected - for code of main (parent) or child class
$result = $this->get_coupons_by_order_ids( $order_ids );
$order_ids(array) (required)
Array of order IDs.

Code of DataStore::get_coupons_by_order_ids() WC 6.1.0

protected function get_coupons_by_order_ids( $order_ids ) {
	global $wpdb;
	$order_coupon_lookup_table = $wpdb->prefix . 'wc_order_coupon_lookup';
	$included_order_ids        = implode( ',', $order_ids );

	/* phpcs:disable WordPress.DB.PreparedSQL.InterpolatedNotPrepared */
	$coupons = $wpdb->get_results(
		"SELECT order_id, coupon_id, post_title as coupon_code
			FROM {$wpdb->posts}
			JOIN {$order_coupon_lookup_table} ON {$order_coupon_lookup_table}.coupon_id = {$wpdb->posts}.ID
			WHERE
				order_id IN ({$included_order_ids})
			",
		ARRAY_A
	);
	/* phpcs:enable */

	return $coupons;
}