Liquid, JavaScript, themes, sales channels
Help who can...
To send order data to the Google Tag Manager I add the following script in the settings of the Checkout section:
{% if first_time_accessed %}
dataLayer.push({
event: "purchase",
ecommerce: {
transaction_id: "{{ order.order_number || order.name }}",
value: {{ total_price | times: 0.01 }},
tax: {{ tax_price | times: 0.01 }},
shipping: {{ shipping_price | times: 0.01 }},
currency: "{{ order.currency }}",
discount: "????????????????????????????????????",
items: [
{% for line_item in line_items %}{
item_id: "{{ line_item.product_id }}",
discount: "??????????????????????",
item_name: "{{ line_item.variant.title || line_item.title }}",
currency: "{{ order.currency || shop.currency }}",
price: "{{ line_item.final_price | times: 0.01 }}",
quantity: "{{ line_item.quantity }}"
},{% endfor %}
]
}
});
Everything works well. Except I don't know how to get coupon information (code). I need to send a discount code in the "discount" field.
Can you please suggest me the object and property. I couldn't find it in the documentation. Tried experimenting with "discount_applications" but couldn't get anything from it (I have no experience with with LiquidJS and how show object in console by it)
Is this at all even possible? In particular, when the tariff version is not a Plus.
You can use following code for total discount
discount: {{ checkout.discounts_amount | times: 0.01 }}
For item level discount use following code
discount': {{ line_item.line_level_total_discount | times: 0.01 }}
User | RANK |
---|---|
37 | |
24 | |
13 | |
13 | |
9 |
Transform this holiday season into a shopping spree. Plus, learn how to effortlessly open ...
By Jasonh Dec 8, 2023Make the shift from discounts to donations, and witness your business not only thrive fina...
By Holly Dec 4, 2023On our Shopify Expert Marketplace, you can find many trusted third party developers and fr...
By Arno Nov 27, 2023