WC_Coupon_Data_Store_CPT::get_ids_by_code()publicWC 3.0.0

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

Метод класса: WC_Coupon_Data_Store_CPT{}

Хуков нет.

Возвращает

Массив. 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(строка) (обязательный)
Coupon code.

Список изменений

С версии 3.0.0 Введена.

Код WC_Coupon_Data_Store_CPT::get_ids_by_code() WC 8.7.0

public function get_ids_by_code( $code ) {
	global $wpdb;
	return $wpdb->get_col(
		$wpdb->prepare(
			"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 )
		)
	);
}