← back to Designer Wallcoverings
deploy: insert before the LAST </body> (theme.liquid has an earlier dead one) + ALLOW_LIVE gate for live pushes
29132a2f97b224618391ded2c727fe10a93d454c · 2026-06-29 12:35:50 -0700 · Steve Abrams
Files touched
M shopify/push-min-qty-to-dev-theme.py
Diff
commit 29132a2f97b224618391ded2c727fe10a93d454c
Author: Steve Abrams <steve@designerwallcoverings.com>
Date: Mon Jun 29 12:35:50 2026 -0700
deploy: insert before the LAST </body> (theme.liquid has an earlier dead one) + ALLOW_LIVE gate for live pushes
---
shopify/push-min-qty-to-dev-theme.py | 13 ++++++++-----
1 file changed, 8 insertions(+), 5 deletions(-)
diff --git a/shopify/push-min-qty-to-dev-theme.py b/shopify/push-min-qty-to-dev-theme.py
index 1157c5fd..9658f813 100644
--- a/shopify/push-min-qty-to-dev-theme.py
+++ b/shopify/push-min-qty-to-dev-theme.py
@@ -38,8 +38,9 @@ if want_id:
else:
match = ([t for t in themes if t["name"] == TARGET_NAME]
or [t for t in themes if t["role"] == "development"])
-match = [t for t in match if t["role"] != "main"] # never the live/main theme
-if not match: sys.exit("Target dev theme not found (live untouched).")
+if not os.environ.get("ALLOW_LIVE"):
+ match = [t for t in match if t["role"] != "main"] # default: never the live/main theme
+if not match: sys.exit("Target theme not found (set ALLOW_LIVE=1 to target the live theme).")
theme = match[0]; tid = theme["id"]
print(f'=== target: {tid} "{theme["name"]}" (role={theme["role"]}) — live untouched ===')
@@ -54,10 +55,12 @@ bk = os.path.join(bkdir, f"theme.liquid.minqty.{tid}.{stamp}.bak")
open(bk, "w", encoding="utf-8").write(cur)
print("backup:", bk, f"({len(cur)} bytes)")
-# remove any prior injected block (idempotent), then insert before </body>
+# remove any prior injected block (idempotent), then insert before the LAST </body>
+# (theme.liquid has an earlier dead </body> in a fallback block — must use the real one)
cleaned = re.sub(re.escape(START) + r".*?" + re.escape(END) + r"\n?", "", cur, flags=re.S)
-if "</body>" in cleaned:
- newsrc = cleaned.replace("</body>", block + "</body>", 1)
+idx = cleaned.rfind("</body>")
+if idx != -1:
+ newsrc = cleaned[:idx] + block + cleaned[idx:]
else:
newsrc = cleaned + block
if newsrc == cur:
← 02af8f98 product min-qty: recurring re-assert beats theme's variant-c
·
back to Designer Wallcoverings
·
auto-save: 2026-06-29T12:49:09 (5 files) — pending-approval/ ff9d3483 →