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