bramdeleeuw/silverstripe-openinghours

将营业时间添加到数据对象

安装: 340

依赖项: 0

建议者: 0

安全: 0

星标: 6

关注者: 2

分支: 4

开放问题: 0

类型:silverstripe-vendormodule

1.1.2 2023-02-23 11:04 UTC

This package is auto-updated.

Last update: 2024-09-14 10:13:05 UTC


README

将营业时间添加到数据对象。我建议添加silverstripe-australia/addressable来将营业时间和地址数据添加到商店网站。未来我建议使用bramdeleeuw/silverstripe-schema来添加结构化数据,如商店信息,到您的网站,但这项工作仍在进行中。

要添加营业时间,只需扩展您想使用它们的对象。

YourObject:
  extensions:
    - 'Broarm\OpeningHours\OpeningHours'

该对象包含一些方法,您可以使用它们来显示营业时间

// Returns the opening hours as a summarized list, this means days with similar opening hours are combined e.g "Mon – Tue"
$openingHourHolder->getOpeningHoursSummarized()
 
// Returns todays opening hours
$openingHourHolder->getOpeningHoursToday()
 
// Return the short localized version for the current day (in the loop)
$openingHour->getShortDay();
 
// Return the short localized version for the current day (in the loop)
$openingHour->getFullDay();
 
// Return the concatnated days list as a range, only used when looping over the summarized days loop.
$openingHour->getConcatenatedDays();
 
// Returns true when the From and Till data are equal (shop is closed for that day)
$openingHour->IsClosed();
 
// Returns true when the current time falls between the opening hours
$openingHour->IsOpenNow();