openart的交货日期


Delivery Date for Opencart

我在openart上有一个站点,我在第4步(交付方法)上设置了这个;

Interlink Express 24 Courier

  • Interlink Express - Get on:星期三,8月13日

我已经有一个代码,但它似乎不工作,在星期六它似乎仍然显示星期日作为交货日期。

<?php
// Text
$_['text_title'] = 'Interlink Express 24 Courier';
$datetime = new DateTime('tomorrow');
if ($datetime->format('l') == 'Sunday') $datetime = new DateTime('tomorrow + 1 day');

$_['text_description'] = 'Interlink Express - Get it on: ' . $datetime->format('l, jS 'of F ');
$_['text_weight'] = 'Weight:';
$_['text_insurance'] = 'Insured upto:';
$_['text_time'] = 'Estimated Time: Within 24 Hours'; 
?>

还有,是否可以使它在特定时间(下午5点)后显示下一个日期?

所以在星期一的5:01它显示星期三而不是星期二

修改这两行

$datetime = new DateTime('tomorrow');
if ($datetime->format('l') == 'Sunday') $datetime = new DateTime('tomorrow + 1 day');

到这些:

$now = new DateTime(); // uses actual date and time
if ($now->format('l') == 'Saturday') {
    // it is Saturday, delivery will be on Tuesday
    $datetime = new DateTime('tomorrow + 2 day');
} elseif ($now->format('l') == 'Sunday' || in_array($now->format('l'), array('Monday', 'Tuesday', 'Wednesday')) && ((int) $now->format('H')) > 17) {
    // it is Sunday - delivery will be on Tuesday
    // or it is working day Mon..Wed after 5 p.m. - delivery will be on second working day
    $datetime = new DateTime('tomorrow + 1 day');
} elseif (in_array($now->format('l'), array('Thursday', 'Friday')) && ((int) $now->format('H')) > 17) {
    // it is Thursday after 5 p.m. - delivery will be on next Monday
    // or it is Friday after 5 p.m. - delivery will be on next Tuesday
    $datetime = new DateTime('tomorrow + 3 day');
} else {
    $datetime = new DateTime('tomorrow');
}