【发布时间】:2016-04-08 07:39:13
【问题描述】:
我想在“订单确认页面”(感谢您购买页面)中为我的网站的营销像素获得一个很好的数据层跟踪。 该网站使用OXID Shop作为电子商务平台。
我想要以下设置:
IF currentPage == 'thankyou':
products_info = '[{id: 'product_id_1', price: 'price_1', quantity: 'quantity_1'},
{id: 'product_id_2', price: 'price_2', quantity: 'quantity_2'}]'
如果我的页面变量“CurrentController”='thankyou',我正在尝试使用以下代码直接从后端获取值,对于仅包含一篇文章的值的变量,我可以轻松地做到这一点。
示例:
[{if $currentControllerName == "thankyou"}]
var dataLayer = [];
[{assign var="order" value=$oView->getOrder()}]
dataLayer.push(
{email: [{$order->oxorder__oxbillemail->value}]}
);
[{/if}]
问题是当我需要获取多篇文章的值时,就像我在开头提到的 products_info 变量一样。
我正在尝试以下代码,但我不确定如何使迭代器“附加”或将每个产品值发送到一个变量:
[{if $currentControllerName == "thankyou"}]
var dataLayer = [];
[{assign var="order" value=$oView->getOrder()}]
(
[{foreach from=$orderArticles item="currOrderArticle"}]
[{assign var="currArticle" value=$currOrderArticle->getArticle()}]
[{assign var="currBasePrice" value=$currOrderArticle->getBasePrice()}]
product_info: [{id: [{$currOrderArticle->oxorderarticles__oxartnum->value}],
price: [{$currBasePrice->getBruttoPrice()}],
quantity: [{$currOrderArticle->oxorderarticles__oxamount->value}]}]
[{/foreach}]
)
[{/if}]
【问题讨论】:
-
我不确定你想要归档什么,但 OXID 使用 smarty 作为模板语言,你可以使用 Smarty 的捕获将输出附加到一个变量。
标签: php smarty google-tag-manager google-datalayer oxid