← back to Designer Wallcoverings
limited-stock badge: fix dead-branch insertion (China-block {% if dw_is_blocked %} has its own </head>; insert before LAST </head>) + own-line CSS under qty-inline flex row
2f00d11c7e4b6a2cf405c1de8ec07f306925c82e · 2026-07-02 12:08:53 -0700 · Steve
Files touched
M shopify/push-limited-stock-badge-to-dev-theme.sh
Diff
commit 2f00d11c7e4b6a2cf405c1de8ec07f306925c82e
Author: Steve <steve@designerwallcoverings.com>
Date: Thu Jul 2 12:08:53 2026 -0700
limited-stock badge: fix dead-branch insertion (China-block {% if dw_is_blocked %} has its own </head>; insert before LAST </head>) + own-line CSS under qty-inline flex row
---
shopify/push-limited-stock-badge-to-dev-theme.sh | 11 +++++++++--
1 file changed, 9 insertions(+), 2 deletions(-)
diff --git a/shopify/push-limited-stock-badge-to-dev-theme.sh b/shopify/push-limited-stock-badge-to-dev-theme.sh
index 115d888e..46156512 100755
--- a/shopify/push-limited-stock-badge-to-dev-theme.sh
+++ b/shopify/push-limited-stock-badge-to-dev-theme.sh
@@ -62,6 +62,9 @@ BLOCK = r"""
border:1px solid #8a5a00;color:#8a5a00;background:#fff8ec;font:inherit;
font-size:12px;letter-spacing:.08em;text-transform:uppercase;border-radius:2px;
line-height:1.4;white-space:nowrap}
+ /* qty-inline makes .product__price a flex row — keep the badge on its own
+ line below the price+qty row instead of crowding between them */
+ .dw-price-qty-row .dw-limited-stock-badge{order:5;flex-basis:100%;max-width:max-content}
</style>
<script>
(function(){
@@ -95,8 +98,12 @@ BLOCK = r"""
# strip any prior injected badge block (idempotent re-run), then insert
src = re.sub(r"\n*\{%-?\s*if template contains 'product'\s*-?%\}\s*<!-- DW: limited-stock badge.*?<!-- /DW limited-stock badge -->\s*\{%-?\s*endif\s*-?%\}\n*",
"\n", src, flags=re.S)
-if "</head>" in src:
- src = src.replace("</head>", BLOCK + "\n</head>", 1); changes.append("limited-stock-badge-v1")
+# theme.liquid opens with a {% if dw_is_blocked %} China-block branch that has
+# its OWN </head>; inserting before the FIRST </head> lands in that never-
+# rendered branch. Insert before the LAST </head> (the real page).
+pos = src.rfind("</head>")
+if pos != -1:
+ src = src[:pos] + BLOCK + "\n" + src[pos:]; changes.append("limited-stock-badge-v1")
else:
src = BLOCK + src; changes.append("limited-stock-badge-v1-prepended")
← 631ae2c3 PDP qty-inline: move quantity stepper to the right of the pr
·
back to Designer Wallcoverings
·
auto-save: 2026-07-02T12:48:04 (6 files) — pending-approval/ c180cdfd →