WC_Coupon_Data_Store_CPT::get_usage_by_email( WC_Coupon $coupon, string $email )

Get the number of uses for a coupon by email address


Description Description


Parameters Parameters

$coupon

(Required) Coupon object.

$email

(Required) Email address.


Top ↑

Return Return

(int)


Top ↑

Source Source

File: includes/data-stores/class-wc-coupon-data-store-cpt.php

	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;
	}

Top ↑

Changelog Changelog

Changelog
Version Description
3.6.4 Introduced.


Top ↑

User Contributed Notes User Contributed Notes

You must log in before being able to contribute a note or feedback.