[英]magento tracking pixel checkout
I'm trying to integrate a tracking pixel into the magento success page. 我正在尝试将跟踪像素集成到magento成功页面中。 For testing I build the following code and implemented it into line > 45 in success.phtml file within the template folder. 为了进行测试,我构建了以下代码,并在template文件夹中的success.phtml文件中的> 45行中实现了该代码。 Actually the variables are all empty. 实际上,变量都是空的。 What's wrong? 怎么了?
<?php
<?php
$lastOrderId = Mage::getSingleton('checkout/session')->getLastOrderId();
$order = Mage::getSingleton('sales/order');
$order->load($lastOrderId);
$skus = array();
$qtys = array();
$amounts = array();
foreach ($order->getAllItems() as $item){
$skus[$item->getProductId()] = $item->getSku();
$names[$item->getProductId()] = $item->getName();
$qtys[$item->getProductId()] = $item->getQtyOrdered() * 1;
$amounts[$item->getProductId()] = $item->getRowTotal() * 100;//or $item->getPrice()*$item->getQtyOrdered();//but this will ignore any applied coupons
}
$skuspipe = implode("|", $skus);
$namespipe = implode("|", $names);
$qtyspipe = implode("|", $qtys);
$amountspipe = implode("|", $amounts);
<!--
OrderID: <?php echo $orderID; ?>
skus: <?php print_r($skus); ?>
names: <?php print_r($names); ?>
qtys: <?php print_r($qtys); ?>
amounts: <?php print_r($amounts); ?>
skupipe: <?php echo $skupipe; ?>
namespipe: <?php echo $namespipe; ?>
qtyspipe: <?php echo $qtyspipe; ?>
amountspipe: <?php echo $amountspipe; ?>
-->
Thank you! 谢谢!
In Collections, Magento often only loads kind of a stub of data for each item. 在集合中,Magento通常只为每个项目加载某种数据存根。
You could load the whole objects by using 您可以使用加载整个对象
$item->load( $item->getId() );
on each iteration. 在每次迭代中。
Also, try to debug output the collection first to see if there are any items found. 另外,尝试首先调试集合的输出以查看是否找到任何项目。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.