Getting Order Id # On Order Landing Page?

When an override is encountered, any existing .post content is thrown away. However, I do believe that if the override contains the same hook that they will be reprocessed (but I'm not sure). But generally, ovrerrides should not be used.

[quote name=‘tbirnseth’ timestamp=‘1399270294’ post=‘182916’]

shouldn’t use an ‘override’ for any of the order_confirmation hooks. You should never use an override hook unless you absolutely need to replace the existing content and are willing to throw away an other addon pre or post templates.

[/quote]



Hi Tbirnseth,

This is how I started using the override file for the Google Analytics Code.

It works great for the tracking with Google on the order confirmation…but this should have been done differently since it will interfere with trying to use this file ‘order_confirmation.post.tpl’ in the same directory? :-(



-Tim

Tim, just change it to a post and you'll have fewer issues in the end. You can always add to the hook foot your needs. Not a requirement (especially for this hook), more about best practices.

Would it be possible to safely combine the Google Tracking with the Shopper Approved code in the same post file? Then once that post file exists then just remove the original override file.



Creating the post file: [color=#FF0000][font=arial, verdana, tahoma, sans-serif]skins/[SKIN_NAME]/customer/addons/my_changes/hooks/checkout/order_confirmation.post.tpl[/font][/color]



And placing both javascripts into the single post file?




<br />
<!-- Shopper Approved Successful Order Code --><br />
{if $order_info}<br />
<script type="text/javascript"><br />
var sa_values = {$ldelim}<br />
		  'site': '{$config.http_host}',<br />
		  'orderid': {$order_info.order_id},<br />
		  'name': '{$order_info.firstname} {$order_info.lastname}',<br />
		  'email': '{$order_info.email}'<br />
				{$rdelim};<br />
function saLoadScript(src) {$ldelim} var js = window.document.createElement('script'); js.src = src; js.type = 'text/javascript'; document.getElementsByTagName("head")[0].appendChild(js); {$rdelim} var d = new Date(); if (d.getTime() - 172800000 > 1398344779000) saLoadScript('//www.shopperapproved.com/thankyou/rate/xxxx.js'); else saLoadScript('//direct.shopperapproved.com/thankyou/rate/xxxx.js?d=' + d.getTime());<br />
</script><br />
{/if}<br />
<br />
<!-- Google Code for Sales Conversion Page --><br />
<script type="text/javascript"><br />
/* <![CDATA[ */<br />
var google_conversion_id = 123456789;<br />
var google_conversion_language = "en";<br />
var google_conversion_format = "3";<br />
var google_conversion_color = "ffffff";<br />
var google_conversion_label = "HOHFCKboxQQQxMSL_gM";<br />
var google_conversion_value = 0;<br />
/* ]]> */<br />
</script><br />
<script type="text/javascript" src="//www.googleadservices.com/pagead/conversion.js"><br />
</script><br />
<noscript><br />
<div style="display:inline;"><br />
<img height="1" width="1" style="border-style:none;" alt="" src="upload://ux1zSLp9vBY9KEUw7CSvZVrESee.gif"><br />
</div><br />
</noscript><br />

```<br />
<br />
<br />
Thanks!

[quote name=‘Tim Hensel’ timestamp=‘1399426959’ post=‘183049’]

Would it be possible to safely combine the Google Tracking with the Shopper Approved code in the same post file? Then once that post file exists then just remove the original override file.



Creating the post file: [color=#FF0000][font=arial, verdana, tahoma, sans-serif]skins/[SKIN_NAME]/customer/addons/my_changes/hooks/checkout/order_confirmation.post.tpl[/font][/color]



And placing both javascripts into the single post file?




<br />
<!-- Shopper Approved Successful Order Code --><br />
{if $order_info}<br />
<script type="text/javascript"><br />
var sa_values = {$ldelim}<br />
		  'site': '{$config.http_host}',<br />
		  'orderid': {$order_info.order_id},<br />
		  'name': '{$order_info.firstname} {$order_info.lastname}',<br />
		  'email': '{$order_info.email}'<br />
				{$rdelim};<br />
function saLoadScript(src) {$ldelim} var js = window.document.createElement('script'); js.src = src; js.type = 'text/javascript'; document.getElementsByTagName("head")[0].appendChild(js); {$rdelim} var d = new Date(); if (d.getTime() - 172800000 > 1398344779000) saLoadScript('//www.shopperapproved.com/thankyou/rate/xxxx.js'); else saLoadScript('//direct.shopperapproved.com/thankyou/rate/xxxx.js?d=' + d.getTime());<br />
</script><br />
{/if}<br />
<br />
<!-- Google Code for Sales Conversion Page --><br />
<script type="text/javascript"><br />
/* <![CDATA[ */<br />
var google_conversion_id = 123456789;<br />
var google_conversion_language = "en";<br />
var google_conversion_format = "3";<br />
var google_conversion_color = "ffffff";<br />
var google_conversion_label = "HOHFCKboxQQQxMSL_gM";<br />
var google_conversion_value = 0;<br />
/* ]]> */<br />
</script><br />
<script type="text/javascript" src="//www.googleadservices.com/pagead/conversion.js"><br />
</script><br />
<noscript><br />
<div style="display:inline;"><br />
<img height="1" width="1" style="border-style:none;" alt="" src="upload://ux1zSLp9vBY9KEUw7CSvZVrESee.gif"><br />
</div><br />
</noscript><br />

```<br />
<br />
<br />
Thanks!<br />
[/quote]<br />
<br />
You can add unlimited amout of scripts to the .post tpl file. The override is not necessary in this case.

Best to also do two things…

  1. Use the 'async' attribute to the script tag like:

```php


```



This should ensure that the scripts do NOT execute until after the page fully loads and that they will complete even if the user quickly leaves the page. You can probably get by without the async but it won't hurt anything.