Support » Plugin: PPOM for WooCommerce » How disable specific dates from the PPOM datepicker

  • Resolved jeff0504

    (@jeff0504)


    Hi,

    How to disable specific dates form the date picker. I need help blocking out Sunday, Monday and Tuesday from the calendar and few particular dates.

    I am trying to use a jquery to implement this. So far I have written this below code but seems to be not working:

    var dateToday = new Date();
    jQuery(document).ready(function(){
    jQuery(‘#preferred_collection_date’).datepicker({
    beforeShowDay: checkAvailable,
    minDate: dateToday
    });
    });

    var unavailableDates = [“19-11-2020″,”1-12-2020″,”15-11-2020”];

    function checkAvailable(date) {
    dmy = date.getDate() + “-” + (date.getMonth() + 1) + “-” + date.getFullYear();
    if (jQuery.inArray(dmy, unavailableDates) != -1) {

    return [false, “”, “unAvailable”];
    } else {
    var day = date.getDay();
    return [(day != 0 && day != 1 && day ! = 2)];
    }
    }

    Any help would really be appreciated. Thanks.

    • This topic was modified 1 year ago by jeff0504.

    The page I need help with: [log in to see the link]

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author N-Media

    (@nmedia)

    Hi,

    Sorry, you need to change this in the core plugin js file (js/ppom-input.js) otherwise the plugin setting will override your jquery code.

    Thread Starter jeff0504

    (@jeff0504)

    Hi,

    Thanks for writing back, do you have a code snippet or can please point me in right direction to implement this. I am an intermediate developer and I don’t have much of an experience with jquery

    This is the code I see on the backend to fiddle the date picker:

    case ‘date’:
    if (input.jquery_dp === ‘on’) {

    InputSelector.datepicker(“destroy”);
    InputSelector.datepicker({
    changeMonth: true,
    changeYear: true,
    dateFormat: input.date_formats,
    yearRange: input.year_range,
    });

    if (typeof input.past_dates !== ‘undefined’) {
    if (input.past_dates.length > 0) {
    var minDate = input.past_dates.trim();

    // accommodate for previous values with “on” as the option
    if (minDate === “on”) { minDate = new Date(); }
    InputSelector.datepicker(‘option’, ‘minDate’, minDate);
    }
    }

    if (input.no_weekends === ‘on’) {
    InputSelector.datepicker(‘option’, ‘beforeShowDay’, jQuery.datepicker.noWeekends);
    }

    }

    Plugin Author N-Media

    (@nmedia)

    Well, we don’t recommend making change in the core plugin because it will be broken in new updates.

    Anyways, here you can do, comment on the entire case above from the code you mentioned and then add your own JS in this case.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘How disable specific dates from the PPOM datepicker’ is closed to new replies.