Getting Order Id # On Order Landing Page?

Hello.

On my order landing page (CS-Cart 2.2.5), I am using Shopper Approved Ratings code which just puts a popup on the thank you for your order and just asks to rate their experience shopping. There is now an option with the Shopper Approved code that I can automatically pass some information to the rating such as Order #, Name, and email.



Here is the sample Shopper Approved code:

<script type="text/javascript"> var sa_values = { 'site':xxxx, 'orderid':'ORDER123', 'name':'John Doe', 'email':'john.doe@gmail.com' }; function saLoadScript(src) { var js = window.document.createElement('script'); js.src = src; js.type = 'text/javascript'; document.getElementsByTagName("head")[0].appendChild(js); } var d = new Date(); if (d.getTime() - 172800000 > 1398344779000) saLoadScript('//www.shopperapproved.com/thankyou/rate/2592.js'); else saLoadScript('//direct.shopperapproved.com/thankyou/rate/xxxx.js?d=' + d.getTime()); </script>
```<br />
<br />
On the order landing page, do these variables exist already or would it require extra programming to do something like look at the last order just successfully placed and pull that information from the database?<br />
<br />
Thank you for any input! <img src="upload://rA9Qa8gnUPZzRZRdI8kt3dpjkrs.png" class="bbc_emoticon" alt=":)"><br />
<br />
-Tim

Hello Tim Hensel,



You can use the {$order_info} variable. For example in this way:


```php


```



Hope it will be helpful.

[quote name=‘eComLabs’ timestamp=‘1398351300’ post=‘182282’]

Hello Tim Hensel,



You can use the {$order_info} variable. For example in this way:


<br />
<script type="text/javascript"> var sa_values = { 'site':xxxx, 'orderid':'{$order_info.order_id}', 'name':'{$order_info.firstname} {$order_info.lastname}', 'email':'{$order_info.email}' }; {literal}function saLoadScript(src) { var js = window.document.createElement('script'); js.src = src; js.type = 'text/javascript'; document.getElementsByTagName("head")[0].appendChild(js); } var d = new Date(); if (d.getTime() - 172800000 > 1398344779000) saLoadScript('//www.shopperapproved.com/thankyou/rate/2592.js'); else saLoadScript('//direct.shopperapproved.com/thankyou/rate/xxxx.js?d=' + d.getTime());{/literal} </script><br />

```<br />
<br />
Hope it will be helpful.<br />
[/quote]<br />
<br />
Thank you eComLabs!<br />
<br />
Unfortunately it does not seem to work. It only passed through the variable but not the actual data.<br />
So looking at the feedback left in the Shopper Approved system, the Order ID was transferred as '{$order_info.order_id}'....and the same with the name and email.<br />
<br />
Could it be being 2.25 CS-Cart that there are no variables once the order is completed and the customer goes to the thank you/order landing page?<br />
<br />
Again thank you very much for the help! <img src="upload://rA9Qa8gnUPZzRZRdI8kt3dpjkrs.png" class="bbc_emoticon" alt=":)">

You probably have the JS enclosed in '{literal}' tags that is preventing the smarty engine from expanding the variable. Alternatively you can replace '{' characters with '{ldelim}' and '}' characters with {rdelim} or reposition your '{literal}' tags…

@Tim Hensel,



tbirnseth is right. Try to add the following code:

```php



```

Thanks.

Thank you for the help! :)



tbirnseth - I tried using the {ldelim} and {ldelim} smarty tags as you suggested but it still would just transfer $order_info.order_id instead of the actual order ID #. :(



eComLabs - I tried this too as you have shown with the literal tags moved but this time the Shopper Approved popup never appeared. :(



For the actual Shopper Approved code/script, I just have this code in its own HTML BLOCK on the order landing page. Could this be why none of the suggestions are working? Should I try pasting the code somewhere else like maybe in the language file?



Thanks guys!!!

[quote name=‘Tim Hensel’ timestamp=‘1398516138’ post=‘182409’]

Thank you for the help! :)



tbirnseth - I tried using the {ldelim} and {ldelim} smarty tags as you suggested but it still would just transfer $order_info.order_id instead of the actual order ID #. :(



eComLabs - I tried this too as you have shown with the literal tags moved but this time the Shopper Approved popup never appeared. :(



For the actual Shopper Approved code/script, I just have this code in its own HTML BLOCK on the order landing page. Could this be why none of the suggestions are working? Should I try pasting the code somewhere else like maybe in the language file?



Thanks guys!!!

[/quote]



Could you please provide us with the full content of the file?

Hi,

It is just a single line for code:





On my successful order landing page (CS-Cart 2.2.5), the script is placed in its own HTML BLOCK.

The code above is the same as what I am actually using, less the orderid, name, and email variables as I cannot seem to retrieve that data.

Hi Tim,


[quote]On my successful order landing page (CS-Cart 2.2.5), the script is placed in its own HTML BLOCK.

The code above is the same as what I am actually using, less the orderid, name, and email variables as I cannot seem to retrieve that data.[/quote]



You can use the following trick:

  1. In the “skins/[SKIN]/customer/views/checkout/complete.tpl” file or its hooks you can add 3 (or more) necessary HTML inputs:






NOTE: On this step it is necessary to create HTML input per every parameter passed to JS.

2. The JS code of your block you should wrap in:


$(document).ready(function(){
});


3. Now in your script you may get necessary attributes by one of the following commands:

document.getelementbyid("secret_order_id").value;
$("#secret_order_id").val();




I hope it helps.



Best regards, Sergei

Hi Tim,



This is what you need on order confirmation page ? :D







#add to file [color=#ff0000]skins/[SKIN_NAME]/customer/addons/my_changes/hooks/checkout/order_confirmation.post.tpl[/color]

<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/2592.js'); else saLoadScript('//direct.shopperapproved.com/thankyou/rate/xxxx.js?d=' + d.getTime());<br />
</script><br />
{/if}<br />

```<br />
<br />
# Clear Cache ex: [color=#ff0000]http://www.example.com/admin.php?cc[/color]<br />
<br />
I hope that helps,<br />
<br />
---<br />
Valentin<br />
[color=#808080][size=2]part of hungryweb.net[/size][/color]

You neglected to state that you were trying to use your code in an html block. Template variables are not available in html blocks. You need to use an html block with “smarty support” if you want to include it in a block. Be much easier to just use the hook as described above (but I wouldn't use the input fields, I'd just use the template variables as we described).

[quote name='tbirnseth' timestamp='1398722210' post='182560']

You neglected to state that you were trying to use your code in an html block. Template variables are not available in html blocks. You need to use an html block with “smarty support” if you want to include it in a block. Be much easier to just use the hook as described above (but I wouldn't use the input fields, I'd just use the template variables as we described).

[/quote]



Hi tbirnseth, I know this was the original desire but does not need to be inserted into an html block and create everything complicated

If is any reason why this should be into an html block please Tim let me know



Regards,





Valentin

[color=#808080][size=2]part of hungryweb.net[/size][/color]

Hi All!

Thank you very much for some much help with my problem! :grin:

This weekend I will have a chance try this and I will post back again with the results.



-Tim

@Vali - I wasn't suggesting that he put it in an html block but identifying that the reason the template variables were not being expanded was because he was using an html block.

Yes, @tbirnseth you are right

[quote name=‘Vali’ timestamp=‘1398696632’ post=‘182532’]

Hi Tim,



This is what you need on order confirmation page ? :D







#add to file [color=#ff0000]skins/[SKIN_NAME]/customer/addons/my_changes/hooks/checkout/order_confirmation.post.tpl[/color]

<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/2592.js'); else saLoadScript('//direct.shopperapproved.com/thankyou/rate/xxxx.js?d=' + d.getTime());<br />
</script><br />
{/if}<br />

```<br />
<br />
# Clear Cache ex: [color=#ff0000][url="http://www.example.com/admin.php?cc"]http://www.example.com/admin.php?cc[/url][/color]<br />
<br />
I hope that helps,<br />
<br />
---<br />
Valentin<br />
[color=#808080][size=2]part of hungryweb.net[/size][/color]<br />
[/quote]<br />
<br />
Hi Valentin,<br />
I attempted to try this but in my store (2.2.5) I do not have this file:<br />
<br />
#add to file [color=#FF0000]skins/[SKIN_NAME]/customer/addons/my_changes/hooks/checkout/order_confirmation.post.tpl[/color]<br />
<br />
The only file I have under the [color=#FF0000]skins/[SKIN_NAME]/customer/addons/my_changes/hooks/checkout/ [/color]is: order_confirmation.override.tpl<br />
This file is just the Google Analytics Code for order tracking.<br />
<br />
Could I just add the order_confirmation.post.tpl file in this directory with the Shopper Approved code ... or would the order_confirmation.override.tpl file 'override' anything else in this directory?<br />
<br />
Originally I just had the basic code in an HTML BLOCK, but it just provides limited or no information about the customer that left the review. And it was very easy to do with placing right into an HTML BLOCK directly through CS-Cart (this is the only reason why I placed the code here). But I did not know the limitations of the HTML BLOCK and not being able to see the variables. This is why I am hoping to be able to use the extra features like automatically adding on the order # to the review to better handle them (if any action is required).<br />
<br />
Thank you to everyone again! <img src="upload://rA9Qa8gnUPZzRZRdI8kt3dpjkrs.png" class="bbc_emoticon" alt=":)"><br />
<br />
<br />
-Tim

Hi Tom,

You need to:

#create directory structure (if not exists)
skins/[SKIN_NAME]/customer/addons/my_changes/hooks/checkout/


#create the file


order_confirmation.post.tpl




Regards,





Valentin

[color=#808080][size=2]part of hungryweb.net[/size][/color]

[quote name='Vali' timestamp='1399261425' post='182903']

Hi Tom,

You need to:

#create directory structure (if not exists)
skins/[SKIN_NAME]/customer/addons/my_changes/hooks/checkout/


#create the file


order_confirmation.post.tpl




Regards,





Valentin

[color=#808080][size=2]part of hungryweb.net[/size][/color]

[/quote]



Are you sure that the .post file will correctly work with the .override one?

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 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]



We are totally agree with. And I am not sure, but as I remember if .post and .override files are used, the first one will be ignored.