Skip to content

Instantly share code, notes, and snippets.

@nickwanhere
Created November 7, 2014 14:27
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nickwanhere/b31f8c6ad4998c0e1a39 to your computer and use it in GitHub Desktop.
Save nickwanhere/b31f8c6ad4998c0e1a39 to your computer and use it in GitHub Desktop.
Magento Pepperjam Network Code
<?php
/*********Start Pepperjam Network Codes #1 ******/
$lastOrderId = Mage::getSingleton('checkout/session')->getLastOrderId();
$order = Mage::getSingleton('sales/order');
$order->load($lastOrderId);
$_totalData = $order->getData();
$_currency = $_totalData['order_currency_code'];
$_productData = $order->getAllItems();
$pixelDataItem = '';
$pixelDataQty = '';
$pixelDataAmount = '';
$i = 1;
foreach ($_productData as $item){
if ($item->getProductType() == 'configurable') continue;
if ($item->getParentItemId()) {
$_total = number_format($item->getParentItem()->getPrice(),2);
$_discount = number_format(($item->getParentItem()->getDiscountAmount() / $item->getParentItem()->getQtyOrdered()),2);
} else {
$_total = number_format($item->getPrice(),2);
$_discount = number_format(($item->getDiscountAmount() / $item->getQtyOrdered()),2);
}
$pixelDataItem .= '&ITEM;'.$i.'='.$item->getSku();
$pixelDataQty .= '&QTY;'.$i.'='.(int)$item->getQtyOrdered();
$pixelDataAmount .= '&AMOUNT;'.$i.'='.number_format($_total - $_discount,2);
$i++;
}
$pixelData = '<iframe src="https://t.pepperjamnetwork.com/track?';
$pixelData .="PID=XXXX";
$pixelData .="&INT;=ITEMIZED";
$pixelData .=$pixelDataItem.$pixelDataQty.$pixelDataAmount;
$pixelData .= '&OID;='.$this->getOrderId().'&CURRENCY;='.$_currency.'" width="1" height="1" frameborder="0"></iframe>';
echo $pixelData;
/*********End Pepperjam Network Codes ******/
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment