get(FeaturesController::class); if ($featuresController instanceof FeaturesController) { $featuresController->change_feature_enable('custom_order_tables', true); } } add_action( 'init', 'mailpoet_enable_cot', 99 ); /** * Add wp create_cot WP CLI command for creating Custom Order Tables from command line */ function mailpoet_create_cot() { if (!function_exists('wc_get_container')) { WP_CLI::error('Can‘t create COT. WooCommerce is not active!'); } try { /** @var DataSynchronizer $dataSynchronizer */ $dataSynchronizer = wc_get_container()->get(DataSynchronizer::class); } catch (\Exception $e) { WP_CLI::error('DataSynchronizer for COT not found. Does installed WooCommerce version support COT? ' . $e->getMessage()); } $dataSynchronizer->create_database_tables(); WP_CLI::success('Database tables for COT feature created.'); } if (class_exists(WP_CLI::class)) { WP_CLI::add_command('create_cot', 'mailpoet_create_cot'); } // Related PR in WooCommerce: https://github.com/woocommerce/woocommerce/pull/39988 // Sometimes during tests can happen that orders are out of sync. This state can trigger and exception // The following filter avoids this state add_filter('wc_allow_changing_orders_storage_while_sync_is_pending', '__return_true');