switch metadata entries; fix getPrice-bug

This commit is contained in:
MaxBUhe 2023-05-23 10:06:21 +02:00
parent af78809ae5
commit 002cc69d2a
3 changed files with 39 additions and 43 deletions

View File

@ -1,6 +1,7 @@
[{$smarty.block.parent}]
[{assign var="d3PriceObject" value=$gtmProduct->getPrice()}]
[{assign var="d3ProductObject" value=$oView->getProduct()}]
[{assign var="d3PriceObject" value=$d3ProductObject->getPrice()}]
[{capture assign=d3_ga4_add_to_cart}]
[{block name="d3_ga4_add_to_basket"}]

View File

@ -1,35 +1,36 @@
[{assign var="gtmProducts" value=$products}]
[{assign var="d3PriceObject" value=$gtmProducts->getPrice()}]
[{assign var="breadCrumb" value=''}]
[{if $gtmProducts|@count}]
[{strip}]
<script>
/* ga4 */
dataLayer.push({ecommerce: null});
dataLayer.push({
'event':'view_item_list',
'event_name': 'view_item_list',
'ecommerce': {
'item_list_id': '[{$oView->getCategoryId()}]',
'item_list_name': '[{foreach from=$oView->getBreadCrumb() item=sCrum}][{if $sCrum.title }][{$breadCrumb|cat:$sCrum.title|cat:" > "}][{/if}][{/foreach}]',
'items': [
[{foreach from=$gtmProducts name="gtmProducts" item="gtmProduct"}]
[{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': [{$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
}[{if !$smarty.foreach.gtmProducts.last}],[{/if}]
[{/foreach}]
]
}
});
</script>
[{/strip}]
[{$smarty.block.parent}]
[{assign var="gtmProducts" value=$products}]
[{assign var="breadCrumb" value=''}]
[{if $gtmProducts|@count}]
[{strip}]
<script>
/* ga4 */
dataLayer.push({ecommerce: null});
dataLayer.push({
'event':'view_item_list',
'event_name': 'view_item_list',
'ecommerce': {
'item_list_id': '[{$oView->getCategoryId()}]',
'item_list_name': '[{foreach from=$oView->getBreadCrumb() item=sCrum}][{if $sCrum.title }][{$breadCrumb|cat:$sCrum.title|cat:" > "}][{/if}][{/foreach}]',
'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': [{$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
}[{if !$smarty.foreach.gtmProducts.last}],[{/if}]
[{/foreach}]
]
}
});
</script>
[{/strip}]
[{/if}]

View File

@ -43,17 +43,11 @@ $aModule = [
'block' => 'theme_svg_icons',
'file' => '/Application/views/blocks/_gtm_nojs.tpl'
],
// widget_product_list
[
'template' => 'widget/product/list.tpl',
'block' => 'widget_product_list',
'file' => '/Application/views/blocks/widget_product_list.tpl'
],
// details
[
'template' => 'page/details/inc/productmain.tpl',
'block' => 'details_productmain_title',
'file' => '/Application/views/blocks/detail.tpl',
'file' => '/Application/views/blocks/view_item.tpl',
'position' => 150
],
// checkout
@ -71,7 +65,7 @@ $aModule = [
// view_item_list
[
'template' => 'widget/product/list.tpl',
'block' => 'd3Ga4_view_item_list',
'block' => 'widget_product_list',
'file' => '/Application/views/ga4/view_item_list.tpl',
'position' => 150
],