Automattic\WooCommerce\Database\Migrations\CustomOrderTable
CLIRunner::toggle_compat_mode()
Toggles compatibility mode on or off.
Method of the class: CLIRunner{}
No Hooks.
Return
null
. Nothing (null).
Usage
// private - for code of main (parent) class only $result = $this->toggle_compat_mode( $enabled ): void;
- $enabled(true|false) (required)
- TRUE to enable compatibility mode, FALSE to disable.
Changelog
Since 9.1.0 | Introduced. |
CLIRunner::toggle_compat_mode() CLIRunner::toggle compat mode code WC 9.7.1
private function toggle_compat_mode( bool $enabled ): void { if ( ! $this->synchronizer->check_orders_table_exists() ) { if ( $enabled ) { $this->synchronizer->create_database_tables(); } else { WP_CLI::error( __( 'HPOS tables do not exist.', 'woocommerce' ) ); } } $currently_enabled = $this->synchronizer->data_sync_is_enabled(); if ( $currently_enabled === $enabled ) { if ( $enabled ) { WP_CLI::warning( __( 'Compatibility mode is already enabled.', 'woocommerce' ) ); } else { WP_CLI::warning( __( 'Compatibility mode is already disabled.', 'woocommerce' ) ); } return; } update_option( $this->synchronizer::ORDERS_DATA_SYNC_ENABLED_OPTION, wc_bool_to_string( $enabled ) ); if ( $enabled ) { WP_CLI::success( __( 'Compatibility mode enabled.', 'woocommerce' ) ); } else { WP_CLI::success( __( 'Compatibility mode disabled.', 'woocommerce' ) ); } }