WC_Coupon_Data_Store_CPT::get_ids_by_code
Return an array of IDs for for a specific coupon code. Can return multiple to check for existence.
Метод класса: WC_Coupon_Data_Store_CPT{}
Хуков нет.
Возвращает
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(строка) (обязательный)
- Coupon code.
Список изменений
| С версии 3.0.0 | Введена. |
Код WC_Coupon_Data_Store_CPT::get_ids_by_code() WC Coupon Data Store CPT::get ids by code WC 11.3.0
public function get_ids_by_code( $code ) {
global $wpdb;
return $wpdb->get_col(
$wpdb->prepare(
"SELECT ID FROM $wpdb->posts WHERE LOWER(post_title) = LOWER(%s) AND post_type = 'shop_coupon' AND post_status = 'publish' ORDER BY post_date DESC",
wc_sanitize_coupon_code( $code )
)
);
}