WC_Shipping_Zone_Data_Store::create()publicWC 3.0.0

Method to create a new shipping zone.

Method of the class: WC_Shipping_Zone_Data_Store{}

No Hooks.

Return

null. Nothing (null).

Usage

$WC_Shipping_Zone_Data_Store = new WC_Shipping_Zone_Data_Store();
$WC_Shipping_Zone_Data_Store->create( $zone );
$zone(WC_Shipping_Zone) (required) (passed by reference — &)
Shipping zone object.

Changelog

Since 3.0.0 Introduced.

WC_Shipping_Zone_Data_Store::create() code WC 9.4.2

public function create( &$zone ) {
	global $wpdb;
	$wpdb->insert(
		$wpdb->prefix . 'woocommerce_shipping_zones',
		array(
			'zone_name'  => $zone->get_zone_name(),
			'zone_order' => $zone->get_zone_order(),
		)
	);
	$zone->set_id( $wpdb->insert_id );
	$zone->save_meta_data();
	$this->save_locations( $zone );
	$zone->apply_changes();
	WC_Cache_Helper::invalidate_cache_group( 'shipping_zones' );
	WC_Cache_Helper::get_transient_version( 'shipping', true );
}