Display date picker in Magento checkout page

Display date picker in Magento checkout page

August 27, 2026 · Illustrated author avatarBy Stefan Bogdanescu
Display date picker in Magento checkout page

Display Date Picker in Magento Checkout Page: A Comprehensive Guide

As an e-commerce developer, you might find yourself wanting to add a date picker to your Magento checkout page for various purposes—from setting delivery dates to scheduling appointments. However, the process isn’t always straightforward, especially for those new to the platform.

Let’s dive into the query raised by our reader and provide a step-by-step solution to display a date picker in the Magento checkout page.

The Issue: Incorrect Configuration

Our reader has attempted to add a date picker using the following steps:

  1. Placing layout XML code in app/design/frontend/default/yourthemename/layout/page.xml to load the necessary JavaScript and CSS files for the calendar.
  2. Adding a block declaration for the calendar view.
  3. Attempting to call these elements from an IndexController.php file within their test module.

However, this approach has two primary issues:

Firstly, the layout XML should not be placed in the default theme folder but rather within your custom theme’s layout directory (e.g., app/design/frontend/your_vendor/your_theme/layout/page.xml).

Secondly, trying to call these calendar elements directly from a controller file is incorrect. Magento follows a MVC (Model-View-Controller) architecture, and such UI-related changes should be handled through the view layer.

The Solution: Proper Magento Layout Configuration

To display a date picker in your checkout page, you need to follow these steps:

  1. Create a custom theme or modify an existing one.
  2. In your theme’s layout directory (app/design/frontend/your_vendor/your_theme/layout), create a new XML file (e.g., checkout.xml).
  3. Add the following code within the <layout> element in checkout.xml:
<default>
    <reference name="head">
        <action method="addJs">
            <translate>js/calendar.js</translate>
        </action>
        <action method="addCss">
            <translate>js/calendar/calendar-win2k-1.css</translate>
        </action>
    </reference>
    <reference name="checkout.steps">
        <block type="core/html_calendar" name="checkout.calendar"
               template="page/js/calendar.phtml"/>
    </reference>
</default>

This layout configuration ensures that the necessary JavaScript and CSS files for the calendar are loaded on the checkout page.

  1. Create a new block template file app/design/frontend/your_vendor/your_theme/template/page/html/calendar.phtml with the following content:
<script type="text/javascript">
    //<![CDATA[
    Calendar.setup({
        inputField: 'delivery_date',   // ID of the input field
        ifFormat: '%m/%d/%Y',  // Format of the date, when it is displayed in the input field
        button: 'delivery_date_trig',  // The ID of the button
        align: 'Bl'       // Alignment of the popup calendar
    });
    //]]>
</script>

<div class="field">
    <label for="delivery_date"><?php echo $this->__(‘Delivery Date’) ?></label>
    <div class="input-box">
        <input type="text" id="delivery_date" name="delivery_date" class="input-text required-entry"/>
        <em>*</em>
        <img title="<?php echo $this->__('Select date') ?>" id="delivery_date_trig" src="<?php echo $this->getSkinUrl('images/calendar.gif'); ?>"
             class="v-middle">
    </div>
</div>

This template file creates the input field for the date picker and associates it with a trigger image.

  1. Call this block from your checkout page layout by adding the following code in app/design/frontend/your_vendor/your_theme/layout/checkout.xml:
<default>
    <reference name="checkout_steps">
        <block type="core/html_calendar" template="page/html/calendar.phtml"/>
    </reference>
</default>

Conclusion

To display a date picker in the Magento checkout page, you need to configure your theme’s layout files correctly. This involves loading the necessary JavaScript and CSS files for the calendar, creating a block declaration for the calendar view, and calling this block from your checkout page layout.

Remember that Magento follows an MVC architecture, so UI-related changes like adding date pickers should be handled through the view layer using layout XML files.

By following these steps, you can easily incorporate a date picker into your Magento checkout process, enhancing the user experience for your customers. If you need further assistance or want to learn more about customizing Magento themes and layouts, feel free to explore our comprehensive guides at Laravel Company.

Checkout Database Extensions Themes

Our network