Skip to content
Docs
Get RestroPress

Filter

rpress_is_discount_used

Updated
On this page

Filters whether a single-use discount has already been redeemed by the customer.

Runs at the end of RPRESS_Discount::is_used(). The value is only true when the discount is single use and an earlier non-abandoned, non-failed, non-pending order by the same customer used its code. The user value is an email address or a user identifier, depending on what the caller supplied.

Available since RestroPress 1.0.6.

Parameters#

ParameterTypeDescription
$returnboolWhether the discount has been used.
$IDintDiscount ID.
$userstringUser info (email address or user identifier) the check was run for.

Return value#

bool. True if the discount should be treated as already used.

Example#

function my_discount_is_used( $return, $discount_id, $user ) {
	// Allow staff to reuse single-use discounts.
	if ( is_email( $user ) && false !== strpos( $user, '@example.com' ) ) {
		return false;
	}
	return $return;
}
add_filter( 'rpress_is_discount_used', 'my_discount_is_used', 10, 3 );

Source#

Applied in:

  • includes/class-rpress-discount.php (line 1754), in RPRESS_Discount::is_used()

See also#

Was this page helpful?