[object Object]

← back to Designer Wallcoverings

Stage You-May-Also-Like mobile 2-up grid fix on dev theme 5.1

1cd2c5dfd6e2c2557bda21e9d5fa67080aa26339 · 2026-06-23 16:26:49 -0700 · Steve

Files touched

Diff

commit 1cd2c5dfd6e2c2557bda21e9d5fa67080aa26339
Author: Steve <steve@designerwallcoverings.com>
Date:   Tue Jun 23 16:26:49 2026 -0700

    Stage You-May-Also-Like mobile 2-up grid fix on dev theme 5.1
---
 shopify/push-rec-grid-fix-to-dev-theme.sh | 100 ++++++++++++++++++++++++++++++
 1 file changed, 100 insertions(+)

diff --git a/shopify/push-rec-grid-fix-to-dev-theme.sh b/shopify/push-rec-grid-fix-to-dev-theme.sh
new file mode 100755
index 00000000..c079c9ad
--- /dev/null
+++ b/shopify/push-rec-grid-fix-to-dev-theme.sh
@@ -0,0 +1,100 @@
+#!/usr/bin/env bash
+# Stage the "You may also like" mobile-grid fix on the DW DEV theme — drift-safe.
+#
+# The PDP product-recommendations block (.product-recommendations.rows-of-4)
+# computes to display:block on phones (theme masonry JS leaves the cards as
+# full-width blocks), so the 3-4 recommended products STACK vertically as giant
+# images. This appends a self-contained <style id="dw-rec-grid-fix"> to the
+# globally-included snippets/dw-boost-overrides.liquid that forces a 2-up grid
+# on <=768px and neutralizes the abandoned masonry positioning.
+#
+# Idempotent (marker dw-rec-grid-fix → replace-in-place on re-run). Targets the
+# DEV theme by id (fallback: first non-main development theme). NEVER live.
+#
+#   bash push-rec-grid-fix-to-dev-theme.sh
+set -euo pipefail
+cd "$(dirname "$0")"
+
+STORE="designer-laboratory-sandbox.myshopify.com"
+API="2024-10"
+SECRETS="$HOME/Projects/secrets-manager/.env"
+DEV_THEME_ID="143933472819"          # "Steves Version 5.1" (dev) — verified this session
+SNIPPET="snippets/dw-boost-overrides.liquid"
+
+TOK="${THEME_TOKEN:-$(grep -hE '^SHOPIFY_THEME_TOKEN=' "$SECRETS" 2>/dev/null | head -1 | cut -d= -f2- | tr -d '"'"'"' ')}"
+[ -z "$TOK" ] && { echo "No theme token (SHOPIFY_THEME_TOKEN in secrets)."; exit 1; }
+echo "token …${TOK: -4}"
+
+mkdir -p theme-backups
+python3 - "$STORE" "$API" "$TOK" "$DEV_THEME_ID" "$SNIPPET" "theme-backups" <<'PY'
+import sys, json, urllib.request, urllib.parse, urllib.error, datetime
+store, api, tok, dev_id, key, bkdir = sys.argv[1:7]
+H = {"X-Shopify-Access-Token": tok, "Content-Type": "application/json"}
+def req(url, method="GET", body=None):
+    r = urllib.request.Request(url, headers=H, method=method,
+                               data=json.dumps(body).encode() if body else None)
+    return json.load(urllib.request.urlopen(r))
+
+themes = req(f"https://{store}/admin/api/{api}/themes.json")["themes"]
+print("themes:")
+for t in themes: print("  ", t["id"], t["role"], "|", t["name"])
+theme = next((t for t in themes if str(t["id"]) == dev_id), None)
+if not theme:
+    cand = [t for t in themes if t["role"] != "main"]
+    theme = next((t for t in cand if t["role"] == "development"), cand[0] if cand else None)
+if not theme: print("No dev theme found."); sys.exit(1)
+if theme["role"] == "main": print("Refusing: resolved theme is LIVE/main."); sys.exit(1)
+tid = theme["id"]
+print(f'=== target: {tid} "{theme["name"]}" (role={theme["role"]}) — live untouched ===')
+
+q = urllib.parse.urlencode({"asset[key]": key})
+try:
+    cur = req(f"https://{store}/admin/api/{api}/themes/{tid}/assets.json?{q}")["asset"]["value"]
+except urllib.error.HTTPError as e:
+    print("snippet GET failed:", e.code, e.read().decode()[:300]); sys.exit(1)
+
+stamp = datetime.datetime.now().strftime("%Y%m%d-%H%M%S")
+bk = f"{bkdir}/dw-boost-overrides.dev-{tid}.{stamp}.bak"
+open(bk, "w").write(cur); print(f"backup: {bk} ({len(cur)} bytes)")
+
+BLOCK = """
+<!-- DW REC GRID FIX — You-May-Also-Like 2-up on mobile (2026-06-23) -->
+<style id="dw-rec-grid-fix">
+@media (max-width:768px){
+  .product-recommendations-wrapper--section .product-recommendations{
+    display:grid !important;
+    grid-template-columns:repeat(2,1fr) !important;
+    gap:16px 12px !important;
+    position:static !important;
+    height:auto !important;
+  }
+  .product-recommendations-wrapper--section .product-recommendations .product-list-item{
+    width:auto !important;float:none !important;position:static !important;
+    left:auto !important;top:auto !important;right:auto !important;margin:0 !important;
+  }
+  .product-recommendations-wrapper--section .product-recommendations .product-grid-masonry-sizer{display:none !important}
+}
+</style>
+"""
+
+import re
+marker_re = re.compile(r"\n?<!-- DW REC GRID FIX.*?</style>\n?", re.S)
+if marker_re.search(cur):
+    new = marker_re.sub("\n" + BLOCK, cur, count=1); action = "replaced-in-place"
+else:
+    new = cur.rstrip() + "\n" + BLOCK; action = "appended"
+
+if new == cur:
+    print("no change needed (already current)."); sys.exit(0)
+
+put = req(f"https://{store}/admin/api/{api}/themes/{tid}/assets.json", "PUT",
+          {"asset": {"key": key, "value": new}})
+print(f"PUT ok — {action}, snippet now {len(new)} bytes")
+
+# verify read-after-write
+ver = req(f"https://{store}/admin/api/{api}/themes/{tid}/assets.json?{q}")["asset"]["value"]
+ok = "dw-rec-grid-fix" in ver and "repeat(2,1fr)" in ver
+print("verify:", "OK — fix present in live snippet asset" if ok else "WARN — not found on re-read")
+print(f"preview: https://{store.replace('.myshopify.com','')}.myshopify.com/products/?preview_theme_id={tid}")
+print(f"PREVIEW_THEME_ID={tid}")
+PY
\ No newline at end of file

← c85040c5 Add reconciled single-path memo for the 5 collection fixes:  ·  back to Designer Wallcoverings  ·  fix(theme): unhide DW density/grid slider on collection page 8eb976d7 →