WC_Shipping_Zone::save()publicWC 1.0

Save zone data to the database.

Method of the class: WC_Shipping_Zone{}

Return

Int.

Usage

$WC_Shipping_Zone = new WC_Shipping_Zone();
$WC_Shipping_Zone->save();

WC_Shipping_Zone::save() code WC 9.4.2

public function save() {
	if ( ! $this->get_zone_name() ) {
		$this->set_zone_name( $this->generate_zone_name() );
	}

	if ( ! $this->data_store ) {
		return $this->get_id();
	}

	/**
	 * Trigger action before saving to the DB. Allows you to adjust object props before save.
	 *
	 * @param WC_Data          $this The object being saved.
	 * @param WC_Data_Store_WP $data_store THe data store persisting the data.
	 */
	do_action( 'woocommerce_before_' . $this->object_type . '_object_save', $this, $this->data_store );

	if ( null !== $this->get_id() ) {
		$this->data_store->update( $this );
	} else {
		$this->data_store->create( $this );
	}

	/**
	 * Trigger action after saving to the DB.
	 *
	 * @param WC_Data          $this The object being saved.
	 * @param WC_Data_Store_WP $data_store THe data store persisting the data.
	 */
	do_action( 'woocommerce_after_' . $this->object_type . '_object_save', $this, $this->data_store );

	return $this->get_id();
}