Skip to content
Advertisement

Disable weekends in magento date picker?

I would like to disable the weekend (saturday and sunday) in Magento default date picker. Is it possible in magento date picker?

Also i would like to disable the some other day’s based on the store holiday’s. So is this options as possible to do in Magento date picker.

Advertisement

Answer

I have not tried this but this is a guide to helps you

Calendar used by magento is located here : /js/calendar/calendar.js

and from its header you find that it is done by dynarch.com

You will see there is built in functionality (via a callback) to disable dates. (http://www.dynarch.com/jscal/#sec8)

it seems you can do this in following ways :

Calendar.setup({
    cont: "sample1",
    min: 20090408,
    max: 20091225
});

OR

Calendar.setup({
    cont: "sample2",
    disabled: function(date) {
        if (date.getDay() == 5) {
            return true;
        } else {
            return false;
        }
    }
});

To extend magento calendar creation, you need to create your own class, which extends the core Varien_Data_Form_Element_Date class

You will need to override the getElementHtml() method, which contains the calandar setup script code and include the callback and dates you have, as per the calendar docs.

Please check and revert if this helps.

User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement