WordPress at Your Fingertips
function is not described

WC_Coupon_Data_Store_CPT::get_usage_by_email() public WC 3.6.4

Get the number of uses for a coupon by email address

{} It's a method of the class: WC_Coupon_Data_Store_CPT{}

No Hooks.

Return

Int.

Usage

$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) (required) (passed by reference — &)
Coupon object.
$email(string) (required)
Email address.

Changelog

Since 3.6.4 Introduced.

Code of WC_Coupon_Data_Store_CPT::get_usage_by_email() WC 5.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;
}