Automattic\WooCommerce\Admin\Features\Blueprint\Importers

ImportSetWCShipping::process()publicWC 1.0

Process the import of WooCommerce shipping settings.

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

Хуков нет.

Возвращает

StepProcessorResult.

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

$ImportSetWCShipping = new ImportSetWCShipping();
$ImportSetWCShipping->process( $schema ): StepProcessorResult;
$schema(объект) (обязательный)
The schema object containing import details.

Код ImportSetWCShipping::process() WC 9.7.1

public function process( $schema ): StepProcessorResult {
	$result = StepProcessorResult::success( SetWCShipping::get_step_name() );

	$fields = array(
		'terms'              => array( 'terms', array( '%d', '%s', '%s', '%d' ) ),
		'classes'            => array( 'term_taxonomy', array( '%d', '%d', '%s', '%s', '%d', '%d' ) ),
		'shipping_zones'     => array( 'woocommerce_shipping_zones', array( '%d', '%s', '%d' ) ),
		'shipping_methods'   => array( 'woocommerce_shipping_zone_methods', array( '%d', '%d', '%s', '%d', '%d' ) ),
		'shipping_locations' => array( 'woocommerce_shipping_zone_locations', array( '%d', '%d', '%s', '%s' ) ),
	);

	foreach ( $fields as $name => $data ) {
		if ( isset( $schema->values->{$name} ) ) {
			$filter_method = 'filter_' . $name . '_data';
			if ( method_exists( $this, $filter_method ) ) {
				$insert_values = $this->$filter_method( $schema->values->{$name} );
			} else {
				$insert_values = $schema->values->{$name};
			}

			$this->insert( $data[0], $data[1], $insert_values );
			// check if function with process_$name exist and call it.
			$method = 'post_process_' . $name;
			if ( method_exists( $this, $method ) ) {
				$this->$method( $schema->values->{$name} );
			}
		}
	}

	if ( isset( $schema->values->local_pickup ) ) {
		$this->add_local_pickup( $schema->values->local_pickup );
	}

	return $result;
}