Google Affiliate Integration
January 11th, 2011
copy and paste to the bottom of
app/design/frontend/base/default/theme_name/template/checkout/success.phtml
getLastOrderId();
$_order = Mage::getModel(‘sales/order’)->load($lastorderid);
$orderID = $this->getOrderId(); #get the order ID
$aProduct = array();
$totalAmt = 0;
$prdsku = “”;
$prdnm = “”;
$prdqn = “”;
$prdpr = “”;
$prcatid = “”;
###########store order data in array of objects###########
foreach ($_order->getAllItems() as $item) {
$oProduct = new stdClass();
$oProduct->sku = $item->getSku(); #sku
$oProduct->price = $item->getPrice(); #price
$totalAmt = $totalAmt + ($oProduct->price * $item->getQtyOrdered()); #total amt (excl.tax/shipping)
$oProduct->qty = $item->getQtyOrdered(); #quantity
$oProduct->name = $item->getName(); #product name
$oProduct->category = $item->getProductId(); #ProductCatID
array_push($aProduct, $oProduct);
$oProduct = NULL; #nuke it
}
###########build query string variables###########
for ($i=0; $i < count($aProduct); $i++) { if ($i == count($aProduct)-1) { $prdsku .= urlencode($aProduct[$i]->sku);
$prdnm .= urlencode($aProduct[$i]->name);
$prdqn .= urlencode($aProduct[$i]->qty);
$prdpr .= urlencode($aProduct[$i]->price);
$prcatid .= urlencode($aProduct[$i]->category);
} else {
$prdsku .= urlencode($aProduct[$i]->sku) . “^”;
$prdnm .= urlencode($aProduct[$i]->name) . “^”;
$prdqn .= urlencode($aProduct[$i]->qty) . “^”;
$prdpr .= urlencode($aProduct[$i]->price) . “^”;
$prcatid .= urlencode($aProduct[$i]->category) .”^”;
}
}
?>
&amt=&prdsku=&prdqn=&prdpr=&prdcatid=&clickid=47999f0b3143dac1f2f35ff096c6b” width=”1″ height=”1″ style=”border:0px solid #F00;”>
getLastOrderId();$_order = Mage::getModel(‘sales/order’)->load($lastorderid);$orderID = $this->getOrderId(); #get the order ID$aProduct = array();$totalAmt = 0;$prdsku = “”;$prdnm = “”;$prdqn = “”;$prdpr = “”;$prcatid = “”;
###########store order data in array of objects###########foreach ($_order->getAllItems() as $item) { $oProduct = new stdClass(); $oProduct->sku = $item->getSku(); #sku $oProduct->price = $item->getPrice(); #price $totalAmt = $totalAmt + ($oProduct->price * $item->getQtyOrdered()); #total amt (excl.tax/shipping) $oProduct->qty = $item->getQtyOrdered(); #quantity $oProduct->name = $item->getName(); #product name $oProduct->category = $item->getProductId(); #ProductCatID array_push($aProduct, $oProduct); $oProduct = NULL; #nuke it}###########build query string variables###########for ($i=0; $i < count($aProduct); $i++) { if ($i == count($aProduct)-1) { $prdsku .= urlencode($aProduct[$i]->sku); $prdnm .= urlencode($aProduct[$i]->name); $prdqn .= urlencode($aProduct[$i]->qty); $prdpr .= urlencode($aProduct[$i]->price); $prcatid .= urlencode($aProduct[$i]->category); } else { $prdsku .= urlencode($aProduct[$i]->sku) . “^”; $prdnm .= urlencode($aProduct[$i]->name) . “^”; $prdqn .= urlencode($aProduct[$i]->qty) . “^”; $prdpr .= urlencode($aProduct[$i]->price) . “^”; $prcatid .= urlencode($aProduct[$i]->category) .”^”; }}?>
&amt=&prdsku=&prdqn=&prdpr=&prdcatid=&clickid=47999f0b3143dac1f2f35ff096c6b” width=”1″ height=”1″ style=”border:0px solid #F00;”>