<?php $get_hash = $this->get_localstorage_hash( 'tiktok' ) . '_' . ( isset( $id ) ? $id : '' ); ?>
var wffnTIKTOKHash = '<?php echo esc_js( $get_hash ); ?>';
var wffnTIKTOKResult = false;
try {

if ('1' === localStorage.getItem("wffnH_" + wffnTIKTOKHash)) {
wffnTIKTOKResult = true;
}

} catch (exception) {

}

if(false === wffnTIKTOKResult) {
<?php
if ( is_array( $data ) && isset( $data['tiktok'] ) && ( true === $purchase ) ) {
	if ( isset( $data['tiktok']['advanced'] ) ) {
		unset( $data['tiktok']['advanced'] );
	}
	?>
    var wffnTikTokPurchaseData = JSON.parse('<?php echo wp_json_encode( $data['tiktok'] ); ?>');

    wffnTikTokPurchaseData = (typeof wffnAddTrafficParamsToEvent !== "undefined")?wffnAddTrafficParamsToEvent(wffnTikTokPurchaseData):wffnTikTokPurchaseData;
	<?php if ( true === $purchase ) { ?>
        ttq.instance('<?php echo esc_js( $id ); ?>').track('Purchase',wffnTikTokPurchaseData);
	<?php } ?>



	<?php
}

?>
try {

localStorage.setItem("wffnH_" + wffnTIKTOKHash, "1");

} catch (exception) {

}
}
