Shopify全栈开发技能Skill shopify-developer

这个技能专注于 Shopify 电商平台的全面开发,包括前端 Liquid 模板和主题定制,后端 GraphQL API 集成和自定义应用开发,以及性能优化和错误调试。关键词:Shopify 开发、Liquid 模板、GraphQL API、电商独立站、性能优化、调试。

独立站 0 次安装 0 次浏览 更新于 3/20/2026

名称: shopify-developer 描述: 完整的 Shopify 开发参考,涵盖 Liquid 模板、主题开发 (OS 2.0)、GraphQL Admin API、Storefront API、自定义应用开发、Shopify Functions、Hydrogen、性能优化和调试。适用于处理 .liquid 文件、创建主题部分和区块、编写 Shopify 的 GraphQL 查询或突变、使用 CLI 和 Polaris 构建 Shopify 应用、通过 Ajax API 实现购物车操作、优化 Shopify 商店的 Core Web Vitals、调试 Liquid 或 API 错误、配置 settings_schema.json、访问 Shopify 对象(产品、集合、购物车、客户)、使用 Liquid 过滤器、创建应用扩展、处理 webhooks、从 Scripts 迁移到 Functions、或使用 Hydrogen 和 React Router 7 构建头部电商解决方案。涵盖 API 版本 2026-01。

Shopify 开发者参考

专业 Shopify 开发的综合参考 - API 版本 2026-01

快速参考

项目
API 版本 2026-01 (稳定)
GraphQL Admin POST https://{store}.myshopify.com/admin/api/2026-01/graphql.json
Storefront API POST https://{store}.myshopify.com/api/2026-01/graphql.json
Ajax API (主题) /cart.js, /cart/add.js, /cart/change.js
CLI 安装 npm install -g @shopify/cli
主题开发 shopify theme dev --store {store}.myshopify.com
应用开发 shopify app dev
部署 shopify app deploy
文档 shopify.dev

选择您的路径

阅读与您任务匹配的参考文件:

Liquid 模板 - 编写或调试 .liquid 文件:

主题开发 - 构建或自定义主题:

API 集成 - 以编程方式获取或修改数据:

应用开发 - 构建 Shopify 应用:

无服务器逻辑 - 自定义业务规则:

头部电商 - 自定义商店前端:

优化与故障排除

弃用通知

已弃用 替代方案 截止日期
Shopify Scripts Shopify Functions 2025 年 8 月(迁移),结束时间待定
checkout.liquid Checkout Extensibility 2024 年 8 月(Plus),已完成
REST Admin API GraphQL Admin API 主动弃用(无移除日期)
遗留自定义应用 新身份验证模型 2025 年 1 月(已完成)
Polaris React Polaris Web Components 主动迁移
Remix (应用框架) React Router 7 Hydrogen 2025.5.0+

Liquid 基础

三种语法类型:

{{ product.title | upcase }}                    {# 带过滤器的输出 #}
{% if product.available %}有货{% endif %}   {# 逻辑标签 #}
{% assign sale = product.price | times: 0.8 %}  {# 赋值 #}
{%- if condition -%}去除空白{%- endif -%}

关键模式:

{% for product in collection.products limit: 5 %}
  {% render 'product-card', product: product %}
{% endfor %}

{% paginate collection.products by 12 %}
  {% for product in paginate.collection.products %}...{% endfor %}
  {{ paginate | default_pagination }}
{% endpaginate %}

API 基础

// GraphQL Admin - 始终使用 GraphQL 而非 REST
const response = await fetch(
  `https://${store}.myshopify.com/admin/api/2026-01/graphql.json`,
  {
    method: 'POST',
    headers: {
      'X-Shopify-Access-Token': accessToken,
      'Content-Type': 'application/json',
    },
    body: JSON.stringify({ query, variables }),
  }
);
const { data, errors } = await response.json();
if (errors) throw new Error(errors[0].message);

// Ajax API(仅主题购物车操作)
fetch('/cart/add.js', {
  method: 'POST',
  headers: { 'Content-Type': 'application/json' },
  body: JSON.stringify({ id: variantId, quantity: 1 }),
});

参考文件

文件 行数 覆盖内容
liquid-syntax.md ~600 标签、控制流、迭代、变量、空白处理、LiquidDoc
liquid-filters.md ~870 字符串、数值、数组、Shopify 特定、日期、URL、颜色过滤器
liquid-objects.md ~695 所有 Shopify 对象:产品、变体、集合、购物车、客户、订单等
theme-development.md ~1200 文件结构、JSON 模板、部分、区块、设置模式、布局
api-admin.md ~595 GraphQL 查询/突变、REST(遗留)、OAuth、webhooks、速率限制
api-storefront.md ~235 Storefront API、Ajax API、购物车操作、Customer Account API
app-development.md ~760 CLI、应用架构、扩展、Polaris Web Components、部署
functions.md ~300 函数类型、Rust/JS 目标、CLI 工作流、Scripts 迁移
hydrogen.md ~375 设置、路由、数据加载、Storefront API、部署
performance.md ~605 图像、JS、CSS、字体、Liquid、第三方脚本、Core Web Vitals
debugging.md ~650 Liquid、JavaScript、API、购物车、webhook、主题编辑器故障排除