Hello everyone,
I’m developing a custom function to create a WooCommerce order immediately after a user accepts an offer. I’ve encountered a very persistent technical issue where the HivePress API is not fully initialized when my code runs.
My Environment Setup:
-
My custom PHP code is running from an MU-Plugin file.
-
I am hooking into the
initaction at the highest priority (999) to ensure late execution. -
The main
hivepress()function exists.
The Problem:
When my code attempts to access the models object (e.g., hivepress()->models->get('offer')), the $models property is NULL.
The Diagnostic Proof:
We have confirmed this is a dependency issue, as my debug log shows the function is running, but the dependency is not ready:
[HP_AcceptOffer] core called; offer_id=XX; user=YY
[HP_AcceptOffer] HivePress function exists. Proceeding to API calls.
[HP_AcceptOffer] Models NULL after core check. Fatal plugin conflict suspected.
[HP_AcceptOffer] Redirection handler failed: API Error: HivePress models failed to initialize during standard page load. Check plugin order.
(Note: I have removed server path information from the full log.)
Question for the Community/Developers:
What is the official HivePress hook or the recommended method to ensure the $models object is fully initialized and guaranteed to be available before accessing the API in a non-AJAX context (like a standard form submission handler on the init hook)?
Thank you for any architectural guidance!