← back to Dw Contact Us Pages
theme/snippets/hide-browse-hidden.liquid
112 lines
{% comment %}
Suppress showroom-only vendors from ALL browse/search grids. TK-11186.
DATA-DRIVEN — no vendor name is hardcoded in logic. The showroom-vendor list is
sourced (in priority order) from:
1. shop metafield custom.showroom_vendors (comma-separated; store-wide, all themes)
2. theme setting settings.showroom_vendors (comma-separated)
3. a canonical fallback snapshot of ~/Projects/fix-live-board/config/showroom-vendors.json
(last resort so suppression never silently fails if 1+2 are unset).
Canonical source of truth = showroom-vendors.json. Set the shop metafield to that
file's contents (metafield-update skill) and this snippet follows it automatically.
Two layers:
(a) RENDER-TIME: product-list-item.liquid emits NO card HTML for a showroom vendor
(the real fix — no SEO-crawlable markup, no flash). This snippet's CSS also
hides any card that carries data-vendor at paint time (before JS).
(b) BACKSTOP: a JS observer catches Boost AJAX-rendered grids that bypass Liquid,
reading the SAME injected list (case-insensitive). Kept minimal.
{% endcomment %}
{%- liquid
assign showroom_raw = shop.metafields.custom.showroom_vendors
if showroom_raw == blank
assign showroom_raw = settings.showroom_vendors
endif
if showroom_raw == blank
assign showroom_raw = 'Phillip Jeffries'
endif
assign showroom_vendors = showroom_raw | split: ','
-%}
<style>
{%- for v in showroom_vendors -%}
{%- assign vt = v | strip -%}
{%- if vt != blank -%}
[data-vendor="{{ vt | escape }}"]{display:none!important;}
{%- endif -%}
{%- endfor -%}
/* TK-11307: product-level 'Showroom' tag hook — a shared-vendor showroom line (MDC under
'Phillipe Romano') carries this attr/class without exposing a hideable vendor name. */
[data-showroom="true"],.pr-showroom-hidden{display:none!important;}
</style>
<script>
(function(){
var SHOWROOM_TAG = 'showroomonly'; // TK-11307 — mirrors fix-live-board/config/showroom-vendor.cjs SHOWROOM_TAG
var HIDDEN = [{%- for v in showroom_vendors -%}{%- assign vt = v | strip -%}{%- if vt != blank -%}{{ vt | json }}{%- unless forloop.last -%},{%- endunless -%}{%- endif -%}{%- endfor -%}].map(function(s){return String(s).trim().toLowerCase();});
if (!HIDDEN.length) return;
var CARD_SEL = '.product-list-item, .boost-sd__product-item, [class*="product-item"], [class*="product-card"], article, .boost-sd__product';
function isHidden(text){ text = (text||'').trim().toLowerCase(); for (var i=0;i<HIDDEN.length;i++){ if (text.indexOf(HIDDEN[i]) > -1) return true; } return false; }
function hideProducts(){
document.querySelectorAll('.product-vendor, .product-list-item-vendor, [class*="vendor"]').forEach(function(el){
if (isHidden(el.textContent)){ var c = el.closest(CARD_SEL); if (c && c.style.display !== 'none') c.style.display = 'none'; }
});
document.querySelectorAll('.product-list-item-title a, .boost-sd__product-title a, [class*="product-title"] a, h2 a, h3 a').forEach(function(el){
if (isHidden(el.textContent)){ var c = el.closest(CARD_SEL); if (c && c.style.display !== 'none') c.style.display = 'none'; }
});
document.querySelectorAll('[data-vendor]').forEach(function(el){
if (HIDDEN.indexOf(String(el.getAttribute('data-vendor')||'').trim().toLowerCase()) > -1){ el.style.display = 'none'; }
});
// TK-11307: the product-level showroom hide is NOT done here.
// A data-tags hook used to live in this function. It was dead code — no product card on
// this store emits data-tags (measured: 59 cards across 4 surfaces, 0 data-tags) — and it
// was actively dangerous, because an earlier revision split tags on WHITESPACE and matched
// 'showroom', which makes the unrelated 'Showroom Line' tag on 18,518+ ACTIVE SELLABLE
// products (Kravet, China Seas, Scalamandre, Osborne & Little, sellable Phillipe Romano...)
// tokenize to ['showroom','line'] and MATCH. Leaving a dead hook in place invites someone
// to "make it work" by emitting data-tags, which arms exactly that landmine.
// Browse grids here are rendered by Boost SD, not Liquid, so the working mechanism is the
// id-keyed asset included below — see assets/dw-showroom-hide.js.
}
hideProducts();
if (document.readyState === 'loading') document.addEventListener('DOMContentLoaded', hideProducts);
setInterval(hideProducts, 2000);
if (document.body){ new MutationObserver(function(){ setTimeout(hideProducts, 100); }).observe(document.body, { childList:true, subtree:true }); }
})();
</script>
{%- comment -%}
TK-11307 — product-level showroom-only hide for Boost-rendered browse grids.
Boost renders every browse/search grid client-side, so neither product-list-item.liquid nor
the observer above can reach those cards; a rendered Boost card exposes only data-product-id
(no tags). dw-showroom-hide.js is GENERATED from the live 'ShowroomOnly' tag by
scripts/tk11307-showroom-tag/build-showroom-hide-asset.mjs and matches on that id.
It deliberately no-ops on /search and ?q= so the line stays findable on-site — Steve's rule
is "addressable but not discoverable". Regenerate the asset whenever the tagged set changes.
{%- endcomment -%}
<script src="{{ 'dw-showroom-hide.js' | asset_url }}" defer></script>
{%- comment -%}
TK-11925 — "contact us" pricing treatment for Boost-rendered browse/search grids.
Boost renders those grids client-side, so the Liquid path in product-list-item.liquid
never runs for them. dw-contact-us-cards.js sweeps .boost-sd__product-item cards and
swaps the price for "Contact us for pricing" for the vendors listed below.
DATA-DRIVEN, mirroring the showroom_vendors pattern above:
1. shop metafield custom.contact_us_vendors (comma-separated; store-wide)
2. theme setting settings.contact_us_vendors (comma-separated)
3. literal fallback: Designers Guild, Ralph Lauren, Christian Lacroix Europe, Nina Campbell
{%- endcomment -%}
{%- liquid
assign contact_us_raw = shop.metafields.custom.contact_us_vendors
if contact_us_raw == blank
assign contact_us_raw = settings.contact_us_vendors
endif
if contact_us_raw == blank
assign contact_us_raw = 'Designers Guild,Ralph Lauren,Christian Lacroix Europe,Nina Campbell'
endif
assign contact_us_vendors = contact_us_raw | split: ','
-%}
<script>
window.DW_CONTACT_US_VENDORS = [{%- for v in contact_us_vendors -%}{%- assign vt = v | strip -%}{%- if vt != blank -%}{{ vt | json }}{%- unless forloop.last -%},{%- endunless -%}{%- endif -%}{%- endfor -%}];
</script>
<script src="{{ 'dw-contact-us-cards.js' | asset_url }}" defer></script>