首页 > 解决方案 > 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.

标签: wordpresswoocommerce

解决方案


Function is working fine when it is moved from custom plugin to function.php. Reason is WordPress load plugins before the theme files.


推荐阅读