Success.phtml - 如何根据客户订购的产品ID触发令人富illyate脚本?
-
13-12-2019 - |
题
首先 - 我不是一个开发人员..我试过谷歌,但似乎无法解决如何做到这一点..
我需要向我的成功添加函数.Phtml,触发我从附属提供商那里获得的谍跟踪脚本。 我有两个不同的跟踪脚本,如果客户购买了产品ID匹配了一个这些ID的“19,76,84,85,86,95”和另一个应该触发的脚本,则应触发第一个脚本客户不购买任何提及的产品..
- 我试图将此添加到我的成功.phtml,但这显然不起作用。有人可以成为天使,帮助我排序吗?
<?php
$order = Mage::getModel('sales/order')->loadByIncrementId($this->getOrderId());
$items = $order->getItemsCollection();
$sku = $ids = array();
foreach($items as $item){
$p_ids[] = $item->getProductId();
}
$p_id = 19, 76, 84, 85, 86, 95;
?>
<?php if(in_array($p_id, $p_ids)){
//run script 1
<script type="text/javascript" src="https://track.adtraction.com/t/t?t=1********************************************************"></script>
} else {
//run script 2
<script type="text/javascript" src="https://track.adtraction.com/t/t?2********************************************************"></script>
}
<?php endif;?>
. 解决方案
尝试
<?php
$order = Mage::getModel('sales/order')->loadByIncrementId($this->getOrderId());
$items = $order->getItemsCollection();
$found = false;
$affiliateProductIds = array(19, 76, 84, 85, 86, 95);
foreach($items as $item){
if(in_array($item->getProductId(), $affiliateProductIds)){
//if you need to send the product ids to the affiliate, they use an array instead of bool ($found)
$found = true;
}
}
?>
<?php if($found) : ?>
<script type="text/javascript" src="https://track.adtraction.com/t/t?t=1********************************************************"></script>
<?php else : ?>
<script type="text/javascript" src="https://track.adtraction.com/t/t?2********************************************************"></script>
<?php endif;?>
.