@claudiulodro Thanks for your reply.
The ‘woocommerce_loaded’ action didn’t work for me and created a memory leak. But I found that the ‘plugins_loaded’ hook (https://codex.www.ads-software.com/Plugin_API/Action_Reference/plugins_loaded) did work :).