Ad

Shopify Additional Scripts

- 1 answer

Within Shopify's "Additional Scripts" section of the Checkout, I need to add a script (below) for tracking purposes, and for the life of me I cannot get the cart item quantity to render.

Apparently I should be able to use Liquid syntax to render the value, but whenever I do a test, the value is empty.

Below is my script that isn't working.

<script language='JavaScript1.1' async src='//pixel.trackingcompany.com/event/js?mt_id=123&mt_adid=456&mt_exem=&mt_excl=&s1={{ cart.item_count }}'></script>

When it renders, I currently get everything except the {{ cart.item_count }} value.

Ad

Answer

There is no cart item in the checkout process.

You should swap cart.item_count with checkout.line_items.size or order.line_items.size.

Ad
source: stackoverflow.com
Ad