Magento datepicker should only enable two days aft

2019-09-03 12:16发布

问题:

I have added datepicker in my magento checkout page by the use of this tutorial:

Tutorial

It is working fine. What I need is The datepicker should enable dates after two dates from today. Suppose I am purchasing on May 1 then then I can select May 3 only as delivery date, It should show only those dates(today+48 hours). How can I do that?

回答1:

function dateRange(date) 
 {
    var today = new Date();
     var dd = today.getDate();
     // Put your logic here, I'm just guessing below logic. 
     return date.getDate() > dd + 48 ;   
 }

 Calendar.setup({
  inputField  : "date",
  ifFormat    : "%m/%e/%Y",
  dateStatusFunc : dateRange,
  button      : "aw_sarp_subscription_start_trig",
  align       : "Bl",
  dateStatusFunc : dateRange
  });

I think this question might help you. https://magento.stackexchange.com/questions/33534/disable-future-dates-in-magento-datepicker