WordPress at Your Fingertips
function is not described

WC_Data::__clone() public WC 3.0.2

When the object is cloned, make sure meta is duplicated correctly.

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

No Hooks.

Return

null. Nothing.

Usage

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

Changelog

Since 3.0.2 Introduced.

Code of WC_Data::__clone() WC 5.5.2

<?php
public function __clone() {
	$this->maybe_read_meta_data();
	if ( ! empty( $this->meta_data ) ) {
		foreach ( $this->meta_data as $array_key => $meta ) {
			$this->meta_data[ $array_key ] = clone $meta;
			if ( ! empty( $meta->id ) ) {
				$this->meta_data[ $array_key ]->id = null;
			}
		}
	}
}