WC_Coupon_Data_Store_CPT::get_tentative_usage_query
Generate query to calculate tentative usages for the coupon.
Метод класса: WC_Coupon_Data_Store_CPT{}
Хуков нет.
Возвращает
Строку. Query for tentative usages.
Использование
// private - только в коде основоного (родительского) класса $result = $this->get_tentative_usage_query( $coupon_id );
- $coupon_id(int) (обязательный)
- Coupon ID to get tentative usage query for.
Код WC_Coupon_Data_Store_CPT::get_tentative_usage_query() WC Coupon Data Store CPT::get tentative usage query WC 10.7.0
private function get_tentative_usage_query( $coupon_id ) {
global $wpdb;
return $wpdb->prepare(
"
SELECT COUNT(meta_id) FROM $wpdb->postmeta
WHERE {$wpdb->postmeta}.meta_key like %s
AND {$wpdb->postmeta}.meta_key > %s
AND {$wpdb->postmeta}.post_id = %d
FOR UPDATE
",
array(
'_coupon_held_%',
'_coupon_held_' . time(),
$coupon_id,
)
); // WPCS: unprepared SQL ok.
}