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 03-05-2013 06:59 AM

Re: XCart removing code from script. How to get code on page?
 
Based on the same post,

I tried this (which I know is putting PHP inside of Javascript, but I'm unsure what else to do here...):

<!-- SpringMetrics Conversion Code for mattressinsider -->
<script type="text/javascript">
_springMetq.push(["setdata", {literal}{revenue: "{/literal}if (<? echo $order.total ?>) {<? echo $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}" }{/literal}]);
_springMetq.push(["convert", "sale" ]);
</script>
<!-- SpringMetrics Conversion Code for mattressinsider -->

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



I also tried this:

<!-- SpringMetrics Conversion Code for mattressinsider -->
<script type="text/javascript">
_springMetq.push(["setdata", {literal}{revenue: "{/literal}{<? echo $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}" }{/literal}]);
_springMetq.push(["convert", "sale" ]);
</script>
<!-- SpringMetrics Conversion Code for mattressinsider -->

Which output this:

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

andrewmattress 03-05-2013 07:09 AM

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

Originally Posted by carpeperdiem
Don't "try" - go get the actual variable. I gave you the link.


Where is the debug console? I changed smarty.php, and turned on Webmaster mode...

andrewmattress 03-05-2013 07:17 AM

Re: XCart removing code from script. How to get code on page?
 
I switched the code in smarty.php, but it's still showing templates, not variables, in the popup.

carpeperdiem 03-05-2013 07:27 AM

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

http://help.x-cart.com/index.php?title=X-Cart:Editing_Skin_Files#Using_Debugging_Console

You have to search the docs. 99% of the time, it's there for you!

andrewmattress 03-05-2013 07:50 AM

Re: XCart removing code from script. How to get code on page?
 
Okay... that was a stretch for me, but based on all the help offered in this post, as well as here:
http://forum.x-cart.com/showthread.php?t=44543

I was able to get the variables to display in debug mode.

Here are the relevant variables:

{$orderids}"12817"{$orders}Array (1)
0 => Array (4)
order => Array (77)
orderid => "12817"
login => "anonymous-13353"
membership => ""
total => "329.00"
giftcert_discount => "0.00"
giftcert_ids => ""
subtotal => "329.00"
discount => "0.00"
coupon => ""
coupon_discount => "0.00"
shippingid => "0"
tracking => ""
shipping_cost => "0.00"
tax => "0.00"
taxes_applied => "N;"
date => "1362493877"
status => "Q"
payment_method => "Phone Ordering"
email => "123testing@readingrainbow.com"

So I put in this code:

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

Which gives this output:

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

Finally the Order ID works. So I assume I'm close now.

How do I get the rest of the fields to work? The email field is at the same level in the tree as the other fields.

Thank-you!

andrewmattress 03-05-2013 07:56 AM

Re: XCart removing code from script. How to get code on page?
 
1 Attachment(s)
Shoot. The tree structure went away. Please see screenshot.

andrewmattress 03-05-2013 08:57 AM

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

YAY!!!

Thank-you SO much for your help.

Was a much longer process than anticipated, but good to go now!

Here is the XCart code for making Spring Metrics work with the version of XCart we are using.

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


All times are GMT -8. The time now is 06:17 PM.

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