Files
grzanieplus.pl/plugins/appFacebookRemarketingPlugin/modules/appFacebookRemarketingFrontend/templates/_fbremarketing.php
2025-03-12 17:06:23 +01:00

154 lines
3.3 KiB
PHP

<?php
$smarty->assign('config_fbremarketing', $fbremarketingConfig);
if ($product_card == 1) {
$smarty->assign('product_card', $product_card);
$product_name = str_replace("'", '', $product->getName());
$smarty->assign('name', $product_name);
if ($product->getDefaultCategory()) {
$category = str_replace("'", '', $product->getDefaultCategory()->getName());
$smarty->assign('category', $category);
} else {
$smarty->assign('category', "NONE");
}
if ($fbremarketingConfig['content_id'] == 'product_code'){
$code = $product->getCode();
} else{
$code = $product->getid();
}
$smarty->assign('code', $code);
$smarty->assign('price', $product->getPriceBrutto());
$smarty->assign('currency', $product->getCurrency());
$event_id = sfContext::getInstance()->getUser()->getAttribute("fb_api_ViewContent");
if ($event_id=="") {
$event_id = "0".mt_rand(100000, 999999);
}
$smarty->assign('event_id', $event_id);
}
if ($orders == 1) {
$smarty->assign('orders', $orders);
$smarty->assign('value', $order->getTotalAmount(true));
$smarty->assign('currency', $order->getOrderCurrency()->getShortcut());
$row=array();
@$last_key = end(array_keys($order->getOrderProducts()));
$sum = 0;
foreach ($order->getOrderProducts() as $index => $order_products)
{
if ($index == $last_key)
{
if ($fbremarketingConfig['content_id'] == 'product_code'){
$row[$index]['code']=$order_products->getCode();
} else{
$row[$index]['code']=$order_products->getProduct()->getId();
}
} else {
if ($fbremarketingConfig['content_id'] == 'product_code'){
$row[$index]['code']=$order_products->getCode().', ';
} else{
$row[$index]['code']=$order_products->getProduct()->getId().', ';
}
}
$row[$index]['quantity']=$order_products->getQuantity();
$sum+= $row[$index]['quantity'];
}
$event_id = sfContext::getInstance()->getUser()->getAttribute("fb_api_Purchase");
if ($event_id=="") {
$event_id = "0".mt_rand(100000, 999999);
}
$smarty->assign('event_id', $event_id);
$smarty->assign('num_items', $sum);
$smarty->assign('results',$row);
}
if ($basket == 1) {
$smarty->assign('basket', $basket);
$items = sfContext::getInstance()->getUser()->getBasket()->getItems();
foreach ($items as $item) {
$value = $item->getPriceBrutto();
$content_ids = $item->getCode();
if ($fbremarketingConfig['content_id'] == 'product_code'){
$content_ids = $item->getCode();
} else{
$content_ids = $item->getProduct()->getId();
}
}
$smarty->assign('currency', $currency);
$smarty->assign('value', $value);
$smarty->assign('content_ids', $content_ids);
$event_id = sfContext::getInstance()->getUser()->getAttribute("fb_api_InitiateCheckout");
if ($event_id=="") {
$event_id = "4".mt_rand(100000, 999999);
}
$smarty->assign('event_id', $event_id);
}
$smarty->assign('lang', $lang);
$smarty->display('fbremarketing.html');