WordPress как на ладони
Недорогой хостинг для сайтов на WordPress: wordpress.jino.ru
функция не описана

WC_Admin_Setup_Wizard::wc_setup_shipping_save() public WC 1.0

Save shipping options.

Это метод класса: WC_Admin_Setup_Wizard{}

Хуков нет.

Возвращает

Null. Ничего.

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

$WC_Admin_Setup_Wizard = new WC_Admin_Setup_Wizard();
$WC_Admin_Setup_Wizard->wc_setup_shipping_save();

Код WC_Admin_Setup_Wizard::wc_setup_shipping_save() WC 4.5.2

woocommerce/includes/admin/class-wc-admin-setup-wizard.php
<?php
public function wc_setup_shipping_save() {
	check_admin_referer( 'wc-setup' );

	// @codingStandardsIgnoreStart
	$setup_domestic   = isset( $_POST['shipping_zones']['domestic']['enabled'] ) && ( 'yes' === $_POST['shipping_zones']['domestic']['enabled'] );
	$domestic_method  = isset( $_POST['shipping_zones']['domestic']['method'] ) ? sanitize_text_field( wp_unslash( $_POST['shipping_zones']['domestic']['method'] ) ) : '';
	$setup_intl       = isset( $_POST['shipping_zones']['intl']['enabled'] ) && ( 'yes' === $_POST['shipping_zones']['intl']['enabled'] );
	$intl_method      = isset( $_POST['shipping_zones']['intl']['method'] ) ? sanitize_text_field( wp_unslash( $_POST['shipping_zones']['intl']['method'] ) ) : '';
	$weight_unit      = sanitize_text_field( wp_unslash( $_POST['weight_unit'] ) );
	$dimension_unit   = sanitize_text_field( wp_unslash( $_POST['dimension_unit'] ) );
	$existing_zones   = WC_Shipping_Zones::get_zones();
	// @codingStandardsIgnoreEnd

	update_option( 'woocommerce_ship_to_countries', '' );
	update_option( 'woocommerce_weight_unit', $weight_unit );
	update_option( 'woocommerce_dimension_unit', $dimension_unit );

	$setup_wcs_labels  = isset( $_POST['setup_woocommerce_services'] ) && 'yes' === $_POST['setup_woocommerce_services'];
	$setup_shipstation = isset( $_POST['setup_shipstation'] ) && 'yes' === $_POST['setup_shipstation'];

	update_option( 'woocommerce_setup_shipping_labels', $setup_wcs_labels );

	if ( $setup_wcs_labels ) {
		$this->install_woocommerce_services();
	}

	if ( $setup_shipstation ) {
		$this->install_plugin(
			'woocommerce-shipstation-integration',
			array(
				'name'      => __( 'ShipStation', 'woocommerce' ),
				'repo-slug' => 'woocommerce-shipstation-integration',
				'file'      => 'woocommerce-shipstation.php',
			)
		);
	}

	// For now, limit this setup to the first run.
	if ( ! empty( $existing_zones ) ) {
		wp_safe_redirect( esc_url_raw( $this->get_next_step_link() ) );
		exit;
	}

	/*
	 * If enabled, create a shipping zone containing the country the
	 * store is located in, with the selected method preconfigured.
	 */
	if ( $setup_domestic ) {
		$zone = new WC_Shipping_Zone( null );
		$zone->set_zone_order( 0 );
		$zone->add_location( WC()->countries->get_base_country(), 'country' );
		$zone_id = $zone->save();

		// Save chosen shipping method settings (using REST controller for convenience).
		if ( ! empty( $_POST['shipping_zones']['domestic'][ $domestic_method ] ) ) { // WPCS: input var ok.

			// Sanitize the cost field.
			$domestic_cost = wc_clean( wp_unslash( $_POST['shipping_zones']['domestic'][ $domestic_method ] ) );
			$domestic_cost = str_replace( array( get_woocommerce_currency_symbol(), html_entity_decode( get_woocommerce_currency_symbol() ) ), '', $domestic_cost );

			// Build and make a REST request to save the shipping zone and method set.
			$request = new WP_REST_Request( 'POST', "/wc/v3/shipping/zones/{$zone_id}/methods" );
			$request->add_header( 'Content-Type', 'application/json' );
			$request->set_body(
				wp_json_encode(
					array(
						'method_id' => $domestic_method,
						'settings'  => $domestic_cost,
					)
				)
			);
			rest_do_request( $request );
		}
	}

	// If enabled, set the selected method for the "rest of world" zone.
	if ( $setup_intl ) {
		// Save chosen shipping method settings (using REST controller for convenience).
		if ( ! empty( $_POST['shipping_zones']['intl'][ $intl_method ] ) ) { // WPCS: input var ok.

			// Sanitize the cost field.
			$intl_cost = wc_clean( wp_unslash( $_POST['shipping_zones']['intl'][ $intl_method ] ) );
			$intl_cost = str_replace( array( get_woocommerce_currency_symbol(), html_entity_decode( get_woocommerce_currency_symbol() ) ), '', $intl_cost );

			// Build and make a REST request to save the shipping zone and method set.
			$request = new WP_REST_Request( 'POST', '/wc/v3/shipping/zones/0/methods' );
			$request->add_header( 'Content-Type', 'application/json' );
			$request->set_body(
				wp_json_encode(
					array(
						'method_id' => $intl_method,
						'settings'  => $intl_cost,
					)
				)
			);
			rest_do_request( $request );
		}
	}

	// Notify the user that no shipping methods are configured.
	if ( ! $setup_domestic && ! $setup_intl ) {
		WC_Admin_Notices::add_notice( 'no_shipping_methods' );
	}

	wp_safe_redirect( esc_url_raw( $this->get_next_step_link() ) );
	exit;
}