Skip to content
Docs
Get RestroPress

Filter

rpress_is_discount_categories_req_met

Updated
On this page

Filters whether the cart satisfies a discount's category requirements.

Runs at the end of RPRESS_Discount::is_categories_requirements_met(). The result is cast to bool. It reflects both the required and the excluded category settings of the discount against the current cart contents.

Available since RestroPress 2.9.2.

Parameters#

ParameterTypeDescription
$returnboolWhether the category requirements are met.
$IDintDiscount ID.

Return value#

bool. True if the category requirements are met.

Example#

function my_discount_categories_req( $return, $discount_id ) {
	// Treat discount 123 as category-agnostic.
	if ( 123 === (int) $discount_id ) {
		return true;
	}
	return $return;
}
add_filter( 'rpress_is_discount_categories_req_met', 'my_discount_categories_req', 10, 2 );

Source#

Applied in:

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

See also#

Was this page helpful?