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.

3 thoughts on “Disable weekends in magento date picker?”

  1. Try this code.

    $( "#date_pickrer_id" ).datepicker({
      beforeShowDay: $.datepicker.noWeekends
    });
    

    you can also hide them using css.

    th.ui-datepicker-week-end,
    td.ui-datepicker-week-end {
        display: none;
    }
    
    Reply
  2. 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.

    Reply
  3. Unsure if solved, however, for disabling weekends this could be tried:

    if((date.getDay() == 5) || (date.getDay() == 0 )){
        return true;
    }else{
        return false;
    }
    
    Reply

Leave a Comment