lucky-media/business-hours 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

lucky-media/business-hours

Composer 安装命令:

composer require lucky-media/business-hours

包简介

README 文档

README

Business Hours is a Statamic addon that gives you the option to easily create, manage and display business hours in a modern and stylish layout.

Features

  • Set opening and closing times for each day of the week separately.
  • Fields to indicate if you are currently open or closed
  • Conditionals to display a text only when you are open or closed
  • Comes unstyled, bring your own styling
  • Supports special dates e.g: holidays, company wide vacations etc
  • Use different time zones and languages
  • Beautiful & user-friendly settings screen for you, or your client
  • Localizable fields for easy translation in any language

How to Install

You can search for this addon in the Tools > Addons section of the Statamic control panel and click install, or run the following command from your project root:

composer require lucky-media/business-hours

How to Use

On your frontend you can make use of the business_hours tag to iterate through the hours.

{{ business_hours }}
  
  {{ weekday }}

  {{ closed }}

  {{ 24_hours }}

  {{ start_time }}
  
  {{ end_time }}

  {{ is_open }}

{{ /business_hours }}

Params:

  • weekday (string)
    • Weekday label
  • closed (boolean)
    • Is the business closed on this day
  • 24_hours (boolean)
    • Is the business working 24hrs on this day
  • start_time (string)
    • What time does the business start on this day
  • end_time (string)
    • What time does the business end on this day
  • is_open (boolean)
    • Is the business open at this moment

If you need to display the exeptions you can use the following:

{{ business_hours:exception }}

 {{ reason }}

 {{ start_date }}

 {{ end_date }}

{{ /business_hours:exception }}

Params:

  • reason (bard)
    • Bard field to write down the reason for the exception
  • start_date (date)
    • Start date of the exception
  • end_date (date)
    • End date of the exception

Common Gotcha's

  • Make sure on your config/app.php you have the correct timezone.
  • You can either display times on 24 hour format or 12 hour format, you can change this on config/statamic/business_hours.php
  • Make sure on CP the start_time and end_time are entered in 24 hour format. There is also validation if the time is not in this format.

Examples

Check the example below and the code snippet. Please keep in mind that the examples use Tailwind CSS for styling.

Screenshot 2022-02-08 at 13 21 11

<div>
    {{ business_hours:exception }}
        <div class="w-full p-5 mb-5 text-center text-white bg-red-600 rounded">
            {{ reason }}
        </div>
    {{ /business_hours:exception }}


    <div class="grid grid-cols-2 gap-4">
        {{ business_hours }}
            <p class="{{ is_past ?= 'line-through opacity-60' }}">
                {{ weekday }}
            </p>

            <p>
                {{ if closed }}
                    <span class="p-2 text-xs text-white uppercase bg-red-500 rounded">closed</span>
                {{ /if }}

                {{ if !closed and !24_hours }}
                    <span class="{{ is_past ?= 'line-through opacity-60' }}">
                        {{ start_time }} - {{ end_time }}
                    </span>
                {{ /if }}

                {{ if 24_hours }}
                    <span class="p-2 text-xs text-white uppercase bg-purple-500 rounded">
                        24hrs
                    </span>
                {{ /if }}

                {{ if is_open }}
                    <span class="p-2 text-xs text-white uppercase bg-green-500 rounded">
                        open now
                    </span>
                {{ /if }}
            </p>
        {{ /business_hours }}
    </div>
</div>

lucky-media/business-hours 适用场景与选型建议

lucky-media/business-hours 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 28 次下载、GitHub Stars 达 3, 最近一次更新时间为 2022 年 02 月 09 日, 在 PHP 生态内属于活跃度较高的组件。

我们在过去多个企业项目中使用过 lucky-media/business-hours 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 lucky-media/business-hours 我们能提供哪些服务?
定制开发 / 二次开发

基于 lucky-media/business-hours 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 28
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 3
  • 点击次数: 7
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 3
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: Unknown
  • 更新时间: 2022-02-09