public function itemMatchesCriteria(OrderItem $item, Discount $discount) { $discountcategoryids = $discount->Categories()->getIDList(); if (empty($discountcategoryids)) { return true; } //get category ids from buyable $buyable = $item->Buyable(); if (!method_exists($buyable, "getCategoryIDs")) { return false; } $ids = array_intersect($buyable->getCategoryIDs(), $discountcategoryids); return !empty($ids); }