You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Advanced Flat Rate Shipping For WooCommerce插件激活报错修复咨询

问题

使用Advanced Flat Rate Shipping For WooCommerce插件时,每次激活该插件,WordPress后台就会崩溃,报错信息如下:

An error of type E_ERROR was caused in line 191 of the file /home/u922158803/domains/janelle-eg.com/public_html/wp-content/plugins/woo-extra-flat-rate/includes/class-advanced-flat-rate-shipping-for-woocommerce.php. Error message: Uncaught Error: Class "AFRSM_Shipping_Method" not found in /home/u922158803/domains/janelle-eg.com/public_html/wp-content/plugins/woo-extra-flat-rate/includes/class-advanced-flat-rate-shipping-for-woocommerce.php:191
Stack trace:
#0 /home/u922158803/domains/janelle-eg.com/public_html/wp-includes/class-wp-hook.php(308): Advanced_Flat_Rate_Shipping_For_WooCommerce_Pro->afrsm_pro_register_shipping_method_class()
#1 /home/u922158803/domains/janelle-eg.com/public_html/wp-includes/plugin.php(205): WP_Hook->apply_filters()
#2 /home/u922158803/domains/janelle-eg.com/public_html/wp-content/plugins/woocommerce/includes/class-wc-shipping.php(148): apply_filters()
#3 /home/u922158803/domains/janelle-eg.com/public_html/wp-content/plugins/woocommerce/includes/class-wc-shipping-zone.php(166): WC_Shipping->get_shipping_method_class_names()
#4 /home/u922158803/domains/janelle-eg.com/public_html/wp-content/plugins/woocommerce/includes/class-wc-shipping-zones.php(36): WC_Shipping_Zone->get_shipping_methods()
#5 /home/u922158803/domains/janelle-eg.com/public_html/wp-content/plugins/woocommerce/packages/woocommerce-blocks/src/Shipping/ShippingController.php(315): WC_Shipping_Zones::get_zones()
#6 /home/u922158803/domains/janelle-eg.com/public_html/wp-includes/class-wp-hook.php(308): AutomatticWooCommerceBlocksShippingShippingController->hydrate_client_settings()
#7 /home/u922158803/domains/janelle-eg.com/public_html/wp-includes/class-wp-hook.php(332): WP_Hook->apply_filters()
#8 /home/u922158803/domains/janelle-eg.com/public_html/wp-includes/plugin.php(517): WP_Hook->do_action()
#9 /home/u922158803/domains/janelle-eg.com/public_html/wp-admin/admin-header.php(118): do_action()
#10 /home/u922158803/domains/janelle-eg.com/public_html/wp-admin/admin.php(239): require_once('/home/u92215880...')
#11 {main}
  thrown

已测试:禁用所有插件后站点正常;仅禁用该插件时站点也正常,但激活该插件就会导致站点及后台崩溃。需要明确错误原因及修复方法。

错误原因分析

  • 核心问题:插件代码尝试调用AFRSM_Shipping_Method类时,该类未被正确加载。
  • 具体诱因包括:
    • 插件文件损坏:存放AFRSM_Shipping_Method类的文件缺失或内容损坏。
    • 加载顺序问题:插件注册配送方法类的时机过早,依赖的基础类文件还未完成加载。
    • 版本不兼容:插件与当前WordPress/WooCommerce版本不匹配,类名或文件结构发生变更导致调用失效。

修复方法

1. 重新安装插件

  • 通过FTP或主机文件管理器,删除服务器上的woo-extra-flat-rate插件文件夹。
  • 从WordPress插件市场重新下载最新版本的插件,上传并安装激活。
  • 操作前备份插件配置数据,避免设置丢失。

2. 检查文件完整性

  • 对比官方插件包的文件结构,确认是否存在缺失的类文件(AFRSM_Shipping_Method通常在includes或classes子目录下)。
  • 若发现文件缺失,手动从官方包中提取对应文件上传到插件目录。

3. 调整插件加载优先级(技术操作)

  • 找到插件主文件中注册afrsm_pro_register_shipping_method_class方法的代码,修改Hook优先级,确保在WooCommerce加载配送方法类后执行。
  • 示例:将原代码add_filter( 'woocommerce_shipping_methods', array( $this, 'afrsm_pro_register_shipping_method_class' ) ); 修改为add_filter( 'woocommerce_shipping_methods', array( $this, 'afrsm_pro_register_shipping_method_class' ), 20 );(数值越大,执行时机越晚)。

4. 回滚到兼容版本

  • 若为版本不兼容问题,查找插件历史版本,选择与当前WordPress/WooCommerce版本匹配的旧版本安装测试。
  • 可通过WordPress插件目录的「高级视图」下载历史版本,或从插件开发者官方渠道获取兼容版本。

5. 联系插件开发者

  • 若以上方法无效,向插件开发者提交错误报告,提供完整报错信息和服务器环境(WordPress版本、WooCommerce版本、PHP版本),请求官方修复。

内容的提问来源于stack exchange,提问作者Reem.H

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.16 07:23:08