Follow us on Twitter X-Cart on Facebook Wiki
Shopping cart software Solutions for online shops and malls
 

XCart removing code from script. How to get code on page?

 
Reply
   X-Cart forums > X-Cart 4 > Dev Questions > Changing design
 
Thread Tools Search this Thread
  #1  
Old 02-27-2013, 08:12 AM
 
andrewmattress andrewmattress is offline
 

Advanced Member
  
Join Date: Feb 2013
Posts: 39
 

Default 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 -->
__________________
JK
X-Cart version 4.7
We have about lots of add-on modules.
Reply With Quote
  #2  
Old 02-27-2013, 11:20 AM
  gb2world's Avatar 
gb2world gb2world is offline
 

X-Wizard
  
Join Date: May 2006
Location: Austin, TX
Posts: 1,970
 

Default 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.

---
__________________
X-CART (4.1.9,12/4.2.2-3/4.3.1-2/4.4.1-5)-Gold
(CDSEO, Altered-Cart On Sale, BCSE Preorder Backorder, QuickOrder, X-Payments, BCSE DPM Module)
Reply With Quote

The following user thanks gb2world for this useful post:
andrewmattress (03-04-2013)
  #3  
Old 02-28-2013, 12:35 AM
  pauldodman's Avatar 
pauldodman pauldodman is online now
 

X-Guru
  
Join Date: Jul 2003
Location: Spain / UK
Posts: 3,054
 

Default Re: XCart removing code from script. How to get code on page?

Yes, just put {literal}tags{/literal} around your javascript code.
__________________
Paul Dodman
e-business & m-commerce consultant
w: www.luminointernet.com
e: xcart@luminointernet.com

Professional X-Cart help, advice, support and services, specialists in Mobile X-Cart.
Reply With Quote

The following user thanks pauldodman for this useful post:
andrewmattress (03-04-2013)
  #4  
Old 03-04-2013, 08:43 AM
 
andrewmattress andrewmattress is offline
 

Advanced Member
  
Join Date: Feb 2013
Posts: 39
 

Default 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>
__________________
JK
X-Cart version 4.7
We have about lots of add-on modules.
Reply With Quote
  #5  
Old 03-04-2013, 08:53 AM
  pauldodman's Avatar 
pauldodman pauldodman is online now
 

X-Guru
  
Join Date: Jul 2003
Location: Spain / UK
Posts: 3,054
 

Default 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.
__________________
Paul Dodman
e-business & m-commerce consultant
w: www.luminointernet.com
e: xcart@luminointernet.com

Professional X-Cart help, advice, support and services, specialists in Mobile X-Cart.
Reply With Quote
  #6  
Old 03-04-2013, 09:25 AM
 
andrewmattress andrewmattress is offline
 

Advanced Member
  
Join Date: Feb 2013
Posts: 39
 

Default 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!
__________________
JK
X-Cart version 4.7
We have about lots of add-on modules.
Reply With Quote
  #7  
Old 03-04-2013, 09:31 AM
  pauldodman's Avatar 
pauldodman pauldodman is online now
 

X-Guru
  
Join Date: Jul 2003
Location: Spain / UK
Posts: 3,054
 

Default 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?
__________________
Paul Dodman
e-business & m-commerce consultant
w: www.luminointernet.com
e: xcart@luminointernet.com

Professional X-Cart help, advice, support and services, specialists in Mobile X-Cart.
Reply With Quote
  #8  
Old 03-04-2013, 09:33 AM
 
andrewmattress andrewmattress is offline
 

Advanced Member
  
Join Date: Feb 2013
Posts: 39
 

Default 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}
__________________
JK
X-Cart version 4.7
We have about lots of add-on modules.
Reply With Quote
  #9  
Old 03-04-2013, 09:34 AM
  pauldodman's Avatar 
pauldodman pauldodman is online now
 

X-Guru
  
Join Date: Jul 2003
Location: Spain / UK
Posts: 3,054
 

Default 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?
__________________
Paul Dodman
e-business & m-commerce consultant
w: www.luminointernet.com
e: xcart@luminointernet.com

Professional X-Cart help, advice, support and services, specialists in Mobile X-Cart.
Reply With Quote
  #10  
Old 03-04-2013, 09:36 AM
  pauldodman's Avatar 
pauldodman pauldodman is online now
 

X-Guru
  
Join Date: Jul 2003
Location: Spain / UK
Posts: 3,054
 

Default 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?
__________________
Paul Dodman
e-business & m-commerce consultant
w: www.luminointernet.com
e: xcart@luminointernet.com

Professional X-Cart help, advice, support and services, specialists in Mobile X-Cart.
Reply With Quote
Reply
   X-Cart forums > X-Cart 4 > Dev Questions > Changing design



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -8. The time now is 07:11 PM.

   

 
X-Cart forums © 2001-2020