Hello everyone,
I’m using the Shopify Horizon theme and I’m trying to add a custom visual price line under the existing AED price on collection product cards.
I’m attaching a screenshot (see red arrow) and explaining exactly where the price appears and what we tried, so you can see where the correct hook/placement should be.
1) Where the price is displayed (important)
On collection pages, each product card shows the price like this:
Dhs. 210.00
This price appears:
-
Inside a product card (grid item)
-
Rendered by Horizon’s Web Components (
product-card,product-price) -
NOT as a simple
.pricespan like classic themes
The red arrow in the screenshot points to the exact visual location:
Directly under the product title, inside the product card
2) What I want to add (visual only)
After
that existing price, I want to show:
≈ USD 57
This is:
-
Visual only (no checkout impact)
-
Collection page only
-
Not touching product templates or checkout
3) JavaScript file created
I created a custom JS file:
Path
/assets/AED-USD.js
4) Code placed inside AED-USD.js (exact)
console.log('AED-USD.js LOADED');
(() => {
const AED_TO_USD = 0.27;
function scan() {
document.querySelectorAll('product-card').forEach(card => {
if (card.querySelector('.cm-usd-line')) return;
const text = card.innerText || '';
const match = text.match(/Dhs\.\s*([0-9,.]+)/i);
if (!match) return;
const aed = parseFloat(match[1].replace(/,/g, ''));
if (!aed) return;
const usd = Math.round(aed * AED_TO_USD);
if (!usd) return;
const el = document.createElement('div');
el.className = 'cm-usd-line';
el.textContent = `≈ USD ${usd}`;
el.style.fontSize = '12px';
el.style.color = '#777';
card.appendChild(el);
});
}
document.addEventListener('DOMContentLoaded', scan);
})();
5) How the file is loaded
In layout/theme.liquid, right before </body>, I added:
<script src="{{ 'AED-USD.js' | asset_url }}" defer></script>
Full context at the bottom of the file:
{% if settings.quick_add or settings.mobile_quick_add %}
{% render 'quick-add-modal' %}
{% endif %}
<script src="{{ 'AED-USD.js' | asset_url }}" defer></script>
</body>
</html>
6) Result
The JS file does not execute:
-
No
console.log -
No
alert -
No DOM changes
Everything else in the theme works normally.
7) Core question (what I need help with)
Given Horizon’s architecture:
-
Web Components
-
import maps
-
modular scripts loaded via
snippets/scripts.liquid
Where is the correct and supported place to hook custom logic that targets product-card pricing?
Specifically:
-
Should this be registered as a module inside
snippets/scripts.liquid? -
Is there a Horizon lifecycle / event for product card hydration?
-
Is
layout/theme.liquidtoo late or ignored for this purpose?
Any guidance from someone who has modified Horizon product cards would be greatly appreciated.
Thank you.
