확인 페이지에서 추적 픽셀을 추가합니다
-
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">
. 제휴하지 않습니다 magento.stackexchange