<script>
jQuery(function ($) {

    function getCurrentMinutes() {
        var now = new Date();
        return (now.getHours() * 60) + now.getMinutes();
    }

    function isToday(dateText) {
        var today = new Date();

        var formatted = $.datepicker.formatDate(
            'dd M yy',
            new Date(today.getFullYear(), today.getMonth(), today.getDate())
        );

        return formatted === dateText;
    }

    function filterSlots(dateText) {

        // Show all slots first
        $('.slot').show();

        // If not today's date, keep all slots visible
        if (!isToday(dateText)) {
            return;
        }

        var mins = getCurrentMinutes();

        $('.slot').each(function () {

            var txt = $(this).text();

            // 07 AM - 09 AM (hide after 08:00 AM)
            if (txt.indexOf('07:00 AM') !== -1 && mins >= 480) {
                $(this).hide();
            }

            // 09 AM - 01 PM (hide after 12:00 PM)
            if (txt.indexOf('09:00 AM') !== -1 && mins >= 720) {
                $(this).hide();
            }

            // 01 PM - 05 PM (hide after 04:00 PM)
            if (txt.indexOf('01:00 PM') !== -1 && mins >= 960) {
                $(this).hide();
            }

            // 05 PM - 10 PM (hide after 09:00 PM)
            if (txt.indexOf('05:00 PM') !== -1 && mins >= 1260) {
                $(this).hide();
            }

            // 11 PM - 12 AM (always available until midnight)
            if (txt.indexOf('11:00 PM') !== -1) {
                $(this).show();
            }

        });
    }

    var now = new Date();
    var minDate = 0;

    if (now.getHours() === 0 && now.getMinutes() > 0) {
        minDate = 1;
    }

    $('#delivery_date').datepicker({
        minDate: minDate,
        dateFormat: 'dd M yy',

        onSelect: function (dateText) {
            filterSlots(dateText);
            $('#time-slot-buttons').slideDown();
        }
    });

    // Auto-select tomorrow after 9 PM
    if (getCurrentMinutes() >= 1260) {
        var tomorrow = new Date();
        tomorrow.setDate(tomorrow.getDate() + 1);
        $('#delivery_date').datepicker('setDate', tomorrow);
    }

    $('.date-box').on('click', function () {
        $('#delivery_date').datepicker('show');
    });

    // Clear session
    $.post(wc_checkout_params.ajax_url, {
        action: 'clear_delivery_session'
    });

    // Slot selection
    $(document).on('click', '.slot', function () {

        var selectedText = $(this).text();
        var charge = $(this).data('charge');

        $('.slot').removeClass('active');
        $(this).addClass('active');

        $('#delivery_time_slot').val(selectedText);

        $('#selected-slot')
            .text('Selected: ' + selectedText + ' (Click to change)')
            .fadeIn();

        setTimeout(function () {
            $('#time-slot-buttons').slideUp();
        }, 200);

        $.ajax({
            url: wc_checkout_params.ajax_url,
            type: 'POST',
            data: {
                action: 'set_delivery_data',
                charge: charge,
                slot: selectedText
            },
            success: function () {
                $('body').trigger('update_checkout');
            }
        });

    });

    $('#selected-slot').on('click', function () {
        $('#time-slot-buttons').slideDown();
    });

});
</script><?xml version="1.0" encoding="UTF-8"?><?xml-stylesheet type="text/xsl" href="//creamys.co.in/wp-content/plugins/wordpress-seo/css/main-sitemap.xsl"?>
<sitemapindex xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
	<sitemap>
		<loc>https://creamys.co.in/page-sitemap.xml</loc>
		<lastmod>2026-03-26T10:17:31+00:00</lastmod>
	</sitemap>
	<sitemap>
		<loc>https://creamys.co.in/blocks-sitemap.xml</loc>
		<lastmod>2016-09-04T15:57:34+00:00</lastmod>
	</sitemap>
	<sitemap>
		<loc>https://creamys.co.in/product-sitemap.xml</loc>
		<lastmod>2026-06-02T19:02:59+00:00</lastmod>
	</sitemap>
	<sitemap>
		<loc>https://creamys.co.in/featured_item-sitemap.xml</loc>
		<lastmod>2016-08-28T09:39:54+00:00</lastmod>
	</sitemap>
	<sitemap>
		<loc>https://creamys.co.in/product_cat-sitemap.xml</loc>
		<lastmod>2026-06-02T19:02:59+00:00</lastmod>
	</sitemap>
	<sitemap>
		<loc>https://creamys.co.in/product_tag-sitemap.xml</loc>
		<lastmod>2026-06-02T18:02:23+00:00</lastmod>
	</sitemap>
	<sitemap>
		<loc>https://creamys.co.in/featured_item_category-sitemap.xml</loc>
		<lastmod>2016-08-28T09:39:54+00:00</lastmod>
	</sitemap>
</sitemapindex>
<!-- XML Sitemap generated by Yoast SEO -->