Add pre_hold_offset. hook quantity + item scheduler.
[order_line_extra.git] / includes / order_xtra_config.inc
index 6ef484b062e52e6445088b69f1f908445b919441..fc04b7f2a1d9b3a12fb4b9b4280442aecd6dd08c 100644 (file)
@@ -1,4 +1,6 @@
 <?php
+require_once($path_to_root.'/'.'includes/date_functions.inc');
+
 class OrderXtraConfig {
        // Location code of the default or main location
        static $default_location = "";
@@ -6,7 +8,10 @@ class OrderXtraConfig {
        // Array location => { delivery, parent }
        // Location not listed are excluded
        static $locations= array();
+       //  control how many days before are holded item 'visible'
+       static $pre_hold_offset=7;
 
+       // Return delivery date for a give location
        static function delivery($location) {
                        if(isset(self::$locations[$location])) {
                        $parameters = self::$locations[$location];
@@ -16,5 +21,11 @@ class OrderXtraConfig {
                                return null;
                        }
                }
+
+       // True if the date before hold_until_date
+       static function early($hold_until_date, $date) {
+               // hold - 7 > date 
+               return date_diff2($hold_until_date, $date, 'd') > OrderXtraConfig::$pre_hold_offset;
+       }
 }
 ?>