Automattic\WooCommerce\Admin\API\Reports\Coupons
DataStore::get_coupons()
Gets coupons based on the provided arguments.
Метод класса: DataStore{}
Хуков нет.
Возвращает
Массив
. Array of results.
Использование
$DataStore = new DataStore(); $DataStore->get_coupons( $args );
- $args(массив) (обязательный)
- Array of args to filter the query by. Supports include.
Код DataStore::get_coupons() DataStore::get coupons WC 9.7.1
public function get_coupons( $args ) { global $wpdb; $query = "SELECT ID, post_title FROM {$wpdb->posts} WHERE post_type='shop_coupon'"; $included_coupons = $this->get_included_coupons( $args, 'include' ); if ( ! empty( $included_coupons ) ) { $query .= " AND ID IN ({$included_coupons})"; } return $wpdb->get_results( $query ); // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared }