Plugin vs Settings load order (woocommerce dependency)

I am developing a Woocommerce dependent plugin which works, and a settings page which behaves funky

if ( !defined( ‘ABSPATH’ ) ) {exit;}

if ( !class_exists( ‘WooCommerce_Chilexpress_Tags_Settings’ ) ) {

class WooCommerce_Chilexpress_Tags_Settings extends WC_Settings_Page{

}

function my_plugin_add_settings() {
return new WooCommerce_Chilexpress_Tags_Settings();
}
}

add_filter( ‘woocommerce_get_settings_pages’, ‘my_plugin_add_settings’, 15 );

this code is in a includes/mysettings.php which is loaded during the plugin init, which alphabetically is woocommerce-chilexpress-etiquetas, so it should be loaded after woocommerce

For a reason I don’t understand yet, my plugin settings are loaded always before WooCommerce Settings though throwing me a PHP Fatal Error:

PHP Fatal error: Class ‘WC_Settings_Page’ not found

The obvious dirty fix was to insert the WC_Settings_Page code into my own settings.
I am trying now to clean this up but somehow it won’t work…

So the (yes I know very broad) question is: What could I miss?

Read more here:: Plugin vs Settings load order (woocommerce dependency)

Leave a Reply

Your email address will not be published. Required fields are marked *