在顺序确认页面中添加跟踪像素
-
13-12-2019 - |
题
我已收到来自我们的一个广告公司的跟踪像素,并让我在订单确认页面中放置该代码。
首先可以告诉我位于magento的订单确认文件在哪里?
和2nd如果我需要得到“订单ID”值和“数量”,那么在这个像素中使用了什么。
<img src="https://www.emjcd.com/u?AMOUNT=AMOUNT&CID=7777777&OID=OID&TYPE=5555555&CURRENCY=GBP&METHOD=IMG" height="1" width="20"/>
.
您可以在此处获取更多信息: http://www.pricerunner.co.uk /关于/销售跟踪 - 说明.html
解决方案
您需要从
复制您的基本模板文件app/design/frontend/base/default/template/checkout/success.phtml
.
到您的Ultimo主题路径
app/design/frontend/ultimo/default/template/checkout
.
您可以将以下代码放在success.phtml文件中
<?php
$order_id = Mage::getSingleton('checkout/session')->getLastRealOrderId();
$order = Mage::getModel('sales/order')->loadByIncrementId($order_id);
$grandTotal = $order->getGrandTotal();
$orderCurrency = $order->getOrderCurrencyCode();
?>
<img src="https://www.emjcd.com/u?AMOUNT=<?php echo $grandTotal; ?>&CID=7777777&OID='<?php echo $order_id;?>'&TYPE=5555555&CURRENCY=<?php echo $orderCurrency; ?>&METHOD=IMG" height="1" width="20"/>
. 其他提示
如果您正在使用RWD主题,它在 / app/design/frontend/rwd/default/template/checkout/success.phtml
确认页面上的订单对象 - 它已卸载此阶段。因此,您可以编写一个模块来挂钩到订单保存功能,但如果您需要快速修复,可以使用类似的东西(在success.phtml中)加载最后订单ID:
$lastOrderId = Mage::getSingleton('checkout/session')->getLastOrderId();
$order = Mage::getSingleton('sales/order');
$order->load($lastOrderId);
$_totalData =$order->getData();
$_sub = $_totalData['subtotal'];
. magento v2.1.x
这是您需要的所有额外值以及
<?php
$merchantid = "<ID>";
$objectManager = \Magento\Framework\App\ObjectManager::getInstance();
$orderId = $block->getOrderId();
$order = $objectManager
->create('Magento\Sales\Model\Order')
->loadByIncrementId($orderId);
$subtotal = $order->getSubtotal();
$discount = $order->getDiscountAmount();
$affiliateTotal = ($subtotal + $discount);
$ordered_items = $order->getAllVisibleItems();
$skulist = '';
$pricelist = '';
$quantitylist = '';
$last_index = array_search(end($ordered_items), $ordered_items, true);
foreach($ordered_items as $index => $item){
$delimiter = $index === $last_index ? '' : ',';
$skulist .= $item->getSku() . $delimiter;
$quantitylist .= ceil($item->getQtyOrdered()) . $delimiter;
$pricelist .= ($item->getProduct()->getFinalPrice() - ($item->getDiscountAmount() / $item->getQtyOrdered())) . $delimiter;
}
$couponcodes = $order->getCouponCode();
$currency = $order->getOrderCurrencyCode();
//render pixel below
?>
<img src="https://www.emjcd.com/u?tracking=<?php echo $orderId ?>&amount=<?php echo $affiliateTotal ?>&transtype=sale&merchantID=<?php echo $merchantid ?>&couponcode=<?php echo $couponcodes ?>&skulist=<?php echo $skulist ?>&quantitylist=<?php echo $quantitylist ?>&pricelist=<?php echo $pricelist ?>&currency=<?php echo $currency ?>&v=2.0" width="1" height="1">
.