{% comment %}
  Offset with ICN — Shopify snippet (no app needed)

  Easiest install, no code editing:
    Online Store → Themes → Customize → open the Cart page (or Product page)
    → Add block → "Custom Liquid" → paste everything below → Save.

  Or as a theme snippet: Online Store → Themes → … → Edit code → Snippets
    → Add a new snippet "icn-offset" → paste → then add {% render 'icn-offset' %}
    where you want the box (e.g. in main-cart-footer.liquid).

  Footprint estimate: grams of CO2e per kg of cart weight (shipping) plus a fixed
  amount per order (packaging). Change the two numbers below to suit your store.
{% endcomment %}
{%- assign icn_g_per_kg = 500 -%}
{%- assign icn_g_per_order = 300 -%}
{%- assign icn_kg = cart.total_weight | divided_by: 1000.0 -%}
{%- assign icn_grams = icn_kg | times: icn_g_per_kg | plus: icn_g_per_order -%}
{%- assign icn_tonnes = icn_grams | divided_by: 1000000.0 -%}
{%- if cart.item_count > 0 -%}
  <div data-icn-offset
       data-tonnes="{{ icn_tonnes }}"
       data-label="your order"
       data-partner="{{ shop.permanent_domain | split: '.' | first }}"></div>
  <script src="https://icn.earth/widget/icn-widget.js" async></script>
{%- endif -%}
