X-Cart: shopping cart software

X-Cart forums (https://forum.x-cart.com/index.php)
-   Changing design (https://forum.x-cart.com/forumdisplay.php?f=51)
-   -   XCart removing code from script. How to get code on page? (https://forum.x-cart.com/showthread.php?t=66240)

andrewmattress 02-27-2013 08:12 AM

XCart removing code from script. How to get code on page?
 
I would like to add code (below) to the <head>.

I've tried putting it directly into the page home.tpl. It shows in the template editor, but XCart removes part of the code when loading the page.

I've tried calling it as a separate .tpl (template) file into the page. Xcart removes part of the code when loading the page.

I've tried putting it into the common.js file. The code doesn't load.

I've tried building a new HTML page, pulling that HTML page into the template in a 1x1 iframe. The frame and code loads, but then doesn't do the tracking I want it to because it's loading in a frame.

No matter what I do, XCart is removing everything between

{
and
}

the code that I've highlighted in Dark Green below.

How do I get this full code to show up on the page inside of <head></head> and get XCart to leave it alone?

Thank-you!

Andrew
http://www.MattressInsider.com



Here is the full code (with our ID changed to X's):

<!-- Begin SpringMetrics -->

<script type='text/javascript'>
var _springMetq = _springMetq || [];
_springMetq.push(['id', 'XXXXXXXXXX']);
(
function(){
var s = document.createElement('script');
s.type = 'text/javascript';
s.async = true;
s.src = ('https:' == document.location.protocol ? 'https://d3rmnwi2tssrfx.cloudfront.net/a.js' : 'http://static.springmetrics.com/a.js');
var x = document.getElementsByTagName('script')[0];
x.parentNode.insertBefore(s, x);
}

)();
</script>
<!-- End SpringMetrics -->

gb2world 02-27-2013 11:20 AM

Re: XCart removing code from script. How to get code on page?
 
Probably this: http://help.x-cart.com/index.php?title=X-Cart:Customizing_storefront#JavaScript_in_template s

Javascript and smarty share syntax, so you have to let smarty know not to interpret the javascript.

---

pauldodman 02-28-2013 12:35 AM

Re: XCart removing code from script. How to get code on page?
 
Yes, just put {literal}tags{/literal} around your javascript code.

andrewmattress 03-04-2013 08:43 AM

Re: XCart removing code from script. How to get code on page?
 
Thanks very much for this help.

It works!

Further question...

I have a separate piece of code to track conversions. (This is for SpringMetrics.)

This code is tracking the conversion itself, but not passing the value of that conversion back.

Here are three pieces of code I've tried...

------------
OPTION 1
------------

<!-- SpringMetrics Conversion Code for mattressinsider -->
{literal}
<script type="text/javascript">
_springMetq.push(["setdata", {revenue: "{/literal}{$order.total}{literal}"}]);
_springMetq.push(["setdata", { "orderId": "{/literal}{$order.orderid}{literal}" }]);
_springMetq.push(["setdata", { "email": "{/literal}{$order.email}{literal}" }]);
_springMetq.push(["setdata", { "promoCode": "{/literal}{$order.coupon}{literal}" }]);
_springMetq.push(["convert", "sale" ]);
</script>
{/literal}
<!-- SpringMetrics Conversion Code for mattressinsider -->


------------
OPTION 2
------------

{literal}
<script type="text/javascript">
_springMetq.push(["setdata", {revenue: "{/literal}{$order.order.subtotal}{literal}"}]);
_springMetq.push(["setdata", { "orderId": "{/literal}{$order.orderid}{literal}" }]);
_springMetq.push(["setdata", { "email": "{/literal}{$order.email}{literal}" }]);
_springMetq.push(["setdata", { "promoCode": "{/literal}{$order.coupon}{literal}" }]);
_springMetq.push(["convert", "sale" ]);
</script>
{/literal}
<!-- SpringMetrics Conversion Code for mattressinsider -->



------------
OPTION 3
------------

<script type="text/javascript">{literal}
_springMetq.push(["setdata", {revenue: {/literal}"{$order.order.subtotal}"{literal}}]);
_springMetq.push(["convert", "sale" ]);
</script>

pauldodman 03-04-2013 08:53 AM

Re: XCart removing code from script. How to get code on page?
 
You've got loads of {literal} tags in the actual code itself - where did they come from???
They also seem to close then open as well!

Get rid of all those literal tags - you just need them before and after the <script>, as you have in #1 and #2 - but just without anything in between.

andrewmattress 03-04-2013 09:25 AM

Re: XCart removing code from script. How to get code on page?
 
I've tried that, but it doesn't actually put in the order value. So I thought I would have to turn on and off the {literal} in order to get it to know the difference between the Javascript and the Smarty tag.

What I've got on the site now is:

<!-- SpringMetrics Conversion Code for mattressinsider -->
{literal}
<script type="text/javascript">
_springMetq.push(["setdata", {revenue: "{$order.total}"}]);
_springMetq.push(["setdata", { "orderId": "{$order.orderid}" }]);
_springMetq.push(["setdata", { "email": "{$order.email}" }]);
_springMetq.push(["setdata", { "promoCode": "{$order.coupon}" }]);
_springMetq.push(["convert", "sale" ]);
</script>
{literal}
<!-- SpringMetrics Conversion Code for mattressinsider -->

Any other thoughts?

By the way, thanks so much for your help and your quick reply!

pauldodman 03-04-2013 09:31 AM

Re: XCart removing code from script. How to get code on page?
 
OK, yes, I see what you did now actually.
Are you getting any of the other values through?

andrewmattress 03-04-2013 09:33 AM

Re: XCart removing code from script. How to get code on page?
 
None of the values seem to be coming through. By the way, in the above code, the second {literal} is actually {/literal}

pauldodman 03-04-2013 09:34 AM

Re: XCart removing code from script. How to get code on page?
 
And is all the rest of the code in the right places and working ok?

pauldodman 03-04-2013 09:36 AM

Re: XCart removing code from script. How to get code on page?
 
And did any value come through at all with any of the code you tried?


All times are GMT -8. The time now is 07:41 AM.

Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.