I would like to get a nice data layer tracking for my site's marketing pixels in the "order confirmation page" (thank you for you purchase page). The site uses OXID Shop as the ecommerce platform.
I would like to have the following setup:
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'}]'
I am trying the following code to obtain the values directly from the backend if my page variable "CurrentController"='thankyou', which I can easily do for a variable that contains only the values of one article.
Example:
[{if $currentControllerName == "thankyou"}]
var dataLayer = [];
[{assign var="order" value=$oView->getOrder()}]
dataLayer.push(
{email: [{$order->oxorder__oxbillemail->value}]}
);
[{/if}]
The issue is when I need to get values for more than one article, something like what I mentioned at the beginning for the products_info variable.
I am trying the following code, but I'm not sure how to make the iterator "append" or send each products values to one single variable:
[{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}]