Script not giving a few variables back

asd123
Excursionist
20 0 8

Hello.

Some of variables in my script does not work. Could you check why?

It only gives back the numer of the order.

Here is the script:

<script>
x('track', 'Purchase', {
transaction_id: '{{order.name}}',
value: {{order.totalPriceSet.shopMoney.amount}},
shipping_cost: {{order.totalShippingPriceSet.shopMoney.amount}},
discount_code: '{{order.discountCode}}',
contents: [
{% for a in order.lineItems %}
{
id: '{{a.id}}',
name: '{{a.title}}',
ean: '{{a.sku}}',
price: {{a.originalUnitPriceSet.shopMoney.amount}},
quantity: {{a.quantity}},
in_stock: ‘true’
},
{% endfor %}
]
});

And here is the outcome:

luxuria_0-1632296504099.png

Any help would be really appreciated.

Thanks in advance.

Reply 1 (1)

IttantaTech
Shopify Partner
525 55 102

Hello , @asd123 

May be you can try like this :-

x('track', 'Purchase', {
transaction_id: '{{order.name}}',
value: {{order.total_price | money}},
shipping_cost: {{order.shipping_price | money}},

{% for discount_application in order.discount_applications %}
discount_code: '{{discount_application.title}}',

{% endfor %}
contents: [
{% for a in order.lineItems %}
{
id: '{{a.id}}',
name: '{{a.title}}',
ean: '{{a.sku}}',
price: {{a.originalUnitPriceSet.shopMoney.amount}},
quantity: {{a.quantity}},
in_stock: ‘true’
},
{% endfor %}
]
});

Thanks,
Ittanta Technologies Pvt. Ltd. | Shopify Expert
If reply is helpful, please Like and Accept Solution.
To hire us, contact us at info@ittanta.com