delivery – Basket Item Count From Certain Departmartments at Checkout

The question is to do with adding code within Owebia Advanced Shipping Module, but I am hoping it may just be a simple syntax error I am not currently spotting.

Before the list of delivery methods, I am hoping to group department id’s together, and check how many products within this group are in the basket, and work the price out from there.

Here’s what I have written, appreciate help to get this working!

$group1 = function ($allItems) {
return array_sum(
    return array_map(
        function ($item) {
            return count(array_intersect($item->product->category_ids, (2, 3)))
            ? $item->qty 
            : 0;