decard1979 Posted November 13, 2013 Share Posted November 13, 2013 Hello I have to put two different codes from affiliate company into clients prestashop. First tracking code should be included into product pages. Second should be included in order confirmation page. Knowing that i cannot insert php/java into tpl files, any idea in what files should i put those codes? Cheers Rafal Link to comment Share on other sites More sharing options...
bellini13 Posted November 13, 2013 Share Posted November 13, 2013 why don't you provide the code they gave you. I'm sure we can convert it to smarty equivalent. Another option would be to create a module which hooks productFooter and orderConfirmation, then the module would include the content. This would save you on upgrades and theme changes in the future. Link to comment Share on other sites More sharing options...
decard1979 Posted November 13, 2013 Author Share Posted November 13, 2013 Hello Code for products: <script type="text/javascript"> (function(abpid, abpcid) { var a4bstag = document.createElement('script'); a4bstag.type = "text/javascript"; a4bstag.async = true; a4bstag.src = 'https://www.a4b-tracking.com/pl/aff/'+abpid+'/'+abpcid; document.getElementsByTagName("head")[0].appendChild(a4bstag); })('<?php echo $_GET['abpid']; ?>', '<?php echo $_GET['abpcid']; ?>'); </script> Code for product confirmation: <script type="text/javascript"> (function(tid, aid) { var a4bstag = document.createElement('script'); a4bstag.type = "text/javascript"; a4bstag.async = true; a4bstag.src = 'https://www.a4b-tracking.com/pl/trans/1/'+tid+'/'+aid; document.getElementsByTagName("head")[0].appendChild(a4bstag); })('your-transaction-id', 'your-transaction-amount'); </script> Link to comment Share on other sites More sharing options...
vekia Posted November 13, 2013 Share Posted November 13, 2013 what is abpid and abcid ? Link to comment Share on other sites More sharing options...
decard1979 Posted November 13, 2013 Author Share Posted November 13, 2013 Those parameters are used by affiliate company. Those lines are designed to add for example this: "?abpid=11&abpcid=12" to product page/link. Link to comment Share on other sites More sharing options...
ExpressTech Posted November 13, 2013 Share Posted November 13, 2013 Try using smarty in place of PHP - {$smarty.get.abpid} and {$smarty.get.abpcid} Link to comment Share on other sites More sharing options...
sadlyblue Posted November 13, 2013 Share Posted November 13, 2013 Hello I have to put two different codes from affiliate company into clients prestashop. First tracking code should be included into product pages. Second should be included in order confirmation page. Knowing that i cannot insert php/java into tpl files, any idea in what files should i put those codes? Cheers Rafal why can't you insert a javascript in the tpl? from what i know, you can. you cant edit header.tpl in your theme, or use the hookHeader. Link to comment Share on other sites More sharing options...
ExpressTech Posted November 13, 2013 Share Posted November 13, 2013 To insert javascript in a tpl file : {literal}<script>..</script>{/literal} Link to comment Share on other sites More sharing options...
bellini13 Posted November 13, 2013 Share Posted November 13, 2013 the original topic said "JAVA" and "PHP". JAVA does not equal javascript. you can insert what you have directly into the template files and convert the usage of PHP to Smarty. If you changes themes/upgrade in the future, you will need to remember to re-add this. Better to create a module This is the altered product page {literal} <script type="text/javascript"> (function(abpid, abpcid) { var a4bstag = document.createElement('script'); a4bstag.type = "text/javascript"; a4bstag.async = true; a4bstag.src = 'https://www.a4b-tracking.com/pl/aff/'+abpid+'/'+abpcid; document.getElementsByTagName("head")[0].appendChild(a4bstag); }){/literal}('{$smarty.get.abpid}', '{$smarty.get.abpcid}');{literal} </script> {/literal} This is the altered order confirmation page. I assume your-transaction-id is order Id and your-transaction-amount is the total amount paid, but not sure on the format. {literal} <script type="text/javascript"> (function(tid, aid) { var a4bstag = document.createElement('script'); a4bstag.type = "text/javascript"; a4bstag.async = true; a4bstag.src = 'https://www.a4b-trac...com/pl/trans/1/'+tid+'/'+aid; document.getElementsByTagName("head")[0].appendChild(a4bstag); }){/literal}('{$id_order}', '{displayWtPriceWithCurrency price=$order->total_paid currency=$currencyObj}');{literal} </script> {/literal} Link to comment Share on other sites More sharing options...
vekia Posted November 13, 2013 Share Posted November 13, 2013 php code in new prestashop 1.5.x (in smarty templates) doesn't work. so it's better to use variables mentioned by vikas above {$smarty.get.abpid} and {$smarty.get.abpcid} Link to comment Share on other sites More sharing options...
decard1979 Posted November 13, 2013 Author Share Posted November 13, 2013 Thank u everyone for your replies. We gonna try that tommorow. I'll let know how that worked out! Link to comment Share on other sites More sharing options...
decard1979 Posted November 14, 2013 Author Share Posted November 14, 2013 Hello again Thank u very much for support. I inserted codes in tpl without problem (product and order confirmation). There are visibile in generated page code. Now there is only one, i believe, small glitch. {/literal}('{$id_order}', '{displayWtPriceWithCurrency price=$order->total_paid currency=$currencyObj}');{literal} That line doesnt show number of order and total price (better for us would be not total, but price without delivery), only empty spaces, example here: https://www.dropbox.com/s/27usar4v4apnzou/script.PNG Link to comment Share on other sites More sharing options...
vekia Posted November 14, 2013 Share Posted November 14, 2013 it looks like variables $id_order and {displayWtPriceWithCurrency price=$order->total_paid currency=$currencyObj} aren't defined. where you tested this code? on what page? order confirmation? or just somewhere else? Link to comment Share on other sites More sharing options...
bellini13 Posted November 14, 2013 Share Posted November 14, 2013 $id_order, $order and $currencyObj are defined in the OrderConfirmationController.php. Since the version of Prestashop was not stated, PS v1.5 was assumed Link to comment Share on other sites More sharing options...
vekia Posted November 14, 2013 Share Posted November 14, 2013 i suppose that decard1979 test it just on homepage or somewhere else, not in order confirmation page Link to comment Share on other sites More sharing options...
decard1979 Posted November 15, 2013 Author Share Posted November 15, 2013 Presta 1.5 First code went to product.tpl Second code with Id and price variable went into order-confirmation.tpl Will check OrderConfirmationController.php for configuration as Bellini13 mentioned Link to comment Share on other sites More sharing options...
bellini13 Posted November 15, 2013 Share Posted November 15, 2013 provide the version of Prestashop Link to comment Share on other sites More sharing options...
decard1979 Posted November 15, 2013 Author Share Posted November 15, 2013 PrestaShop: 1.5.6.0 Link to comment Share on other sites More sharing options...
bellini13 Posted November 15, 2013 Share Posted November 15, 2013 You will need to edit the OrderConfirmationController to make the required fields available to the smarty template. 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