ci()->commerce->loadProcessor();
$processor->loadOrder($orderId);
$cart = $processor->getCart();
$items = [];
foreach ($cart->getItems() as $key => $value) {
if (!isset($value['meta']['description'])) continue;
$items[] = $value['meta']['description'];
}
if (empty($items)) return;
$data = [
'ecommerce' => [
'currencyCode' => 'RUB',
'purchase' => [
'actionField' => [
'id' => (string)$orderId
],
'products' => $items
]
]
];
return '<script>dataLayer.push(' . json_encode($data) . ');</script>';
Советую ознакомиться: Commerce
Обсуждают сегодня