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 6.6.1

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

	if ( $this->data_synchronizer->check_orders_table_exists() ) {
		$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' ),
				__( 'This will delete the custom orders tables. The tables can be deleted only if they are not not in use (via Settings > Advanced > Custom data stores). You can create them again at any time with the "Create the custom orders tables" tool.', 'woocommerce' )
			),
			'requires_refresh' => true,
			'callback'         => function () {
				$this->delete_custom_orders_tables();
				return __( 'Custom orders tables have been deleted.', 'woocommerce' );
			},
			'button'           => __( 'Delete', 'woocommerce' ),
			'disabled'         => $this->custom_orders_table_usage_is_enabled(),
		);
	} else {
		$tools_array['create_custom_orders_table'] = array(
			'name'             => __( 'Create the custom orders tables', 'woocommerce' ),
			'desc'             => __( 'This tool will create the custom orders tables. Once created you can go to WooCommerce > Settings > Advanced > Custom data stores and configure the usage of the tables.', 'woocommerce' ),
			'requires_refresh' => true,
			'callback'         => function() {
				$this->create_custom_orders_tables();
				return __( 'Custom orders tables have been created. You can now go to WooCommerce > Settings > Advanced > Custom data stores.', 'woocommerce' );
			},
			'button'           => __( 'Create', 'woocommerce' ),
		);
	}

	return $tools_array;
}