{%- comment -%} Auto Discount Display — standalone loader Use this snippet on themes where Shopify's Theme App Extension injection doesn't run reliably — page builders like Instant, Replo, Shogun, PageFly, GemPages, or any custom rendering pipeline that bypasses content_for_header (confirmed on Truffly Made's Instant-built pages). Install: 1. Place this file in your theme's snippets/ folder. 2. Add a single render tag to layout/theme.liquid, near : {% raw %}{% render 'auto-discount-display' %}{% endraw %} 3. Open the Auto Discount Display app and click "Sync discounts" once so the public metafield this snippet reads from is populated. This snippet reads from the public namespace shop.metafields['auto_discount_display']['discount_rules'] (not the $app namespace, which is only readable from within the Theme App Extension). Unlike earlier versions of this file, the discount-matching / DOM-injection logic is NOT inlined here — it's loaded at runtime from the same canonical source used to build the app embed. A fix we ship reaches this install automatically the next time the page loads; this file does not need to be re-pasted again after this one-time update. Only re-paste it if the install/render instructions above change. {%- endcomment -%} {%- assign rules_meta = shop.metafields['auto_discount_display']['discount_rules'] -%} {%- if rules_meta and rules_meta.value.enabled -%} {%- if request.page_type == 'product' -%} {%- elsif request.page_type == 'cart' -%} {%- comment -%} Standalone /cart page: deliberately does nothing. We never paint a badge here (Shopify handles cart pricing natively), and scanning this page was an unnecessary source of DOM interaction on a page whose own JS is especially sensitive (quantity updates, line-item removal). The cart DRAWER/tray, which can render on any OTHER page type, is excluded separately in discount-display.js via FOREIGN_UI_SEL. {%- endcomment -%} {%- else -%} {%- comment -%} Any other non-product page: the plain /search results page, home/collection pages, and — just as importantly — wherever Shopify's predictive search popup gets opened from, since it has no page_type of its own to gate on. collection.id is only meaningful on true collection/index pages; it renders blank everywhere else, which is fine — card discounts resolve via each card's own handle regardless. {%- endcomment -%} {%- endif -%} {%- endif -%}