// if the line item has a restock time, add this days to the restock date
if($restockTime){ $restockDate = $restockDate->add(new \DateInterval('P' . $restockTime . 'D')); }
// if the item is completely in stock, use the delivery date
if($item->getDeliveryInformation()->getStock() >= $item->getQuantity()){ $position = newDeliveryPosition($item->getId(), clone$item, $item->getQuantity(), clone$item->getPrice(), $deliveryDate); }else{ // otherwise use the restock date as delivery date
$position = newDeliveryPosition($item->getId(), clone$item, $item->getQuantity(), clone$item->getPrice(), $restockDate); }