Automattic\WooCommerce\Blueprint\Importers

ImportSetSiteOptions::processpublicWC 1.0

Process the step.

Method of the class: ImportSetSiteOptions{}

No Hooks.

Returns

StepProcessorResult.

Usage

$ImportSetSiteOptions = new ImportSetSiteOptions();
$ImportSetSiteOptions->process( $schema ): StepProcessorResult;
$schema(object) (required)
The schema to process.

ImportSetSiteOptions::process() code WC 10.6.2

public function process( $schema ): StepProcessorResult {
	$result = StepProcessorResult::success( SetSiteOptions::get_step_name() );
	foreach ( $schema->options as $key => $value ) {
		// Skip if the option should not be modified.
		if ( in_array( $key, self::RESTRICTED_OPTIONS, true ) ) {
			$result->add_warn( "Cannot modify '{$key}' option: Modifying is restricted for this key." );
			continue;
		}

		$value         = json_decode( wp_json_encode( $value ), true );
		$updated       = $this->wp_update_option( $key, $value );
		$current_value = $this->wp_get_option( $key );

		if ( $current_value !== $value ) {
			$result->add_warn( "{$key} was intended to be set, but the stored value may have been overridden by a hook." );
			continue;
		}

		if ( $updated ) {
			$result->add_info( "{$key} has been updated." );
			continue;
		}

		if ( $current_value === $value ) {
			$result->add_info( "{$key} has not been updated because the current value is already up to date." );
		}
	}

	return $result;
}