Karan Batra
Karan Batra

Reputation: 171

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.

Upvotes: 0

Views: 200

Answers (1)

Karan Batra
Karan Batra

Reputation: 171

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

Upvotes: 1

Related Questions