Ameliabooking_Helpers::get_coupon_usage_count( int $coupon_id )

Fetches the total coupon usage.


Parameters Parameters

$coupon_id

(Required) The coupon ID.


Top ↑

Return Return

(int) The number of coupons left.


Source Source

File: src/integrations/ameliabooking/helpers/ameliabooking-helpers.php

	public function get_coupon_usage_count( $coupon_id ) {
		global $wpdb;
		$results = $wpdb->get_row(
			$wpdb->prepare(
				"SELECT count(*) as total FROM {$wpdb->prefix}amelia_customer_bookings 
					WHERE couponId = %d",
				$coupon_id
			),
			ARRAY_A
		);
		return isset( $results['total'] ) ? absint( $results['total'] ) : 0;
	}