结账页显示加载动画但地址、配送或支付区域不出现时,不要先关闭所有模块。先打开无痕窗口与浏览器开发者工具,找到“第一条失败请求或第一条 JavaScript 异常”。后面的报错往往只是连锁反应。

用 Network 判断卡在哪一步

过滤 Fetch/XHR,刷新 Checkout,常见请求包括 totals、shipping-information、payment-information 和 customer sections。记录 URL、状态码、响应 body 与耗时:

  • 请求一直 Pending:查 PHP、数据库、外部运费/支付 API;
  • 返回 500:用响应 request ID 对应 exception.log;
  • 返回 401/403:查 Session、Form Key 或 API 路由;
  • 全部 200 但界面不渲染:继续查 Console 和 Knockout 组件。

检查页面是否生成了 checkoutConfig

在 Console 中只读检查:

typeof window.checkoutConfig
Object.keys(window.checkoutConfig || {})
window.checkoutConfig && window.checkoutConfig.quoteData

对象不存在或 HTML 被截断,查 checkout layout processor、自定义 Block 和 FPC;对象存在但某个字段结构异常,比较正常环境 JSON,定位扩展加入的数据。不要把完整 checkoutConfig 发到公开工单,其中可能含客户和购物车信息。

RequireJS 报错怎么找模块来源

bin/magento deploy:mode:show
bin/magento config:show dev/js/merge_files
bin/magento config:show dev/js/enable_js_bundling
bin/magento config:show dev/js/minify_files
rg "目标组件名" app/code app/design vendor/*/*/view/frontend

Console 出现 Script error、mismatched anonymous define 或某 mixin undefined 时,在预发布临时关闭合并/压缩并重新部署静态内容,让堆栈指向源文件。生产环境不要边请求边删除 pub/static。

逐个隔离 Checkout 扩展

先从页面的 RequireJS config 找到支付、地址验证、One Step Checkout 等 mixin。一次只禁用一个可疑模块或 mixin,在预发布重新执行:

bin/magento setup:upgrade
bin/magento setup:di:compile
bin/magento setup:static-content:deploy -f zh_CN en_US
bin/magento cache:clean

如果禁用后恢复,再用原购物车、同一地址和支付方式复现,不能只看空购物车。

接口很慢时抓服务端证据

tail -f var/log/exception.log var/log/system.log
mysql -e 'SHOW FULL PROCESSLIST'
curl -w '
TTFB:%{time_starttransfer} TOTAL:%{time_total}
'   -o /dev/null -sS 'https://www.example.com/checkout/'

运费接口没有连接/读取超时、支付模块在 isAvailable 阶段访问网关、地址校验同步调用第三方,都可能让 Spinner 永远不结束。为外部调用设置明确超时和降级逻辑。

修复后分别测试访客、登录客户、实体商品、虚拟商品、国内外地址、优惠券和支付失败返回。只让页面“显示出来”不够,订单金额和最终提交必须正确。