WordPress at Your Fingertips
function is not described


DataStore::get_coupons() public WC 1.0

Gets coupons based on the provided arguments.

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

No Hooks.


Array. Array of results.


$DataStore = new DataStore();
$DataStore->get_coupons( $args );
$args(array) (required)
Array of args to filter the query by. Supports include.

Code of DataStore::get_coupons() WC 6.1.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