0

I have received a tracking pixel from one of our advertising company, and they asked me to place that code in my order confirmation page.

first of all can some one tell me where is the order confirmation file located in magento?

And 2nd if i need to get "order ID" value and "Amount" of the order then what to use in this pixel.

<img src="https://www.emjcd.com/u?AMOUNT=AMOUNT&CID=7777777&OID=OID&TYPE=5555555&CURRENCY=GBP&METHOD=IMG" height="1" width="20"/> 

you can get more information here: http://www.pricerunner.co.uk/about/sales-tracking-instructions.html

3 Answers 3

2

You will need to copy your base template file from

app/design/frontend/base/default/template/checkout/success.phtml

To your ultimo theme path

app/design/frontend/ultimo/default/template/checkout

You can put below code in your success.phtml file

<?php    
    $order_id = Mage::getSingleton('checkout/session')->getLastRealOrderId();
    $order = Mage::getModel('sales/order')->loadByIncrementId($order_id);
    $grandTotal = $order->getGrandTotal();
    $orderCurrency = $order->getOrderCurrencyCode();
?>

<img src="https://www.emjcd.com/u?AMOUNT=<?php echo $grandTotal; ?>&CID=7777777&OID='<?php echo $order_id;?>'&TYPE=5555555&CURRENCY=<?php echo $orderCurrency; ?>&METHOD=IMG" height="1" width="20"/>        
12
  • Hi @akhilesh thanks for your help but "we need to alter the <AMOUNT> and <OID> (highlighted below) to pull in this information from your site. So you'll need to find out which macros create this information and then enter them here."
    – shafiq
    Oct 8, 2015 at 11:39
  • did you tried this code? It didn't work for you? I think it will do same as mention in your url pricerunner.co.uk/about/sales-tracking-instructions.html Oct 8, 2015 at 11:57
  • i have tried this code but i cant see this in my success page html, when placed order on front end.
    – shafiq
    Oct 8, 2015 at 12:08
  • did you clear your magento cache after changing the file? Oct 8, 2015 at 12:12
  • also enabled your template path hints and place order so you will get idea if your success.phtml file path is correct and it is not calling from somewhere else. Oct 8, 2015 at 12:16
4

If you're using the rwd theme, it's in /app/design/frontend/rwd/default/template/checkout/success.phtml

The order object isn't present on the confirmation page - it's already unloaded by this stage. So you could write a module to hook into the order save function, but if you need a quick fix you could load the last order id using something like (in success.phtml):

$lastOrderId = Mage::getSingleton('checkout/session')->getLastOrderId();
$order = Mage::getSingleton('sales/order'); 
$order->load($lastOrderId);
$_totalData =$order->getData(); 
$_sub = $_totalData['subtotal'];
3
  • hi, thanks for your help, but how to use this code togather with above one?
    – shafiq
    Oct 8, 2015 at 11:01
  • i am using ultimo, but i cant find success.phtml any where in my theme.
    – shafiq
    Oct 8, 2015 at 11:05
  • Hi, you need to find /app/design/frontend/base/default/teamplte/checkout/success.phtml and copy to your ultimo theme path, as mention below in Akhilesh's answer. You can do print_r($order) to view the order array (but this may be large) Oct 8, 2015 at 11:58
0

Magento v2.1.x

Here's all what you need with some extra values as well

<?php
$merchantid = "<ID>";

$objectManager  =  \Magento\Framework\App\ObjectManager::getInstance();
$orderId        = $block->getOrderId();
$order          = $objectManager
                    ->create('Magento\Sales\Model\Order')
                    ->loadByIncrementId($orderId);
$subtotal       = $order->getSubtotal();
$discount       = $order->getDiscountAmount(); 
$affiliateTotal = ($subtotal + $discount);

$ordered_items = $order->getAllVisibleItems();
$skulist = '';
$pricelist = '';
$quantitylist = '';

$last_index = array_search(end($ordered_items), $ordered_items, true);
foreach($ordered_items as $index => $item){
    $delimiter    = $index === $last_index ? '' : ',';
    $skulist      .= $item->getSku() . $delimiter;
    $quantitylist .= ceil($item->getQtyOrdered()) . $delimiter;
    $pricelist    .= ($item->getProduct()->getFinalPrice() - ($item->getDiscountAmount() / $item->getQtyOrdered())) . $delimiter;
}
$couponcodes = $order->getCouponCode();

$currency = $order->getOrderCurrencyCode();
//render pixel below
?>
<img src="https://www.emjcd.com/u?tracking=<?php echo $orderId ?>&amp;amount=<?php echo $affiliateTotal ?>&amp;transtype=sale&amp;merchantID=<?php echo $merchantid ?>&amp;couponcode=<?php echo $couponcodes ?>&amp;skulist=<?php echo $skulist ?>&amp;quantitylist=<?php echo $quantitylist ?>&amp;pricelist=<?php echo $pricelist ?>&amp;currency=<?php echo $currency ?>&amp;v=2.0" width="1" height="1">

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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