WordPress at Your Fingertips
function is not described

WC_Data::save_meta_data() public WC 2.6.0

Update Meta Data in the database.

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

No Hooks.

Return

null. Nothing.

Usage

$WC_Data = new WC_Data();
$WC_Data->save_meta_data();

Changelog

Since 2.6.0 Introduced.

Code of WC_Data::save_meta_data() WC 5.8.0

public function save_meta_data() {
	if ( ! $this->data_store || is_null( $this->meta_data ) ) {
		return;
	}
	foreach ( $this->meta_data as $array_key => $meta ) {
		if ( is_null( $meta->value ) ) {
			if ( ! empty( $meta->id ) ) {
				$this->data_store->delete_meta( $this, $meta );
				unset( $this->meta_data[ $array_key ] );
			}
		} elseif ( empty( $meta->id ) ) {
			$meta->id = $this->data_store->add_meta( $this, $meta );
			$meta->apply_changes();
		} else {
			if ( $meta->get_changes() ) {
				$this->data_store->update_meta( $this, $meta );
				$meta->apply_changes();
			}
		}
	}
	if ( ! empty( $this->cache_group ) ) {
		$cache_key = WC_Cache_Helper::get_cache_prefix( $this->cache_group ) . WC_Cache_Helper::get_cache_prefix( 'object_' . $this->get_id() ) . 'object_meta_' . $this->get_id();
		wp_cache_delete( $cache_key, $this->cache_group );
	}
}