WordPress at Your Fingertips
function is not described

WC_Shipping_Zone_Data_Store::delete() public WC 3.0.0

Deletes a shipping zone from the database.

{} It's a method of the class: WC_Shipping_Zone_Data_Store{}

Hooks from the method
Return

null. Nothing.

Usage

$WC_Shipping_Zone_Data_Store = new WC_Shipping_Zone_Data_Store();
$WC_Shipping_Zone_Data_Store->delete( $zone, $args );
$zone(WC_Shipping_Zone) (required) (passed by reference — &)
Shipping zone object.
$args(array)
Array of args to pass to the delete method.
Default: array()

Changelog

Since 3.0.0 Introduced.

Code of WC_Shipping_Zone_Data_Store::delete() WC 5.7.0

public function delete( &$zone, $args = array() ) {
	$zone_id = $zone->get_id();

	if ( $zone_id ) {
		global $wpdb;

		// Delete methods and their settings.
		$methods = $this->get_methods( $zone_id, false );

		if ( $methods ) {
			foreach ( $methods as $method ) {
				$this->delete_method( $method->instance_id );
			}
		}

		// Delete zone.
		$wpdb->delete( $wpdb->prefix . 'woocommerce_shipping_zone_locations', array( 'zone_id' => $zone_id ) );
		$wpdb->delete( $wpdb->prefix . 'woocommerce_shipping_zones', array( 'zone_id' => $zone_id ) );

		$zone->set_id( null );

		WC_Cache_Helper::invalidate_cache_group( 'shipping_zones' );
		WC_Cache_Helper::get_transient_version( 'shipping', true );

		do_action( 'woocommerce_delete_shipping_zone', $zone_id );
	}
}