Limiting options in the date picker

By default, the date picker in the Self Service Center that aids clients to select the next shipment date is not limited in any way. This means that clients can select any day of the week, years in advance.

For certain companies, this is not suitable. For example, some companies do not ship parcels during the weekend or only ship on dedicated days in the week.

In such cases, it is better to limit the date picker to avoid setting certain expectations for clients that can’t be met. At the moment, this can be done through custom code in the SSC page.

Here is an example of limiting the dates available in the calendar only to Wednesdays.

<script>
   document.querySelector("body").on("click",".adjust-shipment-date-picker",function(e) {
      enableWednesdays()
   })

   document.querySelector("body").on("click",".form-input-public,.flatpickr-next-month,.flatpickr-prev-month,.numInputWrapper .arrowUp,.numInputWrapper .arrowDown",function(e) {
      enableWednesdays()
   })

   document.querySelector("body").on("change",".flatpickr-monthDropdown-months",function() {
      enableWednesdays()
   })

   function enableWednesdays() {
      let targetIndex = 3;

      document.querySelector(".flatpickr-calendar .flatpickr-day").each(function(index){
         
         if (index == 3 || index == targetIndex) {
            targetIndex += 7;
         } else {
            document.querySelector(this).addClass("flatpickr-disabled");
         }
      })
   }
</script>