From c83e908da124e2720bcbe56369707128577de267 Mon Sep 17 00:00:00 2001 From: MaxBUhe Date: Wed, 11 Jan 2023 15:04:41 +0100 Subject: [PATCH] reworking view_cart to add necessary parameters --- Application/views/blocks/checkout_s1.tpl | 84 ++++++++---------------- 1 file changed, 29 insertions(+), 55 deletions(-) diff --git a/Application/views/blocks/checkout_s1.tpl b/Application/views/blocks/checkout_s1.tpl index 9123e19..d488548 100644 --- a/Application/views/blocks/checkout_s1.tpl +++ b/Application/views/blocks/checkout_s1.tpl @@ -1,57 +1,31 @@ -[{strip}] - [{assign var='gtmCartArticles' value=$oView->getBasketArticles()}] - -[{/strip}] -[{$smarty.block.parent}] \ No newline at end of file +[{assign var='gtmCartArticles' value=$oView->getBasketArticles()}] +[{strip}][{capture assign=d3_ga4_view_cart}] + dataLayer.push({"event": null, "eventLabel": null, "ecommerce": null}); /* Clear the previous ecommerce object. */ + dataLayer.push({ + 'event': 'view_cart', + 'eventLabel':'Checkout Step 1', + 'ecommerce': { + 'actionField': "step: 1", + 'currency': "[{$currency->name}]", + 'value': [{$oxcmp_basket->getBruttoSum()}], + 'items': [ + [{foreach from=$oxcmp_basket->getContents() item=basketitem name=gtmCartContents key=basketindex}] + [{assign var='_price' value=$basketitem->getUnitPrice()}] + { + 'item_id': '[{$gtmCartArticles[$basketindex]->oxarticles__oxartnum->value}]', + 'item_name': '[{$gtmCartArticles[$basketindex]->oxarticles__oxtitle->value}]', + 'item_variant': '[{$gtmCartArticles[$basketindex]->oxarticles__oxvarselect->value}]', + 'price': [{$_price->getPrice()}], + 'quantity':[{$basketitem->getAmount()}], + 'position':[{$smarty.foreach.gtmCartContents.index}] + }[{if !$smarty.foreach.gtmCartContents.last}],[{/if}] + [{/foreach}] + ] + } + }); +[{/capture}][{/strip}] +[{oxscript add=$d3_ga4_view_cart}] \ No newline at end of file