success.phtml - 고객이 주문한 제품 ID를 기반으로 공휴인 스크립트를 트리거하는 방법?

magento.stackexchange https://magento.stackexchange.com//questions/90356

문제

나는 개발자가 아닙니다. 나는 Google을 시도했지만이를 수행하는 방법을 알아낼 수없는 것 같습니다.

내 성공에 함수를 추가해야합니다 .phtml 내 제휴 공급자에게서 얻은 스피커스 추적 스크립트를 트리거합니다. 제품 ID가 제품 ID가 하나의 ID의 "19, 76, 84, 85, 86, 95"및 트리거되어야하는 다른 스크립트가 하나의 ID와 일치하는 경우 첫 번째 스크립트가 트리거되어야하는 두 가지 추적 스크립트가 있습니다.고객은 언급 된 제품 중 하나를 사지 않습니다.

- 나는 이것을 내 성공에 추가하려고 노력했습니다 .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;?>
.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 magento.stackexchange
scroll top