magento
2013-01-17 62 views 2 likes 
2

我需要您的幫助來解決我的magento問題。我有一個成功頁面跟蹤代碼來跟蹤訂單。這是我的跟蹤代碼:Magento:在成功頁面上獲取購物車信息

<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> 

我知道如何獲得總價:

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

但我不知道如何獲得產品列表。你們中有人有給我的小費嗎?

非常感謝!來自德國

問候, Raisis

回答

4

在成功頁面可以訪問到訂單ID:$this->getOrderId();

比載重超過訂單項目訂單,並循環到拿到產品:

$_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:$product = Mage::getModel('catalog/product')->loadByAttribute$product = Mage::getModel('catalog/product')->load(<productID>)

:可以通過SKU或通過ID加載
相關問題