I have a function that pickup a purchased products to use for tracking purchased products with analytics.js but the result in the purchase page when I call the function only show the first product without doing a loop.
What I am doing wrong?
public function AddProductosAna($result) {
$result2 = mysql_query("SELECT order_id FROM tborder WHERE cart_id = '$this->id_cesta'");
$OrderId = mysql_fetch_array($result2);
$result = mysql_query("SELECT * FROM cesta_linea WHERE id_cesta = '$this->id_cesta'");
while ($row = mysql_fetch_array($result)) {
$producto = $row['id_producto'];
return <<<HTML
ga('ecommerce:addItem', {
'id': '{$OrderId['order_id']}',
'name': '{$producto}',
'price': '{$row['precio']}',
'quantity': '{$row['cantidad']}'
});
HTML;
}
}