Automattic\WooCommerce\Internal\EmailEditor\WCTransactionalEmails

WCEmailTemplateSyncTracker::record_update_availablepublic staticWC 10.9.0

Record _update_available for a post that just transitioned into core_updated_customized at a newer template_version_to than was last stamped on the post.

Callers must already have confirmed that the new status is core_updated_customized and that the version-meta advance has happened (or is about to). This method only owns the suppress-during-backfill check and the per-(post_id, template_version_to) dedup transient.

Метод класса: WCEmailTemplateSyncTracker{}

Хуков нет.

Возвращает

null. Ничего (null).

Использование

$result = WCEmailTemplateSyncTracker::record_update_available( $post_id ): void;
$post_id(int) (обязательный)
The woo_email post that just became eligible.

Список изменений

С версии 10.9.0 Введена.

Код WCEmailTemplateSyncTracker::record_update_available() WC 10.9.1

public static function record_update_available( int $post_id ): void {
	if ( self::should_suppress() ) {
		return;
	}

	$payload = self::build_base_payload( $post_id );
	if ( null === $payload ) {
		return;
	}

	$version_to = (string) $payload['template_version_to'];
	if ( '' === $version_to ) {
		return;
	}

	$transient_key = self::available_dedup_transient_key( $post_id, $version_to );
	if ( false !== get_transient( $transient_key ) ) {
		return;
	}

	self::record( self::EVENT_UPDATE_AVAILABLE, $payload );

	// Set the dedup transient after the record() call. record() swallows
	// throws from the Tracks pipeline in production, so in steady state
	// either ordering would dedup identically. The post-record ordering is
	// intentional for the testing path: when set_event_recorder() injects a
	// throwing spy, the transient stays unwritten and a retry remains
	// possible without manually clearing it. 30-day TTL outlasts the gap
	// between core releases without leaving stale dedup keys forever.
	set_transient( $transient_key, 1, MONTH_IN_SECONDS );
}