How to Force a Plugin to Claim Compatibility with WooCommerce HPOS

If you want to try WooCommerce HPOS in your website and it says some plugins are incompatible with HPOS, then you should check those plugins’ code first.

First make sure their codes don’t contain “update_post_meta or get_post_meta for orders. (for products it is ok). If they have, it can cause a problem.

If you are sure that the incompatible plugin has nothing to do with HPOS and doesn’t affect order processing, then you can claim it is compatible – without modifying its source code.

Open your theme’s functions.php and place such a block there:

add_action( 'before_woocommerce_init', function() {
	if ( class_exists( \Automattic\WooCommerce\Utilities\FeaturesUtil::class ) ) {
        $force_compat_hposs=[
			'woocommerce-follow-up-emails/woocommerce-follow-up-emails.php',
			'woocommerce-gateway-usa-epay/woocommerce-gateway-usa-epay.php'
//and so on...
       ];
        foreach($force_compat_hposs as $force_compat_hpos){
            \Automattic\WooCommerce\Utilities\FeaturesUtil::declare_compatibility( 'custom_order_tables', WP_CONTENT_DIR.'/plugins/'.($force_compat_hpos), true );
        }
		
	}
} );

The strings “woocommerce-follow-up-emails/woocommerce-follow-up-emails.php” and “woocommerce-gateway-usa-epay/woocommerce-gateway-usa-epay.php” are just examples and you should replace those with real plugin slugs of your plugins.

After that “incompatibility” barrier will be disappeared and you will be able to activate HPOS. Of course it is recommended to activate it in DUAL MODE first, because it is 100% safe. After few days of observation you can switch to HPOS only mode.

Get more useful WP tricks and snippets by subscribing to my mailclub.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.