WordPress at Your Fingertips
function is not described

WC_Coupon_Data_Store_CPT::get_ids_by_code() public WC 3.0.0

Return an array of IDs for for a specific coupon code. Can return multiple to check for existence.

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

No Hooks.


Array. Array of IDs.


$WC_Coupon_Data_Store_CPT = new WC_Coupon_Data_Store_CPT();
$WC_Coupon_Data_Store_CPT->get_ids_by_code( $code );
$code(string) (required)
Coupon code.


Since 3.0.0 Introduced.

Code of WC_Coupon_Data_Store_CPT::get_ids_by_code() WC 5.8.0

public function get_ids_by_code( $code ) {
	global $wpdb;
	return $wpdb->get_col(
			"SELECT ID FROM $wpdb->posts WHERE post_title = %s AND post_type = 'shop_coupon' AND post_status = 'publish' ORDER BY post_date DESC",
			wc_sanitize_coupon_code( $code )