Automattic\WooCommerce\Admin\Features\Fulfillments

Fulfillment::get_changespublicWC 10.7.0

Return data changes including meta-based field changes.

Core data props are tracked by set_prop(); meta-based fields are detected by comparing current meta values against the snapshot taken on read.

Method of the class: Fulfillment{}

No Hooks.

Returns

Array.

Usage

$Fulfillment = new Fulfillment();
$Fulfillment->get_changes(): array;

Changelog

Since 10.7.0 Introduced.

Fulfillment::get_changes() code WC 10.7.0

public function get_changes(): array {
	$changes = parent::get_changes();

	$current_meta = array();
	foreach ( $this->get_meta_data() as $meta ) {
		$current_meta[ $meta->key ] = $meta->value;
	}

	$meta_changes = array();

	// Detect changed or added meta.
	foreach ( $current_meta as $key => $value ) {
		if ( ! array_key_exists( $key, $this->meta_snapshot ) || $this->meta_snapshot[ $key ] !== $value ) {
			$meta_changes[ $key ] = $value;
		}
	}

	// Detect deleted meta.
	foreach ( $this->meta_snapshot as $key => $value ) {
		if ( ! array_key_exists( $key, $current_meta ) ) {
			$meta_changes[ $key ] = null;
		}
	}

	if ( ! empty( $meta_changes ) ) {
		$changes['meta_data'] = $meta_changes;
	}

	return $changes;
}