llms_find_coupon( string $code = '', int $dupcheck_id )

Get the most recently created coupon ID for a given code


Parameters Parameters

$code

(string) (Optional) The coupon's code (title). Default is empty string.

Default value: ''

$dupcheck_id

(int) (Optional) Coupon id that can be passed which will be excluded during the query this is used to dupcheck the coupon code during coupon creation. Default is 0.


Top ↑

Return Return

(int)


Top ↑

Source Source

File: includes/llms.functions.core.php

 */
function llms_find_coupon( $code = '', $dupcheck_id = 0 ) {

	global $wpdb;
	return $wpdb->get_var(
		$wpdb->prepare(
			"SELECT ID
		 FROM {$wpdb->posts}
		 WHERE post_title = %s
		 AND post_type = 'llms_coupon'
		 AND post_status = 'publish'
		 AND ID != %d
		 ORDER BY ID desc;
		",
			array( $code, $dupcheck_id )
		)
	); // no-cache ok.



Top ↑

Changelog Changelog

Changelog
Version Description
3.0.0 Introduced.

Top ↑

User Contributed Notes User Contributed Notes

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