Checkout script help [repost from Technical Q&A board]

New Member
7 0 0

I posted this yesterday over on the Technical Q&A board, but I'm now wondering if I got the wrong group. so thought I'd post it here.


I'm needing a bit of help with some Liquid script code to be added to my Checkout Additional scripts section.

This is a live (in production) site, so I don't want to mess things up by adding any bad code, so I thought I'd ask here for some advice.


I want to add a Content Box, but only when there is an item in the order which is a particular product.type AND either the product, or it could be a variant of the product, is not a physical product (ie: requires_shipping == false).


To explain I have products of 'documents', most of them have two variants; one that can be purchased as physical printed/shipped items, and the other as a downloadable PDF. I only want to show the ContentBox if a PDF is purchased, so the product.type=="document" and requires_shipping == false. But to make it awkward some of the products are only available as PDFs and some only as physical items, so they don't have any variants, I can only find a variant.requires_shipping - is there a similar product.requires_shipping attribute?


So far I've got something along the lines of this:

{% for line in checkout.line_items %}
  {% if line.product.type == "document" %}
    {% for variant in line.product.variants %}
      {% if variant.requires_shipping == false %}
        Shopify.Checkout.OrderStatus.addContentBox( [code to be displayed] );
      {% endif %}
    {% endfor %}
  {% endif %}
{% endfor %}

Am I heading in the right direction? And what if the product doesn't have any vairants, how do I detect if it's physical or not?

Hope someone can help. Thanks.


Shopify Partner
1156 133 203

Even if the product is a standalone product, it always has a variant attached. One cannot add a master product to the cart, only variants are allowed. All products on Shopify side have at least one variant, so you should be good?

Sergiu Svinarciuc | CTO @
- Was my reply helpful? Click Like to let me know!
- Was your question answered? Mark it as an Accepted Solution!
- To learn more about the awesome stuff we do head over to or our blog