案例作品集 浏览精选项目

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

开发知识库 / 系列选型与比较

系列选型与比较

先定真实差异属性,再实现筛选、结果与型号比较。

型号差异与 HTML 对比表

按顾客的用途与适配问题挑选比较维度,以同单位和测试条件展示。参数使用真实文字,型号链接回具体商品。

数据与依赖

  • collection.custom.comparison_products:list.product_reference。
  • 商品 custom.key_spec 与正式规格资料一致。

交互逻辑

  • 缺少资料显示未提供,不自行补零。
  • 手机表格可聚焦横向阅读,保留列标题。
示例代码 · snippets/ww-comparison.liquid
Liquid · WESWOO
{% assign models = collection.metafields.custom.comparison_products.value %}
{% if models != blank %}
  <div class="ww-table-scroll" role="region" aria-label="Model comparison" tabindex="0">
    <table>
      <caption>Compare the models in this collection</caption>
      <thead><tr><th scope="col">Model</th><th scope="col">Use and key specification</th></tr></thead>
      <tbody>
        {% for model in models %}
          <tr>
            <th scope="row"><a href="{{ model.url | escape }}">{{ model.title | escape }}</a></th>
            <td>{{ model.metafields.custom.key_spec.value | default: 'Not supplied' | escape }}</td>
          </tr>
        {% endfor %}
      </tbody>
    </table>
  </div>
{% endif %}

示例代码 · assets/ww-module-layout.css
CSS · WESWOO
.ww-product-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1.25rem;
  list-style: none;
  padding: 0;
}
.ww-product-grid img { width: 100%; height: auto; }
.ww-product-grid h3 { overflow-wrap: anywhere; }
.ww-table-scroll { max-width: 100%; overflow-x: auto; }
.ww-table-scroll table { border-collapse: collapse; min-width: 30rem; }
.ww-table-scroll th, .ww-table-scroll td { padding: .75rem; text-align: start; }
@media (max-width: 749px) {
  .ww-product-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .75rem; }
}

验收检查

  • 用一个实际选型问题走到型号。
  • 核相同单位、条件及商品链接。

示例只有一项比较维度;需要更多规格时从同一字段字典扩展列。

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

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

示例按 Shopify Online Store 2.0 主题编写;Headless 使用单独的数据与版本边界。代码片段需接实际字段、主题和语言文件。

架构参考

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

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

依据核对 2026-11-12