What are some best practices for adding a vorausichtliches Lieferdatum to a Bestellvorgang in PHP?

When adding a vorausichtliches Lieferdatum (expected delivery date) to a Bestellvorgang (ordering process) in PHP, it is important to calculate the estimated delivery date based on factors like processing time, shipping method, and any potential delays. One best practice is to store the estimated delivery date in the database along with the order details, so it can be easily retrieved and displayed to the customer.

// Calculate estimated delivery date based on processing time and shipping method
$processingTime = 2; // in days
$shippingMethod = 'Express'; // could be 'Standard', 'Express', etc.

if($shippingMethod == 'Express'){
    $estimatedDeliveryDate = date('Y-m-d', strtotime("+$processingTime days"));
} else {
    $estimatedDeliveryDate = date('Y-m-d', strtotime("+$processingTime + 3 days")); // add 3 days for standard shipping
}

// Save the estimated delivery date in the database along with other order details
// Assuming $orderDetails is an array containing the order details
$orderDetails['estimated_delivery_date'] = $estimatedDeliveryDate;

// Insert order details into the database
// $db->insert('orders', $orderDetails);