Jump to content

Smarty IF statements & order currency ISO code


Big Spender

Recommended Posts

I am working on Facebook's conversion tracking code at the moment which is as below: -

<!-- Facebook Conversion Code for Checkout -->
<script>(function() {
var _fbq = window._fbq || (window._fbq = []);
if (!_fbq.loaded) {
var fbds = document.createElement('script');
fbds.async = true;
fbds.src = '//connect.facebook.net/en_US/fbds.js';
var s = document.getElementsByTagName('script')[0];
s.parentNode.insertBefore(fbds, s);
_fbq.loaded = true;
}
})();
window._fbq = window._fbq || [];
window._fbq.push(['track', '0000000000', {'value':'0.00','currency':'GBP'}]);
</script>
<noscript><img height="1" width="1" alt="" style="display:none" src="https://www.facebook.com/tr?ev=0000000000&amp;cd[value]=0.00&amp;cd[currency]=GBP&amp;noscript=1" /></noscript>

Firstly - is there smarty code for an if statement for the template of the page I want to add this too? As this code needs adding inside the head tags (which means I need to do it in the header) but only on the content.receipt.php page (I assume), CC's analytics conversion tracking is here so that seems the logical place but what has thrown me is that isn't this the same page also used in the order details via My Account and it would register a conversion if someone visited that too...?

 

Finally, I can send it the total order value using {$SUM.total} in the above, but you can also send it the currency via the ISO code, is there a hook for the currency ISO code for the order, I know there is {$currency.code} but I think that is just the currency code you have selected to browse the website not the one in use on the order.

Thanks,

Link to comment
Share on other sites

A stock skin (and third-party skins that follow protocol) will have a variable {$SECTION_NAME}. You can get a good idea of what the values of the variable may be by looking through CubeCart->loadPage() and also by looking at the skin's common.css file for the *_wrapper{} CSS rules.

 

However, CubeCart->_receipt() (having arrived from the catch-all default case at the bottom of CubeCart->loadPage()) does not assign a value to $SECTION_NAME, nor is there a CSS rule for this section. I'll file a bug report.

 

So, back in CubeCart->loadPage(), you can build a snippet to use the hook class.cubecart.construct (line 382) that tests for the value of $_GET['_a'] and if receipt, then assign a value to your custom variable in the <head> of your skin template.

 

Or, you can go ahead and modify CubeCart->_receipt() by adding a Smarty->assign('SECTION_NAME', 'receipt') statement. Then, in the main template, <head> section, add this:

{if $SECTION_NAME eq "receipt"}My New HTML{/if}

Link to comment
Share on other sites

To get an idea of what Smarty variables are available for a given template, content.receipt.php for example, at the bottom of the template code, add {debug}. (While doing this development, I suggest turning off the cache in admin, Store Settings, Advanced tab.)

 

You will discover exactly what key/values are in $SUM.

 

Because the content templates are rendered first, variables available in this template can be seen in the main.php template.

Link to comment
Share on other sites

Thanks for the information, much appreciated.

 

Looking at the debug info there is nothing for the currency of the order, only the default currency of the store.

 

Am I correct that the orders after checkout are converted to the master currency anyway? So therefore I should just use: default_currency => "GBP" for the purposes of the above?

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...