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

WC_AJAX::shipping_zones_save_changes() public WC 1.0

Handle submissions from assets/js/wc-shipping-zones.js Backbone model.

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

Хуков нет.

Возвращает

Null. Ничего.

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

$result = WC_AJAX::shipping_zones_save_changes();

Код WC_AJAX::shipping_zones_save_changes() WC 4.7.1

<?php
public static function shipping_zones_save_changes() {
	if ( ! isset( $_POST['wc_shipping_zones_nonce'], $_POST['changes'] ) ) {
		wp_send_json_error( 'missing_fields' );
		wp_die();
	}

	if ( ! wp_verify_nonce( wp_unslash( $_POST['wc_shipping_zones_nonce'] ), 'wc_shipping_zones_nonce' ) ) { // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
		wp_send_json_error( 'bad_nonce' );
		wp_die();
	}

	// Check User Caps.
	if ( ! current_user_can( 'manage_woocommerce' ) ) {
		wp_send_json_error( 'missing_capabilities' );
		wp_die();
	}

	$changes = wp_unslash( $_POST['changes'] ); // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
	foreach ( $changes as $zone_id => $data ) {
		if ( isset( $data['deleted'] ) ) {
			if ( isset( $data['newRow'] ) ) {
				// So the user added and deleted a new row.
				// That's fine, it's not in the database anyways. NEXT!
				continue;
			}
			WC_Shipping_Zones::delete_zone( $zone_id );
			continue;
		}

		$zone_data = array_intersect_key(
			$data,
			array(
				'zone_id'    => 1,
				'zone_order' => 1,
			)
		);

		if ( isset( $zone_data['zone_id'] ) ) {
			$zone = new WC_Shipping_Zone( $zone_data['zone_id'] );

			if ( isset( $zone_data['zone_order'] ) ) {
				$zone->set_zone_order( $zone_data['zone_order'] );
			}

			$zone->save();
		}
	}

	wp_send_json_success(
		array(
			'zones' => WC_Shipping_Zones::get_zones( 'json' ),
		)
	);
}