if ($lineItem->
getPrice() === null
) { continue;
} // add as long as the minimum package value is not reached
if ($currentPackageSum >=
$minPackageValue) { break;
} // add the item to our result
// with the current quantity
$result->
addItem($lineItem->
getId(),
$lineItem->
getQuantity());
/** @var CalculatedPrice $price */
$price =
$lineItem->
getPrice();
$grossPrice =
$price->
getUnitPrice();
$currentPackageSum +=
$lineItem->
getQuantity() *
$grossPrice;
} // if we have less results than our max value
// return an empty list, because that is not a valid group