Automattic\WooCommerce\Internal\DataStores\Orders

LegacyDataCleanup::get_tools_entries()publicWC 1.0

Returns an array in format required by woocommerce_debug_tools register the cleanup tool in WC.

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

Хуков нет.

Возвращает

Массив. Tools entries to register with WC.

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

$LegacyDataCleanup = new LegacyDataCleanup();
$LegacyDataCleanup->get_tools_entries();

Код LegacyDataCleanup::get_tools_entries() WC 9.7.1

public function get_tools_entries() {
	$orders_for_cleanup_exist = ! empty( $this->legacy_handler->get_orders_for_cleanup( array(), 1 ) );
	$entry_id                 = $this->is_flag_set() ? 'hpos_legacy_cleanup_cancel' : 'hpos_legacy_cleanup';
	$entry                    = array(
		'name'             => __( 'Clean up order data from legacy tables', 'woocommerce' ),
		'desc'             => __( 'This tool will clear the data from legacy order tables in WooCommerce.', 'woocommerce' ),
		'requires_refresh' => true,
		'button'           => __( 'Clear data', 'woocommerce' ),
		'disabled'         => ! ( $this->can_run() && ( $orders_for_cleanup_exist || $this->is_flag_set() ) ),
	);

	if ( ! $this->can_run() ) {
		$entry['desc'] .= '<br />';
		$entry['desc'] .= sprintf(
			'<strong class="red">%1$s</strong> %2$s',
			__( 'Note:', 'woocommerce' ),
			__( 'Only available when HPOS is authoritative and compatibility mode is disabled.', 'woocommerce' )
		);
	} else {
		if ( $this->is_flag_set() ) {
			$entry['status_text'] = sprintf(
				'%1$s %2$s',
				'<span class="dashicons dashicons-update spin"></span>',
				__( 'Clearing data...', 'woocommerce' )
			);
			$entry['button']      = __( 'Cancel', 'woocommerce' );
			$entry['callback']    = function() {
				$this->toggle_flag( false );
				return __( 'Order legacy data cleanup has been canceled.', 'woocommerce' );
			};
		} elseif ( ! $orders_for_cleanup_exist ) {
			$entry['button'] = __( 'No orders in need of cleanup', 'woocommerce' );
		} else {
			$entry['callback'] = function() {
				$this->toggle_flag( true );
				return __( 'Order legacy data cleanup process has been started.', 'woocommerce' );
			};
		}
	}

	return array( $entry_id => $entry );
}