Automattic\WooCommerce\Internal\ProductAttributesLookup

CLIRunner::enable_coreprivateWC 1.0

Core method for the "enable" command.

Method of the class: CLIRunner{}

No Hooks.

Returns

null. Nothing (null).

Usage

// private - for code of main (parent) class only
$result = $this->enable_core( $args, $assoc_args );
$args(array) (required)
Positional arguments passed to the command.
$assoc_args(array) (required)
Associative arguments (options) passed to the command.

CLIRunner::enable_core() code WC 9.8.5

private function enable_core( array $args, array $assoc_args ) {
	$table_name = $this->lookup_data_store->get_lookup_table_name();
	if ( 'yes' === get_option( 'woocommerce_attribute_lookup_enabled' ) ) {
		$this->warning( "The usage of the of the %W{$table_name}%n table is already enabled." );
		return;
	}

	if ( ! array_key_exists( 'force', $assoc_args ) ) {
		$must_confirm = true;
		if ( $this->lookup_data_store->regeneration_is_in_progress() ) {
			$this->warning( "The regeneration of the %W{$table_name}%n table is currently in process." );
		} elseif ( $this->lookup_data_store->regeneration_was_aborted() ) {
			$this->warning( "The regeneration of the %W{$table_name}%n table was aborted." );
		} elseif ( 0 === $this->get_lookup_table_info()['total_rows'] ) {
			$this->warning( "The %W{$table_name}%n table is empty." );
		} else {
			$must_confirm = false;
		}

		if ( $must_confirm ) {
			WP_CLI::confirm( 'Are you sure that you want to enable the table usage?' );
		}
	}

	update_option( 'woocommerce_attribute_lookup_enabled', 'yes' );
	$table_name = $this->lookup_data_store->get_lookup_table_name();
	$this->success( "The usage of the %W{$table_name}%n table for product attribute lookup has been enabled." );
}