示例#1
0
 public static function unusableDeliveryRates($earliest_delivery_date, $local_usable_rates)
 {
     $notUsable = array();
     if (self::getParam('delivtime') || self::getParam('delivdate')) {
         $todaytime = time();
         $tomorrowtime = $todaytime + 24 * 60 * 60;
         $today = self::getFormattedDate('Ymd', $todaytime);
         $tomorrow = self::getFormattedDate('Ymd', $tomorrowtime);
         $now = self::getFormattedDate('H:i', $todaytime);
         foreach ($local_usable_rates as $k => $rate) {
             if (!isset($rate->shipping_params->shipping_extra_deliv_dates)) {
                 // This indicates that the plugin delivery date settings
                 // were set BEFORE the BFManual Hikashop shipping method.
                 if (empty(self::$_warn1)) {
                     JError::raiseWarning(4720, 'Please contact System Administrator');
                     self::$_warn1 = array();
                 }
                 if (empty(self::$_warn1[$rate->shipping_id])) {
                     JError::raiseWarning(4720, 'Delivery day setup error: "' . $rate->shipping_name . '"');
                     self::$_warn1[$rate->shipping_id] = true;
                 }
                 continue;
             }
             $found = false;
             for ($d = 0; $d < 7; $d++) {
                 $delivon = 'shipping_delivon_' . $d;
                 if (!empty($rate->shipping_params->{$delivon})) {
                     $found = true;
                     break;
                 }
             }
             if (!$found && empty($rate->shipping_params->shipping_extra_deliv_dates)) {
                 $notUsable[] = $k;
                 continue;
             }
             $shipping_order_before = @$rate->shipping_params->shipping_order_before;
             if (!empty($shipping_order_before) && $shipping_order_before <= $now) {
                 $notUsable[] = $k;
                 continue;
             }
             $shipping_same_day_before = @$rate->shipping_params->shipping_same_day_before;
             $shipping_next_day_after = @$rate->shipping_params->shipping_next_day_after;
             $shipping_next_day_before = @$rate->shipping_params->shipping_next_day_before;
             if (empty($earliest_delivery_date) || $earliest_delivery_date == $today) {
                 if (!empty($shipping_same_day_before)) {
                     if ($shipping_same_day_before <= $now) {
                         $notUsable[] = $k;
                         continue;
                     }
                     if (!self::validDeliveryDay($today, $rate->shipping_params)) {
                         $notUsable[] = $k;
                         continue;
                     }
                 }
             }
             if (empty($earliest_delivery_date) || $earliest_delivery_date == $tomorrow) {
                 if (!empty($shipping_next_day_before)) {
                     if ($shipping_next_day_before <= $now) {
                         $notUsable[] = $k;
                         continue;
                     }
                 }
                 if (!empty($shipping_next_day_after)) {
                     if ($shipping_next_day_after >= $now) {
                         $notUsable[] = $k;
                         continue;
                     }
                 }
                 if (!self::validDeliveryDay($tomorrow, $rate->shipping_params)) {
                     $notUsable[] = $k;
                     continue;
                 }
             }
             if (!empty($earliest_delivery_date) && $earliest_delivery_date > $tomorrow) {
                 if (!self::validDeliveryDay($earliest_delivery_date, $rate->shipping_params)) {
                     $notUsable[] = $k;
                     continue;
                 }
             }
         }
     }
     return $notUsable;
 }