Automattic\WooCommerce\Internal\DataStores\Orders

CustomOrdersTableController::add_initiate_regeneration_entry_to_tools_array()privateWC 1.0

Add an entry to Status - Tools to create or regenerate the custom orders table, and also an entry to delete the table as appropriate.

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

Хуков нет.

Возвращает

Массив. The updated array of tools-

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

// private - только в коде основоного (родительского) класса
$result = $this->add_initiate_regeneration_entry_to_tools_array( $tools_array ): array;
$tools_array(массив) (обязательный)
The array of tools to add the tool to.

Код CustomOrdersTableController::add_initiate_regeneration_entry_to_tools_array() WC 7.3.0

private function add_initiate_regeneration_entry_to_tools_array( array $tools_array ): array {
	if ( ! $this->data_synchronizer->check_orders_table_exists() ) {
		return $tools_array;
	}

	if ( $this->is_feature_visible() ) {
		$disabled = true;
		$message  = __( 'This will delete the custom orders tables. The tables can be deleted only if the "High-Performance order storage" feature is disabled (via Settings > Advanced > Features).', 'woocommerce' );
	} else {
		$disabled = false;
		$message  = __( 'This will delete the custom orders tables. To create them again enable the "High-Performance order storage" feature (via Settings > Advanced > Features).', 'woocommerce' );
	}

	$tools_array['delete_custom_orders_table'] = array(
		'name'             => __( 'Delete the custom orders tables', 'woocommerce' ),
		'desc'             => sprintf(
			'<strong class="red">%1$s</strong> %2$s',
			__( 'Note:', 'woocommerce' ),
			$message
		),
		'requires_refresh' => true,
		'callback'         => function () {
			$this->features_controller->change_feature_enable( 'custom_order_tables', false );
			$this->delete_custom_orders_tables();
			return __( 'Custom orders tables have been deleted.', 'woocommerce' );
		},
		'button'           => __( 'Delete', 'woocommerce' ),
		'disabled'         => $disabled,
	);

	return $tools_array;
}