WC_Shipping_Zone_Data_Store::delete()
Deletes a shipping zone from the database.
Method of the class: WC_Shipping_Zone_Data_Store{}
Hooks from the method
Return
null
. Nothing (null).
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. |
WC_Shipping_Zone_Data_Store::delete() WC Shipping Zone Data Store::delete code WC 9.4.2
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 ); } }