Automattic\WooCommerce\Internal\ProductAttributesLookup

CLIRunner::enable_core()privateWC 1.0

Core method for the "enable" command.

Метод класса: CLIRunner{}

Хуков нет.

Возвращает

null. Ничего (null).

Использование

// private - только в коде основоного (родительского) класса
$result = $this->enable_core( $args, $assoc_args );
$args(массив) (обязательный)
Positional arguments passed to the command.
$assoc_args(массив) (обязательный)
Associative arguments (options) passed to the command.

Код CLIRunner::enable_core() WC 9.7.1

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." );
}