WC_Coupon_Data_Store_CPT::get_tentative_usage_query()
Generate query to calculate tentative usages for the coupon.
Method of the class: WC_Coupon_Data_Store_CPT{}
No Hooks.
Return
String
. Query for tentative usages.
Usage
// private - for code of main (parent) class only $result = $this->get_tentative_usage_query( $coupon_id );
- $coupon_id(int) (required)
- 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 code WC 9.4.2
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. }