doumiang2297 2014-08-12 10:19
浏览 10
已采纳

Opencart的交货日期

I have a site on opencart, and I have this on step 4 (delivery method);

Interlink Express 24 Courier

  • Interlink Express - Get it on: Wednesday, 13th of August

I already have a code, but it does not seem to work, on Saturdays it still seems to display Sunday as the delivery date.

<?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'; 
?>

Also, is it possible to make it display the next date after a certain time (5:00pm) ?

So on a Monday at 5:01 it displays Wednesday instead of Tuesday.

  • 写回答

1条回答 默认 最新

  • ds34222222 2014-08-12 11:11
    关注

    Change these two lines

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

    into these:

    $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');
    }
    

    This should do the trick.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 用windows做服务的同志有吗
  • ¥60 求一个简单的网页(标签-安全|关键词-上传)
  • ¥35 lstm时间序列共享单车预测,loss值优化,参数优化算法
  • ¥15 Python中的request,如何使用ssr节点,通过代理requests网页。本人在泰国,需要用大陆ip才能玩网页游戏,合法合规。
  • ¥100 为什么这个恒流源电路不能恒流?
  • ¥15 有偿求跨组件数据流路径图
  • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值
  • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
  • ¥15 一直显示正在等待HID—ISP
  • ¥15 Python turtle 画图