# Delivery Time Slot Choice at Checkout

> Lets customers pick a delivery time window, such as morning or evening, on the classic checkout and saves it on the order for your drivers.

- Type: PHP
- Runs: Run everywhere
- Category: [WooCommerce](https://wpide.com/library/category/woocommerce/)
- Requires: WooCommerce
- Tags: woocommerce, checkout, delivery, fields
- Author: WPIDE Team
- Installs: 0
- Updated: 2026-10-28
- Page: https://wpide.com/library/woo-checkout-delivery-time-slot/

## Code

```php
$wpide_slots = array( // Key => label.
    'morning'   => 'Morning (8am to 12pm)',
    'afternoon' => 'Afternoon (12pm to 5pm)',
    'evening'   => 'Evening (5pm to 9pm)',
);

add_filter( 'woocommerce_checkout_fields', function ( $fields ) use ( $wpide_slots ) {
    $fields['order']['wpide_time_slot'] = array(
        'type'     => 'select',
        'label'    => 'Delivery time slot',
        'required' => true,
        'priority' => 6,
        'options'  => array( '' => 'Choose a time slot' ) + $wpide_slots,
    );

    return $fields;
} );

add_action( 'woocommerce_checkout_create_order', function ( $order, $data ) use ( $wpide_slots ) {
    $slot = (string) ( $data['wpide_time_slot'] ?? '' );

    if ( isset( $wpide_slots[ $slot ] ) ) {
        $order->update_meta_data( '_wpide_time_slot', $wpide_slots[ $slot ] );
    }
}, 10, 2 );

add_action( 'woocommerce_admin_order_data_after_shipping_address', function ( $order ) {
    $slot = $order->get_meta( '_wpide_time_slot' );

    if ( $slot ) {
        printf( '<p><strong>Delivery slot:</strong> %s</p>', esc_html( $slot ) );
    }
} );

add_filter( 'woocommerce_email_order_meta_fields', function ( $fields, $sent_to_admin, $order ) {
    $slot = $order->get_meta( '_wpide_time_slot' );

    if ( $slot ) {
        $fields['wpide_time_slot'] = array( 'label' => 'Delivery slot', 'value' => $slot );
    }

    return $fields;
}, 10, 3 );
```

## Notes

Edit $wpide_slots to match your delivery rounds; the chosen slot appears on the order screen and in order emails.

## How to use it

Install the free WPIDE plugin (https://wordpress.org/plugins/wpide/), find "Delivery Time Slot Choice at Checkout" in its snippet library and add it in one click; or create a new PHP snippet in WPIDE (or any code snippets plugin) and paste the code above. More snippets: https://wpide.com/library/
