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

WC_REST_Shipping_Zone_Methods_V2_Controller::delete_item() public WC 1.0

Delete a shipping method instance.

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

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

WP_Error/true/false.

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

$WC_REST_Shipping_Zone_Methods_V2_Controller = new WC_REST_Shipping_Zone_Methods_V2_Controller();
$WC_REST_Shipping_Zone_Methods_V2_Controller->delete_item( $request );
$request(WP_REST_Request) (обязательный)
Full details about the request.

Код WC_REST_Shipping_Zone_Methods_V2_Controller::delete_item() WC 4.7.1

<?php
public function delete_item( $request ) {
	$zone = $this->get_zone( $request['zone_id'] );
	if ( is_wp_error( $zone ) ) {
		return $zone;
	}

	$instance_id = (int) $request['instance_id'];
	$force       = $request['force'];

	$methods = $zone->get_shipping_methods();
	$method  = false;

	foreach ( $methods as $method_obj ) {
		if ( $instance_id === $method_obj->instance_id ) {
			$method = $method_obj;
			break;
		}
	}

	if ( false === $method ) {
		return new WP_Error( 'woocommerce_rest_shipping_zone_method_invalid', __( 'Resource does not exist.', 'woocommerce' ), array( 'status' => 404 ) );
	}

	$method = $this->update_fields( $instance_id, $method, $request );
	if ( is_wp_error( $method ) ) {
		return $method;
	}

	$request->set_param( 'context', 'view' );
	$response = $this->prepare_item_for_response( $method, $request );

	// Actually delete.
	if ( $force ) {
		$zone->delete_shipping_method( $instance_id );
	} else {
		return new WP_Error( 'rest_trash_not_supported', __( 'Shipping methods do not support trashing.', 'woocommerce' ), array( 'status' => 501 ) );
	}

	/**
	 * Fires after a product review is deleted via the REST API.
	 *
	 * @param object           $method
	 * @param WP_REST_Response $response        The response data.
	 * @param WP_REST_Request  $request         The request sent to the API.
	 */
	do_action( 'rest_delete_product_review', $method, $response, $request );

	return $response;
}