Closed (fixed)
Project:
Commerce delivery times
Component:
Code
Priority:
Normal
Category:
Feature request
Assigned:
Reporter:
Created:
13 Jan 2014 at 11:08 UTC
Updated:
27 Jan 2014 at 13:40 UTC
Jump to comment: Most recent
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:
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
Comment #1
guy_schneerson commentedComment #2
guy_schneerson commentedCommitted http://drupalcode.org/sandbox/guy_schneerson/2152365.git/commit/253fbf7
Comment #3
guy_schneerson commentedComment #4
guy_schneerson commented