如果条件基于prestashop TPL中每周的聪明日和24小时的小时

时间:2018-08-15 14:32:27

标签: task-parallel-library prestashop smarty date-format strtotime

下午好, 我正在尝试在我的prestashop模板中编写页内信息,其中每个商品的产品页面根据库存情况提供有关可能的交货日期的信息。 仪器应显示基于我们当天(24H)和一周中的某天的特定规则(每个星期一1个,每个星期二2个...)。 到目前为止,由于有关于prestashop论坛本身的原始评论,我设法有了一个仅在每周工作的基础上有效的代码,该代码实际有效,如下所示:

{if $product->quantity >= 1}            
  {assign var="Delivery_day" value=$smarty.now|date_format:"%u"}
  {l s='If you are ordering before 11:30 a.m.,  delivery to Italy will be between'}
    {if $Delivery_day == 7}
        {"+2 days"|strtotime|date_format:"d-m-Y"} {l s='and'} {"+3 days"|strtotime|date_format:"d-m-Y"}
    {/if}
    {if $Delivery_day == 6}
        {"+3 days"|strtotime|date_format:"d-m-Y"} {l s='and'} {"+4 days"|strtotime|date_format:"d-m-Y"}
    {/if}    
    {if $Delivery_day > 0 && $Delivery_day < 6}
        {"tomorrow"|strtotime|date_format:"d-m-Y"} {l s='and'} {"+2 days"|strtotime|date_format:"d-m-Y"}
    {/if}
    {l s='. If later, please get in touch so we can inform you if still able to ship today. For deliveries outside Italy, please count 72H for EU and up to 1 Week for Extra EU'}
{/if} 

我编写的更新如下:

{if $product->quantity >= 1}        
  {assign var="Delivery_day" value=$smarty.now|date_format:"%u"}
  {assign var="Delivery_hour" value=$smarty.now|date_format:"%k"}
 {l s='Order now and receive you order in'}
    <!-- Domenica -->
    {if $Delivery_day == 7} 
    {"+2 days"|strtotime|date_format:"d-m-Y"} {l s='and'} {"+3 days"|strtotime|date_format:"d-m-Y"}
    {/if}
    <!-- Sabato-->
    {if $Delivery_day == 6}
        {"+3 days"|strtotime|date_format:"d-m-Y"} {l s='and'} {"+4 days"|strtotime|date_format:"d-m-Y"} 
        {/if}
    <!-- Prima di Mezzo Giorno-->
    {if $Delivery_hour > 0 && $Delivery_hour < 12 && $Delivery_hour = 0}
        <!-- Lun-Giov-->
    {if $Delivery_day > 0 && $Delivery_day < 5}
        {"tomorrow"|strtotime|date_format:"d-m-Y"} {l s='and'} {"+2 days"|strtotime|date_format:"d-m-Y"}
    {/if}
        <!-- Venerdì-->
    {if $Delivery_day == 5}
        {"+3 days"|strtotime|date_format:"d-m-Y"} {l s='and'} {"+4 days"|strtotime|date_format:"d-m-Y"}
    {/if}
    {/if}
   <!-- Dopo di Mezzo Giorno-->
    {if $Delivery_hour >= 12 && $Delivery_hour <= 23 }
        <!-- Lun-Giov-->
    {if $Delivery_day > 0 && $Delivery_day < 5}
        {"+2 days"|strtotime|date_format:"d-m-Y"} {l s='and'} {"+3 days"|strtotime|date_format:"d-m-Y"}
    {/if}
        <!-- Venerdì-->
    {if $Delivery_day == 5}
        {"+4 days"|strtotime|date_format:"d-m-Y"} {l s='and'} {"+5 days"|strtotime|date_format:"d-m-Y"}
    {/if}
    {/if}
    {l s='. If later, please get in touch so we can inform you if still able to ship today. For deliveries outside Italy, please count 72H for EU and up to 1 Week for Extra EU'}
{/if} 

但是,不幸的是,我的尝试没有成功,我想知道是否有机会了解我可能造成的冲突。 感谢您的任何答复。 祝你有美好的一天! 弗朗切斯科

0 个答案:

没有答案