WC_Data::set_clone_modepublicWC 10.4.0

Set the clone mode.

This controls how meta IDs are handled when the object is cloned:

  • CLONE_MODE_DUPLICATE (default): Clears meta IDs for duplication workflows
  • CLONE_MODE_CACHE: Preserves meta IDs for caching workflows

Method of the class: WC_Data{}

No Hooks.

Returns

null. Nothing (null).

Usage

$WC_Data = new WC_Data();
$WC_Data->set_clone_mode( $mode );
$mode(string) (required)
One of the CLONE_MODE_* constants.

Changelog

Since 10.4.0 Introduced.

WC_Data::set_clone_mode() code WC 10.8.1

public function set_clone_mode( $mode ) {
	if ( ! in_array( $mode, array( self::CLONE_MODE_DUPLICATE, self::CLONE_MODE_CACHE ), true ) ) {
		throw new InvalidArgumentException( 'Clone mode must be either WC_Data::CLONE_MODE_DUPLICATE or WC_Data::CLONE_MODE_CACHE' );
	}
	$this->clone_mode = $mode;
}