Recomputing Delivery Windows

Last updated: February 6, 2025

This article describes how the system automatically recomputes delivery windows, ensuring that orders remain current and deliverable after the originally scheduled dropoff time has passed.

Overview

The recompute delivery windows feature guarantees that orders with expired time frames are automatically updated to reflect new valid delivery slots. The recomputation is triggered under two conditions:

  1. The order is tagged with "first_delivery_window"

  2. The current dropoff time has passed

By utilizing this feature, we prevent orders from being stuck with outdated delivery times. For example, if a customer has an order scheduled for delivery between 2 PM and 4 PM and the current time is 4:05 PM, the system will automatically recalculate and provide new available time slots.

How It Works

The recomputation process is executed via the _compute_first_delivery_window() method, which is called during order updates to assess whether delivery windows need to be recalculated.

Triggering Recomputation

The system checks two conditions before initiating recomputation:

  1. The order must have a "first_delivery_window" tag

  2. The dropoff time must have passed

If both conditions are met, the system automatically recalculates the delivery windows to ensure the order remains deliverable.

Updating Delivery Windows

The _compute_first_delivery_window() method performs three key tasks:

  1. Calculates new valid time slots: Generates delivery time frames based on current availability

  2. Updates the order: Applies the newly computed delivery windows to provide accurate estimates

  3. Ensures future dropoff times: Sets the order's dropoff time to a future date to prevent confusion

Benefits

The recompute delivery windows feature offers four primary advantages:

  1. Prevents Stale Orders: Automatically updates expired delivery windows, preventing orders from becoming undeliverable

  2. Improves Efficiency: Enables more effective scheduling and management of deliveries, reducing delays

  3. Enhances Customer Experience: Provides customers with accurate delivery estimates without manual intervention

  4. Reduces Manual Updates: Minimizes the need for staff to manually adjust expired delivery windows