Keepsake Posted April 19, 2019 Share Posted April 19, 2019 Hi guys I'm on 1.6.0.14 and I've integrated ShareASale's current tracking pixel - the one that requires a cookie, explained at http://shareasale.com/itp/custom.htm#_Mastertag_Installation_Instructions Here's how - and again it's a mix of own code and code from Vekia and others from several threads on here back from 2013. First, to do the cookie, paste this in header.tpl for your template - notice how it's all wrapped in LITERAL clauses otherwise you get http 500. <!-- ShareASale - wrapped in literal because otherwise Smarty fails --> {literal} <script> var shareasaleSSCID=shareasaleGetParameterByName("sscid"); function shareasaleSetCookie(e,a,r,s,t){if(e&&a){var o,n=s?"; path="+s:"",i=t?"; domain="+t:"",l="";r&&((o=new Date).setTime(o.getTime()+r),l="; expires="+o.toUTCString()),document.cookie=e+"="+a+l+n+i}} function shareasaleGetParameterByName(e,a){a||(a=window.location.href),e=e.replace(/[\[\]]/g,"\\$&");var r=new RegExp("[?&]"+e+"(=([^&#]*)|&|#|$)").exec(a);return r?r[2]?decodeURIComponent(r[2].replace(/\+/g," ")):"":null} shareasaleSSCID&&shareasaleSetCookie("shareasaleSSCID",shareasaleSSCID,94670778e4,"/"); </script> {/literal} Then, using approach from the forums, I added extra variable to /controllers/front/OrderConfirmationController.php $order = new Order($this->id_order); $cart = new Cart($order->id_cart); $this->context->smarty->assign(array( 'products_total'=>$order->total_products, )); $this->setTemplate(_PS_THEME_DIR_.'order-confirmation.tpl'); Replace the last row (setTemplate) with the 6 rows including the last one. There are samples in the historical threads as how to get more variables - I only needed the order total without tax. Then in order-confirmation.tpl add the following to the end: <img id="_SHRSL_img_1" src="https://www.shareasale.com/sale.cfm?tracking={Tools::getvalue('id_order')}&amount={$products_total}&merchantID=XXXX&transtype=sale&sscidmode=6&sscid={$smarty.cookies.shareasaleSSCID}" width="1" height="1"> <script defer async type="text/javascript" src="https://shareasale-analytics.com/j.js"></script> Make sure to change your merchantID to the correct one. Hope that helps you guys - took a chunk out of my day to figure it out since I never did Presta/Smarty programming before. Have a great day, Mike RedlineGoods.com Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now