Skip to content
Docs
Get RestroPress

Filter

rpress_is_discount_products_req_met

Updated
On this page

Filters whether the cart satisfies a discount's menu item requirements.

Runs at the end of RPRESS_Discount::is_product_requirements_met(). The result is cast to bool. The product condition is the discount's setting that decides how the required menu items must match the cart contents (all required items must be in the cart, or any one of them). Use it to add custom requirements or relax the built-in ones.

Available since RestroPress 1.0.6.

Parameters#

ParameterTypeDescription
$returnboolWhether the menu item requirements are met.
$IDintDiscount ID.
$product_conditionstringThe discount's product condition setting.

Return value#

bool. True if the menu item requirements are met.

Example#

function my_discount_products_req( $return, $discount_id, $product_condition ) {
	// Never apply discount 123 when the cart contains a gift card item.
	if ( 123 === (int) $discount_id && rpress_item_in_cart( 999 ) ) {
		return false;
	}
	return $return;
}
add_filter( 'rpress_is_discount_products_req_met', 'my_discount_products_req', 10, 3 );

Source#

Applied in:

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

See also#

Was this page helpful?