LLMS_Voucher::get_voucher_by_code( string $code )

Get a single voucher code by string


Parameters Parameters

$code

(string) (Required) Voucher code string.


Top ↑

Return Return

(obj)


Top ↑

Source Source

File: includes/class.llms.voucher.php

	public function get_voucher_by_code( $code ) {

		global $wpdb;

		$table          = $this->get_codes_table_name();
		$redeemed_table = $this->get_redemptions_table_name();

		$query = "SELECT c.*, count(r.id) as used
                  FROM $table as c
                  LEFT JOIN $redeemed_table as r
                  ON c.`id` = r.`code_id`
                  WHERE `code` = '$code' AND `is_deleted` = 0
                  GROUP BY c.id
                  LIMIT 1";
		return $wpdb->get_row( $query );
	}


Top ↑

Changelog Changelog

Changelog
Version Description
2.0.0 Introduced.

Top ↑

User Contributed Notes User Contributed Notes

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