i need to implement an affiliate code in the thank you page for every payment method (Paypal, Credit Card and COD) in my magento installation

This is the code and the fields that must be replaced are SALE_ID and 99.99. SALE_ID is the order id and 99.99 is the amount of sale without the shipping cost.

I have little knowledge of PHP, could you suggest me a solution?


<script type="text/javascript" src="https://go.affiliate.de/delivery/afl/afl.js"></script>
<script type="text/javascript">
Affiliate.load_action("11501", "SALE_ID", "1::99.99", "", "pending");
 <img src="https://go.affiliate.de/delivery/afl/afl.php?cam_id=11501&trans_id=SALE_ID&sale_amount=1::99.99&adv_subid=&status=pending" style="width:0px;height:0px;"/>

The fastest way is to hardcode it directly in the template - app/design/frontend/base/default/template/checkout/success.phtml. Below this line:

<?php if ($this->getOrderId()):?>

you can enter your script and you can get the ID and price by this code:

<?php $_order = Mage::getModel('sales/order')->loadByIncrementId($this->getOrderId()); ?>
<?php echo $this->getOrderId(); //this is increment id, i.e. 100000001 ?>
<?php echo $_order->getId(); //this is table id, i.e. 1 ?>
<?php echo $_order->getSubtotal(); ?>

Of course the better way is to make new module with layout update handle which will include this code in the header and will not overwrite the base template but for this you will need more time and knowledge.

  • I have succeed to implement this code and the right numbers are printed in the success page. The problem i have noticed is the affiliate javascript code is not rendered at all and i cannot see it in the source of the success page when i look on HTML. Am i doing something wrong? – girok Nov 26 '14 at 13:17
  • 1
    How did you try to see the HTML code? If you try with FireBug or something like that - you should see it. But if you try to choose View Page Source then you will see the HTML of the Shopping Cart (because it clears the session and redirects you to the Shopping Cart). Also please check if this is the right file because you can use another theme (show Path Hints in the admin panel -> System -> Configuration -> Advanced -> Developer -> Debug -> Template Path Hints : Yes). – michael Nov 26 '14 at 13:55
  • I was trying with View Page Source :( I checked with FireBug and now i see the code! Thanks for your help – girok Nov 26 '14 at 14:16

Not the answer you're looking for? Browse other questions tagged or ask your own question.