Automattic\WooCommerce\Admin\API\Reports\Coupons
DataStore::get_coupons()
Gets coupons based on the provided arguments.
Method of the class: DataStore{}
No Hooks.
Return
Array
. Array of results.
Usage
$DataStore = new DataStore(); $DataStore->get_coupons( $args );
- $args(array) (required)
- Array of args to filter the query by. Supports include.
DataStore::get_coupons() DataStore::get coupons code WC 9.3.3
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 }