Problem with StoreTime and OrderTime handling
Let say Stores Open at 15:00 but customers can only make orders after 16:00 (depending on the Stores Opening time), code does work below as expected
$nowtime = $this->HourMinuteToDecimal(date('H:i'));
$OrderTime = $this->HourMinuteToDecimal('16:00');
$storeOpeningTime = $this->HourMinuteToDecimal($data[$key]['opentime']);
if ($nowtime >= $OrderTime && ($OrderTime >= $storeOpeningTime)) {
$data开发者_如何学C[$key]['open'] = 1;
} else {
$data[$key]['open'] = 0;
}
public function HourMinuteToDecimal($hour_minute) {
$t = explode(':', $hour_minute);
return $t[0] * 60 + $t[1];
}
There is a problem, what if a Store-Open-Time is 18:00 but default Order-Time is 16:00, How to fix these solution? Customer can only place order after 18:00 in that case.
General Rule: Customer can only place order after 16:00 (Order-Time) but depending on the Store Open Time first.
Orders are taken after OrderTime and StoreOpeningTime, so that means the relevant time is the latest one of those two.
if ($nowtime >= max($OrderTime, $StoreOpeningTime)) {
$data[$key]['open'] = 1;
}
// ...
精彩评论