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

WC_AJAX::shipping_classes_save_changes() public WC 1.0

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

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

Хуки из метода
Возвращает

Null. Ничего.

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

$result = WC_AJAX::shipping_classes_save_changes();

Код WC_AJAX::shipping_classes_save_changes() WC 4.7.1

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

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

	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 $term_id => $data ) {
		$term_id = absint( $term_id );

		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;
			}
			wp_delete_term( $term_id, 'product_shipping_class' );
			continue;
		}

		$update_args = array();

		if ( isset( $data['name'] ) ) {
			$update_args['name'] = wc_clean( $data['name'] );
		}

		if ( isset( $data['slug'] ) ) {
			$update_args['slug'] = wc_clean( $data['slug'] );
		}

		if ( isset( $data['description'] ) ) {
			$update_args['description'] = wc_clean( $data['description'] );
		}

		if ( isset( $data['newRow'] ) ) {
			$update_args = array_filter( $update_args );
			if ( empty( $update_args['name'] ) ) {
				continue;
			}
			$inserted_term = wp_insert_term( $update_args['name'], 'product_shipping_class', $update_args );
			$term_id       = is_wp_error( $inserted_term ) ? 0 : $inserted_term['term_id'];
		} else {
			wp_update_term( $term_id, 'product_shipping_class', $update_args );
		}

		do_action( 'woocommerce_shipping_classes_save_class', $term_id, $data );
	}

	$wc_shipping = WC_Shipping::instance();

	wp_send_json_success(
		array(
			'shipping_classes' => $wc_shipping->get_shipping_classes(),
		)
	);
}