genuine code cleanup; switch hard-getter to methods and use price-object
This commit is contained in:
parent
27798703b0
commit
122dd4cf53
@ -2,10 +2,10 @@
|
||||
|
||||
[{*$oxcmp_basket|get_class_methods|dumpvar*}]
|
||||
|
||||
[{assign var="d3BasketPrice" value=$oxcmp_basket->getPrice()}]
|
||||
|
||||
[{assign var='gtmCartArticles' value=$oView->getBasketArticles()}]
|
||||
[{strip}][{capture assign=d3_ga4_view_cart}]
|
||||
let iPrice = "[{oxprice price=$oxcmp_basket->getPrice()}]";
|
||||
|
||||
dataLayer.push({"event": null, "eventLabel": null, "ecommerce": null}); /* Clear the previous ecommerce object. */
|
||||
dataLayer.push({
|
||||
'event': 'view_cart',
|
||||
@ -13,15 +13,15 @@
|
||||
'ecommerce': {
|
||||
'actionField': "step: 1",
|
||||
'currency': "[{$currency->name}]",
|
||||
'value': iPrice.replace("€", ""),
|
||||
'value': [{$d3BasketPrice->getPrice()}],
|
||||
'items': [
|
||||
[{foreach from=$oxcmp_basket->getContents() item=basketitem name=gtmCartContents key=basketindex}]
|
||||
[{assign var='_price' value=$basketitem->getUnitPrice()}]
|
||||
[{assign var="d3oItemPrice" value=$basketitem->getPrice()}]
|
||||
{
|
||||
'item_id': '[{$gtmCartArticles[$basketindex]->oxarticles__oxartnum->value}]',
|
||||
'item_name': '[{$gtmCartArticles[$basketindex]->oxarticles__oxtitle->value}]',
|
||||
'item_variant': '[{$gtmCartArticles[$basketindex]->oxarticles__oxvarselect->value}]',
|
||||
'price': [{$_price->getPrice()}],
|
||||
'item_id': '[{$gtmCartArticles[$basketindex]->getFieldData('oxartnum')}]',
|
||||
'item_name': '[{$gtmCartArticles[$basketindex]->getFieldData('oxtitle')}]',
|
||||
'item_variant': '[{$gtmCartArticles[$basketindex]->getFieldData('oxvarselect')}]',
|
||||
'price': [{$d3oItemPrice->getPrice()}],
|
||||
'quantity':[{$basketitem->getAmount()}],
|
||||
'position':[{$smarty.foreach.gtmCartContents.index}]
|
||||
}[{if !$smarty.foreach.gtmCartContents.last}],[{/if}]
|
||||
|
@ -10,21 +10,22 @@
|
||||
'event': 'purchase',
|
||||
'eventLabel':'Checkout Step 5',
|
||||
'ecommerce': {
|
||||
'transaction_id': '[{$_gtmOrder->oxorder__oxordernr->value}]',
|
||||
'affiliation': '[{$oxcmp_shop->oxshops__oxname->value}]',
|
||||
'value': '[{$_gtmOrder->oxorder__oxtotalordersum->value}]',
|
||||
'tax': '[{math equation="x+y" x=$_gtmOrder->oxorder__oxartvatprice1->value y=$_gtmOrder->oxorder__oxartvatprice2->value }]',
|
||||
'shipping': '[{$_gtmOrder->oxorder__oxdelcost->value}]',
|
||||
'transaction_id': '[{$_gtmOrder->getFieldData("oxordernr")}]',
|
||||
'affiliation': '[{$oxcmp_shop->getFieldData("oxname")}]',
|
||||
'value': '[{$_gtmOrder->getTotalOrderSum()}]',
|
||||
'tax': '[{math equation="x+y" x=$_gtmOrder->getFieldData("oxartvatprice1") y=$_gtmOrder->getFieldData("oxartvatprice2") }]',
|
||||
'shipping': '[{$_gtmOrder->getFieldData("oxdelcost")}]',
|
||||
'currency': '[{$_gtmOrder->getFieldData('oxcurrency')}]',
|
||||
'items':
|
||||
[
|
||||
[{foreach from=$_gtmArticles item="_gtmArticle" name="gtmArticles"}]
|
||||
[{foreach from=$_gtmArticles item="d3BasketArticle" name="gtmArticles"}]
|
||||
[{assign var="d3oArticlePrice" value=$d3BasketArticle->getPrice()}]
|
||||
{
|
||||
'id': '[{$_gtmArticle->oxorderarticles__oxartnum->value}]',
|
||||
'name': '[{$_gtmArticle->oxorderarticles__oxtitle->value}]',
|
||||
'variant': '[{$_gtmArticle->oxorderarticles__oxselvariant->value}]',
|
||||
'price': [{$_gtmArticle->oxorderarticles__oxprice->value}],
|
||||
'quantity': [{$_gtmArticle->oxorderarticles__oxamount->value}],
|
||||
'id': '[{$d3BasketArticle->getFieldData("oxartnum")}]',
|
||||
'name': '[{$d3BasketArticle->getFieldData("oxtitle")}]',
|
||||
'variant': '[{$d3BasketArticle->getFieldData("oxselvariant")}]',
|
||||
'price': [{$d3oArticlePrice->getPrice()}],
|
||||
'quantity': [{$d3BasketArticle->getFieldData("oxamount")}],
|
||||
'position': [{$smarty.foreach.gtmArticles.iteration}]
|
||||
}[{if !$smarty.foreach.gtmArticles.last}],[{/if}]
|
||||
[{/foreach}]
|
||||
|
@ -12,12 +12,13 @@
|
||||
'currency': '[{$currency->name}]',
|
||||
'items': [
|
||||
{
|
||||
'item_name': '[{$gtmProduct->oxarticles__oxtitle->value}]',
|
||||
'item_id': '[{$gtmProduct->oxarticles__oxartnum->value}]',
|
||||
'item_name': '[{$gtmProduct->getFieldData("oxtitle")}]',
|
||||
'item_id': '[{$gtmProduct->getFieldData("oxartnum")}]',
|
||||
'item_brand': '[{if $gtmManufacturer}][{$gtmManufacturer->oxmanufacturers__oxtitle->value}][{/if}]',
|
||||
'item_category': '[{if $gtmCategory}][{$gtmCategory->getLink()|parse_url:5|ltrim:"/"|rtrim:"/"}][{else}]-[{/if}]',
|
||||
'item_variant': '[{if $gtmProduct->oxarticles__oxvarselect->value}][{$gtmProduct->oxarticles__oxvarselect->value}][{/if}]',
|
||||
'price': [{$gtmProduct->oxarticles__oxprice->value}]
|
||||
'item_variant': '[{if $gtmProduct->getFieldData("oxvarselect")}][{$gtmProduct->getFieldData("oxvarselect")}][{/if}]',
|
||||
[{assign var="d3PriceObject" value=$gtmProduct->getPrice()}]
|
||||
'price': [{$d3PriceObject->getPrice()}]
|
||||
}
|
||||
]
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
[{$smarty.block.parent}]
|
||||
|
||||
[{*$gtmProduct|get_class_methods|dumpvar*}]
|
||||
[{assign var="d3PriceObject" value=$gtmProduct->getPrice()}]
|
||||
|
||||
[{capture assign=d3_ga4_add_to_cart}]
|
||||
[{block name="d3_ga4_add_to_basket"}]
|
||||
@ -17,23 +17,18 @@
|
||||
'eventLabel': 'add_to_cart',
|
||||
'ecommerce': {
|
||||
'currency': "[{$currency->name}]",
|
||||
'value': iArtQuantity*[{$gtmProduct->getFieldData('oxprice')}],
|
||||
'value': iArtQuantity*[{$d3PriceObject->getPrice()}],
|
||||
'items': [
|
||||
{
|
||||
'item_id': '[{$gtmProduct->getFieldData('oxartnum')}]',
|
||||
'item_name': '[{$gtmProduct->getFieldData('oxtitle')}]',
|
||||
'price': '[{$gtmProduct->getFieldData('oxprice')}]',
|
||||
'price': '[{$d3PriceObject->getPrice()}]',
|
||||
'item_brand': '[{if $gtmManufacturer}][{$gtmManufacturer->oxmanufacturers__oxtitle->value}][{/if}]',
|
||||
'item_variant': '[{if $gtmProduct->getFieldData('oxvarselect')}][{$gtmProduct->getFieldData('oxvarselect')}][{/if}]',
|
||||
'item_category': itemCategories[0] || 'no category',
|
||||
'item_category_2':itemCategories[1] || '',
|
||||
'item_category_3':itemCategories[2] || '',
|
||||
'item_category_4':itemCategories[3] || '',
|
||||
[{if false}]
|
||||
'item_list_name': 'Search Results', // If associated with a list selection.
|
||||
'item_list_id': 'SR123', // If associated with a list selection.
|
||||
'index': 1, // If associated with a list selection.
|
||||
[{/if}]
|
||||
'quantity': iArtQuantity
|
||||
}
|
||||
]
|
||||
|
@ -13,12 +13,13 @@
|
||||
'search_term': '[{$searchparamforhtml}]',
|
||||
'items': [
|
||||
[{foreach from=$gtmProducts name="gtmProducts" item="gtmProduct"}]
|
||||
[{assign var="d3PriceObject" value=$gtmProduct->getPrice()}]
|
||||
[{assign var="gtmManufacturer" value=$gtmProduct->getManufacturer()}]
|
||||
[{if !$gtmCategory}][{assign var="gtmCategory" value=$gtmProduct->getCategory()}][{/if}]
|
||||
{
|
||||
'item_id': '[{$gtmProduct->getFieldData("oxartnum")}]',
|
||||
'item_name': '[{$gtmProduct->getFieldData("oxtitle")}]',
|
||||
'price': [{$gtmProduct->oxarticles__oxprice->value|default:'0'}],
|
||||
'price': [{$d3PriceObject->getPrice()}],
|
||||
'item_brand': '[{if $gtmManufacturer}][{$gtmManufacturer->oxmanufacturers__oxtitle->value}][{/if}]',
|
||||
'item_category': '[{if $gtmCategory}][{$gtmCategory->getLink()|parse_url:5|ltrim:"/"|rtrim:"/"}][{else}]-[{/if}]',
|
||||
'quantity': 1
|
||||
|
@ -1,4 +1,5 @@
|
||||
[{assign var="gtmProducts" value=$products}]
|
||||
[{assign var="d3PriceObject" value=$gtmProducts->getPrice()}]
|
||||
|
||||
[{assign var="breadCrumb" value=''}]
|
||||
|
||||
@ -20,7 +21,7 @@
|
||||
{
|
||||
'item_id': '[{$gtmProduct->getFieldData("oxartnum")}]',
|
||||
'item_name': '[{$gtmProduct->getFieldData("oxtitle")}]',
|
||||
'price': [{$gtmProduct->oxarticles__oxprice->value|default:'0'}],
|
||||
'price': [{$d3PriceObject->getPrice()}],
|
||||
'item_brand': '[{if $gtmManufacturer}][{$gtmManufacturer->oxmanufacturers__oxtitle->value}][{/if}]',
|
||||
'item_category': '[{if $gtmCategory}][{$gtmCategory->getLink()|parse_url:5|ltrim:"/"|rtrim:"/"}][{else}]-[{/if}]',
|
||||
'quantity': 1
|
||||
|
Loading…
Reference in New Issue
Block a user