wordpress - Is there any way to load woo-commerce classes before the form submit action function
问题描述
I have created a function to add products to the woo-commerce programmatically and tested it on admin_init hook and it is working fine. But when I am running the same function using form submit action it is showing the class not found errors as till now woo-commerce class are not loaded.
I have manually included few classes but in those classes itself some constant and other classes are used which comes with woo-commerce and causing the same fatal error.
Is there any way so that I can load all the classes before my function start executing.
解决方案
Function is working fine when it is moved from custom plugin to function.php. Reason is WordPress load plugins before the theme files.
推荐阅读
- ruby-on-rails - 如何在嵌套模型rails 6中从孩子获取父母
- json - 如何将此 JSON 转换为 CSV?
- cygwin - 我正在使用 cygwin 安装 ns2,但是当我将 ns2 文件夹粘贴到 c/cygwin/home/systemname 文件夹中时,它没有确认?
- ldap - 在 NFS 上首次登录时创建 Ldap 用户主目录
- javascript - 使用 JavaScript 如何从 nodejs 覆盖预先存在的 csv 文件中的二维数组
- visualization - 如何将多个 xml-vtk 文件(vtu、vti)组合成一个以获得动画?
- angular - 无法验证 Angular 12 中的表单
- vue.js - vue i18n 无法从语言环境加载翻译
- html - Html Css表格格式合并行
- swift - 在 WebView Swift 5 中拉动刷新