使用Elementor编辑特定页面时出现Error 500错误求助
问题解决:Dokan Lite引发的Error 500及页面空白问题
问题概述
使用WooCommerce默认页面恢复工具无效,部分页面仅显示旧页眉、内容空白;用Elementor编辑时触发Error 500,调试显示Dokan Lite插件的/wp-content/plugins/dokan-lite/includes/Product/Hooks.php第406行出现Uncaught Error: Call to a member function get_id() on bool错误。
错误详情
Uncaught Error: Call to a member function get_id() on bool in /home/u330303233/domains/vendorbyte.com/public_html/wp-content/plugins/dokan-lite/includes/Product/Hooks.php:406 Stack trace: #0 /home/u330303233/domains/vendorbyte.com/public_html/wp-includes/class-wp-hook.php(324): WeDevs\Dokan\Product\Hooks->own_product_not_purchasable_notice() #1 /home/u330303233/domains/vendorbyte.com/public_html/wp-includes/class-wp-hook.php(348): WP_Hook->apply_filters() #2 /home/u330303233/domains/vendorbyte.com/public_html/wp-includes/plugin.php(517): WP_Hook->do_action() #3 /home/u330303233/domains/vendorbyte.com/public_html/wp-content/plugins/elementorpro3171n/modules/woocommerce/documents/product.php(117): do_action() #4 /home/u330303233/domains/vendorbyte.com/public_html/wp-content/plugins/elementorpro3171n/modules/theme-builder/documents/theme-document.php(156): ElementorPro\Modules\Woocommerce\Documents\Product->before_get_content() #5 /home/u330303233/domains/vendorbyte.com/public_html/wp-content/plugins/elementorpro3171n/modules/theme-builder/documents/theme-document.php(173): ElementorPro\Modules\ThemeBuilder\Documents\Theme_Document->get_content() #6 /home/u330303233/domains/vendorbyte.com/public_html/wp-content/plugins/elementorpro3171n/modules/theme-builder/documents/single-base.php(93): ElementorPro\Modules\ThemeBuilder\Documents\Theme_Document->print_content() #7 /home/u330303233/domains/vendorbyte.com/public_html/wp-content/plugins/elementorpro3171n/modules/woocommerce/documents/product.php(133): ElementorPro\Modules\ThemeBuilder\Documents\Single_Base->print_content() #8 /home/u330303233/domains/vendorbyte.com/public_html/wp-content/plugins/elementorpro3171n/modules/theme-builder/classes/locations-manager.php(364): ElementorPro\Modules\Woocommerce\Documents\Product->print_content() #9 /home/u330303233/domains/vendorbyte.com/public_html/wp-content/themes/astra/inc/compatibility/class-astra-elementor-pro.php(243): ElementorPro\Modules\ThemeBuilder\Classes\Locations_Manager->do_location() #10 /home/u330303233/domains/vendorbyte.com/public_html/wp-includes/class-wp-hook.php(324): ElementorPro\Modules\ThemeBuilder\ThemeSupport\Astra_Elementor_Pro->do_template_parts() #11 /home/u330303233/domains/vendorbyte.com/public_html/wp-includes/class-wp-hook.php(348): WP_Hook->apply_filters() #12 /home/u330303233/domains/vendorbyte.com/public_html/wp-includes/plugin.php(517): WP_Hook->do_action() #13 /home/u330303233/domains/vendorbyte.com/public_html/wp-content/themes/astra/inc/class-astra-loop.php(191): do_action() #14 /home/u330303233/domains/vendorbyte.com/public_html/wp-content/themes/astra/inc/class-astra-loop.php(174): Astra_Loop->loop_markup() #15 /home/u330303233/domains/vendorbyte.com/public_html/wp-includes/class-wp-hook.php(324): Astra_Loop->loop_markup_page() #16 /home/u330303233/domains/vendorbyte.com/public_html/wp-includes/class-wp-hook.php(348): WP_Hook->apply_filters() #17 /home/u330303233/domains/vendorbyte.com/public_html/wp-includes/plugin.php(517): WP_Hook->do_action() #18 /home/u330303233/domains/vendorbyte.com/public_html/wp-content/themes/astra/inc/core/theme-hooks.php(267): do_action() #19 /home/u330303233/domains/vendorbyte.com/public_html/wp-content/themes/astra/page.php(32): astra_content_page_loop() #20 /home/u330303233/domains/vendorbyte.com/public_html/wp-includes/template-loader.php(106): include('/home/u33030323...') #21 /home/u330303233/domains/vendorbyte.com/public_html/wp-blog-header.php(19): require_once('/home/u33030323...') #22 /home/u330303233/domains/vendorbyte.com/public_html/index.php(17): require('/home/u33030323...') #23 {main} thrown
解决步骤
1. 临时恢复页面编辑能力
- 登录WordPress后台,进入插件 > 已安装插件
- 找到
Dokan Lite插件,点击停用 - 此时再尝试用Elementor编辑页面,应该能正常打开,先恢复或重新编辑页面内容
2. 修复Dokan Lite代码问题
错误原因是own_product_not_purchasable_notice方法中,获取当前产品的函数返回了false,却直接调用get_id()方法。添加判断即可避免报错:
- 通过FTP或主机文件管理器,找到文件
/wp-content/plugins/dokan-lite/includes/Product/Hooks.php - 打开文件定位到第406行,在调用
get_id()前添加产品存在判断:// 原代码示例: $product_id = $product->get_id(); // 修改为: if ( ! $product ) { return; } $product_id = $product->get_id(); - 保存文件后重新启用Dokan Lite插件
3. 更新Dokan Lite到最新版本
该错误大概率是插件兼容性bug,官方可能已修复:
- 后台进入插件 > 已安装插件,检查Dokan Lite的更新提示
- 点击更新插件,完成后测试页面是否恢复正常
4. 检查插件与主题兼容性
- 确认WooCommerce、Elementor Pro、Dokan Lite、Astra主题均为最新版本
- 若更新后仍报错,切换到WordPress默认主题(如Twenty Twenty-Four)测试,排查主题兼容性问题
5. 重新设置WooCommerce页面
若页面仍空白:
- 进入WooCommerce > 设置 > 高级,点击页面设置下的恢复默认页面
- 重新用Elementor编辑这些页面,设置自定义内容
内容的提问来源于stack exchange,提问作者hyper
相关产品推荐
相关产品推荐

