Jump to content

Affiliation PHP/Java Code


decard1979

Recommended Posts

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

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

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

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

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

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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...