WC_Install::verify_base_tables()public staticWC 1.0

Check if all the base tables are present.

Method of the class: WC_Install{}

No Hooks.

Return

Array. List of queries.

Usage

$result = WC_Install::verify_base_tables( $modify_notice, $execute );
$modify_notice(true|false)
Whether to modify notice based on if all tables are present.
Default: true
$execute(true|false)
Whether to execute get_schema queries as well.
Default: false

WC_Install::verify_base_tables() code WC 9.4.2

public static function verify_base_tables( $modify_notice = true, $execute = false ) {
	if ( $execute ) {
		self::create_tables();
	}

	$schema = self::get_schema();

	$hpos_settings = filter_var_array(
		array(
			'cot'       => get_option( CustomOrdersTableController::CUSTOM_ORDERS_TABLE_USAGE_ENABLED_OPTION ),
			'data_sync' => get_option( DataSynchronizer::ORDERS_DATA_SYNC_ENABLED_OPTION ),
		),
		array(
			'cot'       => FILTER_VALIDATE_BOOLEAN,
			'data_sync' => FILTER_VALIDATE_BOOLEAN,
		)
	);
	if ( in_array( true, $hpos_settings, true ) ) {
		$schema .= wc_get_container()
			->get( OrdersTableDataStore::class )
			->get_database_schema();
	}

	$missing_tables = wc_get_container()
		->get( DatabaseUtil::class )
		->get_missing_tables( $schema );

	if ( 0 < count( $missing_tables ) ) {
		if ( $modify_notice ) {
			WC_Admin_Notices::add_notice( 'base_tables_missing' );
		}
		update_option( 'woocommerce_schema_missing_tables', $missing_tables );
	} else {
		if ( $modify_notice ) {
			WC_Admin_Notices::remove_notice( 'base_tables_missing' );
		}
		update_option( 'woocommerce_schema_version', WC()->db_version );
		delete_option( 'woocommerce_schema_missing_tables' );
	}
	return $missing_tables;
}