定制 merrick/laravel-shopify-timezones 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

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

merrick/laravel-shopify-timezones

最新稳定版本:1.0.0

Composer 安装命令:

composer require merrick/laravel-shopify-timezones

包简介

Laravel package providing the full list of Shopify supported timezones (hardcoded from IANA with friendly names and offsets)

README 文档

README

Packagist Version Downloads

A lightweight Laravel package that provides the full list of timezones supported by Shopify, hardcoded from the IANA timezone database with friendly names and GMT offsets exactly as shown in Shopify Admin dropdown (e.g., "(GMT-05:00) Eastern Time (US & Canada)").

Features:

  • Timezone code (IANA identifier), friendly display name, and offset.
  • Sorted like Shopify Admin: Most used timezones first (US/Canada zones, Europe, Asia...), then alphabetical by display name.
  • No database, no migrations, no API calls – pure PHP enum + static data for instant performance.

Perfect for:

  • Timezone dropdowns in store settings or user profiles
  • Matching Shopify store timezone exactly
  • Validation rules for timezone inputs
  • Scheduling features, order notifications, or analytics

Requirements

  • PHP ^8.1 | ^8.2 | ^8.3
  • Laravel ^9.0 | ^10.0 | ^11.0 | ^12.0 (illuminate/support)

Installation

Install via Composer (live on Packagist):

composer require merrick/laravel-shopify-timezones

For local development/testing:

Add to your project's composer.json:

"repositories": [
    {
        "type": "vcs",
        "url": "https://github.com/merrick67/laravel-shopify-timezones"
    }
],
"require": {
    "merrick/laravel-shopify-timezones": "dev-main"
}

Then run:

composer update merrick/laravel-shopify-timezones

No manual configuration or provider registration needed – auto-registered.

Usage

1. Via Facade (Recommended)

use Merrick\ShopifyTimezones\Facades\ShopifyTimezones;

// Get all timezone codes (IANA identifiers) as array
$codes = ShopifyTimezones::codes();

// Get full Collection (sorted like Shopify Admin dropdown)
$timezones = ShopifyTimezones::all();
// Example items:
// ['code' => 'America/New_York', 'display' => '(GMT-05:00) Eastern Time (US & Canada)', 'offset' => 'GMT-05:00']
// ['code' => 'Europe/London', 'display' => '(GMT+00:00) Dublin, Edinburgh, Lisbon, London', 'offset' => 'GMT+00:00']

// Validate a timezone code
$isValid = ShopifyTimezones::isValid('America/Chicago'); // true

2. Via Helper Functions

$codes = shopify_timezone_codes();          // array of codes
$timezones = shopify_timezones();           // full collection with display
$isValid = is_shopify_timezone('UTC');      // true

3. Via Service Container

use Merrick\ShopifyTimezones\Services\ShopifyTimezoneService;

$service = app(ShopifyTimezoneService::class);
$timezones = $service->all();

Blade Dropdown Example (Matches Shopify Admin Exactly)

<select name="timezone" required>
    @foreach (ShopifyTimezones::all() as $tz)
        <option value="{{ $tz['code'] }}">
            {{ $tz['display'] }}
        </option>
    @endforeach
</select>

Result preview (just like Shopify Admin General settings):

  • (GMT-12:00) International Date Line West
  • (GMT-11:00) American Samoa
  • (GMT-10:00) Hawaii
  • ...
  • (GMT-05:00) Eastern Time (US & Canada)
  • (GMT+00:00) Dublin, Edinburgh, Lisbon, London
  • ...

Available Methods

Method Return Type Description
codes() array All IANA timezone codes
all() Collection Full list with code, display, offset (Most used first)
isValid(string $code) bool Check if timezone is supported by Shopify

Why Hardcoded?

Shopify's timezone list is stable and based on IANA database. Hardcoding ensures:

  • Exact match with Shopify Admin dropdown (friendly names + offsets)
  • No external API dependencies
  • Instant loading and zero runtime overhead

Version History

  • 1.0.0: Initial release with full timezone list, friendly display, offset, and Most used sorting.

Contributing

Report missing timezones, suggest improvements, or open PRs on GitHub: https://github.com/merrick67/laravel-shopify-timezones

License

MIT License

See LICENSE for details.

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-01-26

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固