{% sw_extends '@Storefront/storefront/base.html.twig' %}
{% block base_body_script %}
{{ parent() }}
{% if config('CbaxModulAdcell.config') and
config('CbaxModulAdcell.config.active') and
config('CbaxModulAdcell.config.pubId') and
app.request.cookies.get('adcell-enabled') == 1 %}
{% block cbax_base_body_script_adcell %}
<script async type="text/javascript" src="https://t.adcell.com/js/trad.js"></script>
{% set pubId = config('CbaxModulAdcell.config.pubId') %}
{% set catId = page.header.navigation.active.id %}
{% set catName = page.header.navigation.active.translated.name %}
{% set prodIds = page.cbaxProductIdsForAdcell ? page.cbaxProductIdsForAdcell : '' %}
{% set prodId = page.product ? page.product.productNumber : '' %}
{% set prodName = page.product ? page.product.translated.name : '' %}
{% set orderNumber = page.order ? page.order.orderNumber : '' %}
{% set searchTerm = page.searchTerm ? page.searchTerm : '' %}
{% set searchListingElements = page.listing ? page.listing.elements : [] %}
{% for item in searchListingElements %}
{% if loop.last %}
{% set prodIds = prodIds ~ item.productNumber %}
{% else %}
{% set prodIds = prodIds ~ item.productNumber ~ ';' %}
{% endif %}
{% endfor %}
{% set lineItems = page.cart ? page.cart.lineItems.elements : (page.order ? page.order.lineItems.elements : []) %}
{% set productQuantities = '' %}
{% set totalQuantity = 0 %}
{% set netPositionPrice = 0 %}
{% for item in lineItems %}
{% set totalQuantity = totalQuantity + item.quantity %}
{% set calculatedTaxes = 0 %}
{% for taxElement in item.price.calculatedTaxes.elements %}
{% set calculatedTaxes = calculatedTaxes + taxElement.tax %}
{% endfor %}
{% set netPositionPrice = netPositionPrice + item.price.totalPrice - calculatedTaxes %}
{% if loop.last %}
{% set prodIds = prodIds ~ item.payload.productNumber %}
{% set productQuantities = productQuantities ~ item.quantity %}
{% else %}
{% set prodIds = prodIds ~ item.payload.productNumber ~ ';' %}
{% set productQuantities = productQuantities ~ item.quantity ~ ';' %}
{% endif %}
{% endfor %}
<script>
window.onload = function(){ Adcell.Tracking.track(); };
</script>
{% if config('CbaxModulAdcell.config.retargeting') %}
{% if activeRoute == "frontend.home.page" %}
<script type="text/javascript" src="https://t.adcell.com/js/inlineretarget.js?method=track&pid={{ pubId }}&type=startpage" async></script>
{% endif %}
{% if activeRoute == "frontend.navigation.page" %}
<script type="text/javascript" src="https://t.adcell.com/js/inlineretarget.js?method=category&pid={{ pubId }}&categoryName={{ catName }}&categoryId={{ catId }}&productIds={{ prodIds }}&productSeparator=;" async></script>
{% endif %}
{% if activeRoute == "frontend.detail.page" %}
<script type="text/javascript" src="https://t.adcell.com/js/inlineretarget.js?method=product&pid={{ pubId }}&productId={{ prodId }}&productName={{ prodName }}&categoryId={{ catId }}&productIds={{ prodIds }}&productSeparator=;" async></script>
{% endif %}
{% if activeRoute == "frontend.search.page" %}
<script type="text/javascript" src="https://t.adcell.com/js/inlineretarget.js?method=search&pid={{ pubId }}&search={{ searchTerm }}&productIds={{ prodIds }}&productSeparator=;" async></script>
{% endif %}
{% if activeRoute == "frontend.checkout.cart.page" %}
<script type="text/javascript" src="https://t.adcell.com/js/inlineretarget.js?method=basket&pid={{ pubId }}&productIds={{ prodIds }}&quantities={{ productQuantities }}&basketProductCount={{ totalQuantity }}&basketTotal={{ netPositionPrice }}&productSeparator=;" async></script>
{% endif %}
{% if activeRoute == 'frontend.checkout.register.page' or activeRoute == 'frontend.checkout.confirm.page' %}
<script type="text/javascript" src="https://t.adcell.com/js/inlineretarget.js?method=basket&pid={{ pubId }}&productIds={{ prodIds }}&quantities={{ productQuantities }}&basketProductCount={{ totalQuantity }}&basketTotal={{ netPositionPrice }}&productSeparator=;" async></script>
{% endif %}
{% if activeRoute == "frontend.checkout.finish.page" %}
<script type="text/javascript" src="https://t.adcell.com/js/inlineretarget.js?method=checkout&pid={{ pubId }}&basketId={{ orderNumber }}&basketTotal={{ netPositionPrice }}&basketProductCount={{ totalQuantity }}&productIds={{ prodIds }}&quantities={{ productQuantities }}&productSeparator=;" async></script>
{% endif %}
{% endif %}
{% if config('CbaxModulAdcell.config.eventId') and activeRoute == "frontend.checkout.finish.page" %}
{% set eventId = config('CbaxModulAdcell.config.eventId') %}
<script async type="text/javascript" src="https://t.adcell.com/t/track.js?eventid={{ eventId }}&pid={{ pubId }}&referenz={{ orderNumber }}&betrag={{ netPositionPrice }}"></script>
<noscript>
<img src="https://t.adcell.com/t/track?pid={{ pubId }}&eventid={{ eventId }}&referenz={{ orderNumber }}&betrag={{ netPositionPrice }}" border="0" width="1" height="1">
</noscript>
{% endif %}
{% endblock %}
{% endif %}
{% endblock %}