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 9.9.5

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 );

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

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

	return $result;
}