案例作品集 浏览精选项目

WESWOO 提供 Shopify Plus 项目开发费抵扣,至多 US$4,800

Shopify 开发知识库 / 帮助、手册与政策

Shopify 帮助、手册与政策

从问题和型号找到资料,再连接适用政策、账户与人工服务。

Shopify 帮助中心的型号与问题索引

先把型号、说明书、退换保修和联系入口组织成可点击的资源目录,再增强本页筛选。找不到时保留全站帮助搜索与客服路径;本页匹配不应伪装成搜索了整个商店。

数据与依赖

  • Section 的 records 选择 ww_help_topic 条目,title 与 destination 必填,models/purpose 提供可读型号、别名与任务词。
  • 本页只匹配已输出记录;GET 表单使用 routes.search_url 和 type=page,article。URL 与正文语言由商家维护,contact 是可选入口。

交互逻辑

  • JS 筛选只隐藏本页已有资源,并播报数量。
  • 无匹配时说明范围,允许清空、全站搜索或联系客服。
接入位置与初始化
  1. 先建立 HANDOFF.md 中的 metaobject 定义并启用 storefront 读取,仅挑选已核记录。
  2. 把 Section 加到开发主题 JSON 模板;合并三语 locale 叶键,不能覆盖原 locale。
  3. 在theme.liquid结束body前仅一次 render ww-support-assets;不要放入每个Section。custom element随Section重建连接/断开并清除事件。
状态、触发与反馈
  • 完整目录输入关键词 → 仅匹配当前目录
  • 无匹配清空或全站搜索 → 恢复目录或进入实际搜索
  • 脚本失败阅读链接列表 → 仍可到达全部已列资源
示例代码 · sections/ww-help-routing.liquid
Liquid · WESWOO
{% assign valid_count = 0 %}
{% for record in section.settings.records %}
  {% if record.title.value != blank and record.destination.value != blank %}
    {% assign valid_count = valid_count | plus: 1 %}
  {% endif %}
{% endfor %}
<ww-support-index>
  <h2>{{ 'ww_support.help' | t }}</h2>
  <form action="{{ routes.search_url | escape }}" method="get" role="search">
    <label for="HelpQuery-{{ section.id }}">{{ 'ww_support.query' | t }}</label>
    <input id="HelpQuery-{{ section.id }}" name="q" type="search" data-query>
    <input type="hidden" name="type" value="page,article">
    <button type="submit">{{ 'ww_support.search_all' | t }}</button>
    <button type="button" data-clear hidden>{{ 'ww_support.clear' | t }}</button>
  </form>
  <p>{{ 'ww_support.scope' | t }}</p>
  <p role="status" aria-live="polite" data-count data-template="{{ 'ww_support.count' | t | escape }}"></p>
  <p data-empty{% if valid_count > 0 %} hidden{% endif %}>{{ 'ww_support.no_match' | t }}</p>
  <ul>
    {% for record in section.settings.records %}
      {% assign destination = record.destination.value %}
      {% if record.title.value != blank and destination != blank %}
        <li data-row data-key="{{ record.title.value | append: ' ' | append: record.models.value | append: ' ' | append: record.purpose.value | escape }}">
          <a href="{{ destination | escape }}">{{ record.title.value | escape }}</a>
          {% if record.models.value != blank %}<span>{{ record.models.value | escape }}</span>{% endif %}
        </li>
      {% endif %}
    {% endfor %}
  </ul>
  {% if section.settings.contact != blank %}<a href="{{ section.settings.contact | escape }}">{{ 'ww_support.contact' | t }}</a>{% endif %}
</ww-support-index>
{% schema %}
{
  "name": "WESWOO help-routing",
  "settings": [
    {
      "type": "metaobject_list",
      "id": "records",
      "label": "Reviewed records",
      "metaobject_type": "ww_help_topic",
      "limit": 50
    },
    {
      "type": "url",
      "id": "contact",
      "label": "Contact page"
    }
  ],
  "presets": [
    {
      "name": "WESWOO help-routing"
    }
  ]
}
{% endschema %}

示例代码 · locales/en.default.json
JSON · WESWOO
{
  "ww_support": {
    "manuals": "Manuals and instructions",
    "download": "Open reviewed manual",
    "no_file": "Download unavailable; use the instructions or contact us.",
    "empty": "No published records available.",
    "contact": "Contact support",
    "help": "Help resources",
    "query": "Model or question",
    "search_all": "Search store pages and articles",
    "clear": "Clear local filter",
    "scope": "The local filter checks only the links listed on this page.",
    "no_match": "No local matches. Clear the filter, search the store, or contact support.",
    "stores": "Stores",
    "open_map": "Open external map (new tab)",
    "no_map": "Map unavailable; use the address above.",
    "count": "[count] resources in this page index."
  }
}

示例代码 · locales/zh-CN.json
JSON · WESWOO
{
  "ww_support": {
    "manuals": "手册与操作说明",
    "download": "打开已核手册",
    "no_file": "下载暂不可用,请阅读说明或联系支持。",
    "empty": "暂无已发布记录。",
    "contact": "联系支持",
    "help": "帮助资源",
    "query": "型号或问题",
    "search_all": "搜索商店页面与文章",
    "clear": "清空本页筛选",
    "scope": "本页筛选仅匹配下方列出的链接。",
    "no_match": "本页无匹配,请清空筛选、搜索全站或联系支持。",
    "stores": "门店",
    "open_map": "打开外部地图(新标签页)",
    "no_map": "地图暂不可用,请使用上方文字地址。",
    "count": "本页目录有 [count] 条匹配资源。"
  }
}

示例代码 · locales/zh-TW.json
JSON · WESWOO
{
  "ww_support": {
    "manuals": "手冊與操作說明",
    "download": "開啟已核手冊",
    "no_file": "下載暫不可用,請閱讀說明或聯絡支援。",
    "empty": "暫無已發佈記錄。",
    "contact": "聯絡支援",
    "help": "協助資源",
    "query": "型號或問題",
    "search_all": "搜尋商店頁面與文章",
    "clear": "清空本頁篩選",
    "scope": "本頁篩選僅比對下方列出的連結。",
    "no_match": "本頁無符合項目,請清空篩選、搜尋全站或聯絡支援。",
    "stores": "門市",
    "open_map": "開啟外部地圖(新分頁)",
    "no_map": "地圖暫不可用,請使用上方文字地址。",
    "count": "本頁目錄有 [count] 條符合資源。"
  }
}

示例代码 · assets/ww-support-index.js
JavaScript · WESWOO
// Original WESWOO teaching example. Load once with defer from theme.liquid.
if (!customElements.get('ww-support-index')) {
  customElements.define('ww-support-index', class extends HTMLElement {
    connectedCallback() {
      this.controller?.abort();
      this.controller = new AbortController();
      const input = this.querySelector('[data-query]');
      const clear = this.querySelector('[data-clear]');
      const empty = this.querySelector('[data-empty]');
      const status = this.querySelector('[data-count]');
      const rows = [...this.querySelectorAll('[data-row]')];
      if (!input || !clear || !empty) return;
      const normalize = value => value.normalize('NFKC').trim().toLocaleLowerCase();
      const update = () => {
        const query = normalize(input.value);
        let count = 0;
        rows.forEach(row => {
          row.hidden = !normalize(row.dataset.key || '').includes(query);
          if (!row.hidden) count++;
        });
        empty.hidden = count !== 0;
        if (status) status.textContent = status.dataset.template.replace('[count]', String(count));
        clear.hidden = !query;
      };
      input.addEventListener('input', event => { if (!event.isComposing) update(); }, {signal:this.controller.signal});
      input.addEventListener('compositionend', update, {signal:this.controller.signal});
      clear.addEventListener('click', () => { input.value=''; update(); input.focus(); }, {signal:this.controller.signal});
      update();
    }
    disconnectedCallback() { this.controller?.abort(); }
  });
}

示例代码 · snippets/ww-support-assets.liquid
Liquid · WESWOO
{% comment %}Render once in layout/theme.liquid before </body>, never inside each Section.{% endcomment %}
<script src="{{ 'ww-support-index.js' | asset_url }}" defer></script>

验收检查

  • 按完整型号、问题片段和无匹配词各测试一次。
  • 无 JS 仍能读全部目录;每个手册和政策入口实际可用。
  • 测试空记录、草稿、缺必填字段、三语、禁用JS与Section重排/删除/重建;目标店尚待验收。

这是一个已策划资源列表的本页匹配器。索引字段需要维护;大型目录应增加真正的分页 / 服务端搜索,不能把有限前端数组称为完整知识库。

先理解,再整合,最后验证

  1. 选择模块,确认数据和输入输出。
  2. 将片段接入当前主题或框架。
  3. 用真实变体、市场和失败恢复场景验收。

代码为 Shopify 主题或 Headless 项目的教学实现,说明实际输入、交互与接入边界。先在开发主题中连接已有组件和真实资料,再做商店实测。没有对应的 WESWOO 文章时保留官方依据,不以相似标题凑关联。

架构参考

示例由 WESWOO 编写,结合 Shopify 官方文档和固定版本的仓库参考。采用仓库代码时应保留适用许可。

Shopify/dawn · 许可commit 3e9ee2281dc4 · Shopify 集成主题的限定许可;参考架构,不复制仓库实现。
Shopify/hydrogen · 许可commit 9e358a2462ba · MIT;采用实质代码时保留版权与许可。

依据核对 2026-11-17