Automattic\WooCommerce\Internal\DataStores\Orders

CustomOrdersTableController::get_hpos_setting_for_feature()privateWC 1.0

Returns the HPOS setting for rendering HPOS vs Post setting block in Features section of the settings page.

Method of the class: CustomOrdersTableController{}

No Hooks.

Return

Array. Feature setting object.

Usage

// private - for code of main (parent) class only
$result = $this->get_hpos_setting_for_feature();

CustomOrdersTableController::get_hpos_setting_for_feature() code WC 9.3.3

private function get_hpos_setting_for_feature() {
	if ( 'yes' === get_transient( 'wc_installing' ) ) {
		return array();
	}

	$get_value = function () {
		return $this->custom_orders_table_usage_is_enabled() ? 'yes' : 'no';
	};

	/**
	 * ⚠️The FeaturesController instance must only be accessed from within the callback functions. Otherwise it
	 * gets called while it's still being instantiated and creates and endless loop.
	 */

	$get_desc = function () {
		$plugin_compatibility = $this->features_controller->get_compatible_plugins_for_feature( 'custom_order_tables', true );

		return $this->plugin_util->generate_incompatible_plugin_feature_warning( 'custom_order_tables', $plugin_compatibility );
	};

	$get_disabled = function () {
		$compatibility_info = $this->features_controller->get_compatible_plugins_for_feature( 'custom_order_tables', true );
		$sync_complete      = 0 === $this->data_synchronizer->get_current_orders_pending_sync_count();
		$disabled           = array();
		// Changing something here? You might also want to look at `enable|disable` functions in Automattic\WooCommerce\Database\Migrations\CustomOrderTable\CLIRunner.
		$incompatible_plugins = $this->plugin_util->get_items_considered_incompatible( 'custom_order_tables', $compatibility_info );
		$incompatible_plugins = array_diff( $incompatible_plugins, $this->plugin_util->get_plugins_excluded_from_compatibility_ui() );
		if ( count( $incompatible_plugins ) > 0 ) {
			$disabled = array( 'yes' );
		}
		if ( ! $sync_complete && ! $this->changing_data_source_with_sync_pending_is_allowed() ) {
			$disabled = array( 'yes', 'no' );
		}

		return $disabled;
	};

	return array(
		'id'          => self::CUSTOM_ORDERS_TABLE_USAGE_ENABLED_OPTION,
		'title'       => __( 'Order data storage', 'woocommerce' ),
		'type'        => 'radio',
		'options'     => array(
			'no'  => __( 'WordPress posts storage (legacy)', 'woocommerce' ),
			'yes' => __( 'High-performance order storage (recommended)', 'woocommerce' ),
		),
		'value'       => $get_value,
		'disabled'    => $get_disabled,
		'desc'        => $get_desc,
		'desc_at_end' => true,
		'row_class'   => self::CUSTOM_ORDERS_TABLE_USAGE_ENABLED_OPTION,
	);
}