My question is probably simple but my eyes is blinking and I cannot think something else right now. Any help appreciated
This is my initial array
var Products = [
{
"order_product_id":"1111",
"order_id":"555",
"product_id":"111",
"name":"name1",
"model":"111",
"quantity":"1",
"price":"100",
"total":"100",
"tax":"20",
},
{
"order_product_id":"2222",
"order_id":"555",
"product_id":"222",
"name":"name2",
"model":"222",
"quantity":"1",
"price":"200",
"total":"200",
"tax":"40",
}
];
and this is the array that i need (change names and exclude some elements)
{
"id": "1111",
"name": "name1",
"category": "",
"list_position": 1,
"quantity": 1,
"price": '100'
},
{
"id": "2222",
"name": "name2",
"category": " ",
"list_position": 2,
"quantity": 1,
"price": '200'
}
finally this is where i want to put the new array of products after manipulation
{
"transaction_id": 1,
"value": 99,
"currency": "EUR",
"shipping": 0,
"items": Items
}
I tried push / forEach / even string but I cannot manage to have a final clean array as Google wants like this
gtag('event', 'purchase', {
"transaction_id": 1,
"value": 99,
"currency": "EUR",
"shipping": 0,
"items": [
{
"id": "1111",
"name": "name1",
"category": "",
"list_position": 1,
"quantity": 1,
"price": '100'
},
{
"id": "2222",
"name": "name2",
"category": " ",
"list_position": 2,
"quantity": 1,
"price": '200'
}
]
});