Automattic\WooCommerce\Internal\CLI\Migrator\Lib

ImportSession::bump_total_number_of_entitiespublicWC 1.0

Method of the class: ImportSession{}

No Hooks.

Returns

null. Nothing (null).

Usage

$ImportSession = new ImportSession();
$ImportSession->bump_total_number_of_entities( $newly_indexed_entities );
$newly_indexed_entities(required)
.

ImportSession::bump_total_number_of_entities() code WC 10.8.1

public function bump_total_number_of_entities( $newly_indexed_entities ) {
	foreach ( $newly_indexed_entities as $field => $count ) {
		if ( ! in_array( $field, static::PROGRESS_ENTITIES, true ) ) {
			_doing_it_wrong(
				__METHOD__,
				'Cannot set total number of entities for unknown entity type: ' . $field,
				'1.0.0'
			);
			continue;
		}

		// Get current total from cache or database
		if ( ! isset( $this->cached_totals[ $field ] ) ) {
			$this->cached_totals[ $field ] = (int) get_post_meta( $this->post_id, 'total_' . $field, true );
		}

		// Add new count to total
		$new_total = $this->cached_totals[ $field ] + $count;

		// Update database and cache
		update_post_meta( $this->post_id, 'total_' . $field, $new_total );
		$this->cached_totals[ $field ] = $new_total;
	}
}