It is difficult to allow for every eventuality and a hook will allow making changes to the array holding the delivery time slots.
The hook_commerce_delivery_times_alter() will be triggered once the entire slots array is loaded and will allow custom modules to make changes to that array.
it will allow for the following:

  • Removing complete days
  • Clearing individual time slots
  • Changing the number of delivery time slots available
  • Change the display

extract of the array:

<?php
Array
(
    [2014-01-14] => Array
        (
            [display] => Tomorrow<br /><span>Tue 14/01</span>
            [slots] => Array
                (
                    [06:00] => Array
                        (
                            [deliveries] => 10
                            [timestamp] => 1389664800
                            [display] => 06-08
                        )

                    [08:00] => Array
                        (
                            [deliveries] => 10
                            [timestamp] => 1389672000
                            [display] => 08-10
                        )
?>

Example of removing the 1'st of Jan from the time slots array:

<?php
/**
 * Implements hook_commerce_delivery_times_alter().
 */
function mymodule_commerce_delivery_times_alter(&$timeslots) {
  $d = date("Y") . '-01-01';
  if(isset($timeslots[$d])) {
    // Remove the day.
    unset($timeslots[$d]);
  }
}
?>

Comments

guy_schneerson’s picture

Issue summary: View changes
guy_schneerson’s picture

guy_schneerson’s picture

Issue summary: View changes
guy_schneerson’s picture

Title: Add a drupal_alter so custom modules can override the delivery times. » Add a hook_commerce_delivery_times_alter() so custom modules can override the delivery times.
Issue summary: View changes

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.