2

I need your help with my magento problem. I've got a tracking code for the success page to track orders. This is my tracking code:

<script language="javascript" type="text/javascript">
(function(){
var properties = {};
properties.billing_orderid      = 'PLEASE ADD A UNIQUE ORDER ID'; // this id must be unique otherwise we will count the conversion only once
properties.billing_address      = 'NULL'; // if needed
properties.billing_customerid   = 'NULL'; // if needed
properties.billing_sum          = 'ADD BASKET VALUE HERE, ONLY . SIGN ALLOWED';

// each line represents a product, please add neccassary line for each product and put the right values into it
properties.ec_Event=[
 // Syntax: Action, ProductID, Name, Price, Category, Number of Items, NULL, NULL, NULL
 // please avoid any ' sign in each value especially in the product name or make the right javascript quoting by using \' instead of single '
 ['buy' /* stay fix */ 'YOUR PRODUCT ID', 'PRODUCT NAME', 'PRICE', 'CATEGORY', NUMER OF ITEMS, 'NULL' /* stay fix */, 'NULL' /* stay fix */, 'NULL' /* stay fix */],
 ['buy', 'ABC123', 'Nike shoe ', '50.00', 'shoes/nike', 2,'NULL', 'NULL', 'NULL']];
A3320.trackEvent(properties);
})();
</script>

I know how to get the total price:

$total = sprintf("%1\$.2f",$grandTotal);

But I have no idea how to get the product list. Does anybody of you has a tip for me?

Thank you very much!

Greetings from Germany, Raisis

Raisis
  • 75
  • 1
  • 3
  • 11

1 Answers1

4

In the success page you have access to the order-id: $this->getOrderId();

Than load your order and loop over the order-items to get the products:

$_order = Mage::getModel('sales/order')->loadByIncrementId($this->getOrderId());
foreach ($_order->getAllItems() as $item) {
// do stuff with the item or optionally load them to get full product.
}

PS: you can load by SKU or by ID: $product = Mage::getModel('catalog/product')->loadByAttribute or $product = Mage::getModel('catalog/product')->load(<productID>)

JNDPNT
  • 7,445
  • 2
  • 34
  • 40