Last active
May 23, 2019 08:56
-
-
Save Steveb-p/f881bf33f029751fd342efd5f1544c14 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function tracking_js() | |
{ | |
$apiSettings = get_option('module_settings_option'); | |
$apiKey = $apiSettings['tracking_api_key']; | |
$tc_dont_show = (isset($_SESSION['tc_dont_show']) && $_SESSION['tc_dont_show']) == 1 ? 1 : 0; | |
$xtroScript = "<script type='text/javascript'> | |
(function(i,n,t,r,e,d,o){ | |
i['IntredoAnalyticsObject'] = e; i[e] = i[e] || function(){ (i[e].q=i[e].q||[]).push(arguments) | |
}; d = n.createElement(t),o = n.getElementsByTagName(t)[0]; | |
d.async = 1;d.src = r;o.parentNode.insertBefore(d,o); | |
})(window,document,'script','//xtro24.com/analytics.js','xtro'); | |
xtro('create', '{$apiKey}', {get_values: {Priority: " . $tc_dont_show . "}, handler_class: 'xtroDetails'}); | |
</script>"; | |
if (isset($_SESSION['sale-set']['page-type']) && $_SESSION['sale-set']['page-type'] !== 'confirm') { | |
echo $xtroScript; | |
return; | |
} | |
if (empty($_SESSION['sale-set']['response']['order_no'])) { | |
return; | |
} | |
if (isset($_SESSION['sale-set']['delivery-identyficator'])) { | |
return; | |
} | |
echo $xtroScript; | |
$_SESSION['sale-set']['delivery-identyficator'] = $_SESSION['sale-set']['response']['order_no']; | |
} | |
// Add hook for front-end <head></head> | |
add_action('wp_head', 'tracking_js'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment