WC_Coupon_Data_Store_CPT::get_usage_by_email()
Get the number of uses for a coupon by email address
Метод класса: WC_Coupon_Data_Store_CPT{}
Хуков нет.
Возвращает
int
.
Использование
$WC_Coupon_Data_Store_CPT = new WC_Coupon_Data_Store_CPT(); $WC_Coupon_Data_Store_CPT->get_usage_by_email( $coupon, $email );
- $coupon(WC_Coupon) (обязательный) (передается по ссылке — &)
- Coupon object.
- $email(строка) (обязательный)
- Email address.
Список изменений
С версии 3.6.4 | Введена. |
Код WC_Coupon_Data_Store_CPT::get_usage_by_email() WC Coupon Data Store CPT::get usage by email WC 8.7.0
public function get_usage_by_email( &$coupon, $email ) { global $wpdb; $usage_count = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT( meta_id ) FROM {$wpdb->postmeta} WHERE post_id = %d AND meta_key = '_used_by' AND meta_value = %s;", $coupon->get_id(), $email ) ); $tentative_usage_count = $this->get_tentative_usages_for_user( $coupon->get_id(), array( $email ) ); return $tentative_usage_count + $usage_count; }