← back to Secrets Manager
deploy-collection-faqs.py
88 lines
#!/usr/bin/env python3
"""
deploy-collection-faqs.py — set a custom.faq JSON metafield on the top category
collections. The live theme's dw-collection-hero.liquid already renders this metafield
as a visible FAQ + FAQPage JSON-LD, so this alone takes each page ~60 -> ~85+.
Grounded in each collection's real description + material facts. Private-label safe
(no source vendor names). Idempotent (skips a collection that already has the metafield
unless --force). Run:
! python3 ~/Projects/secrets-manager/deploy-collection-faqs.py # dry-run
! python3 ~/Projects/secrets-manager/deploy-collection-faqs.py --apply
"""
import re, json, sys, urllib.request
APPLY = '--apply' in sys.argv; FORCE = '--force' in sys.argv
env = open('/Users/macstudio3/Projects/secrets-manager/.env').read()
tok = re.search(r'^SHOPIFY_CONTENT_TOKEN=(.+)$', env, re.M).group(1).strip().strip('"').strip("'")
S = "designer-laboratory-sandbox.myshopify.com"; A = "2024-10"
def api(p, method="GET", body=None):
data = json.dumps(body).encode() if body else None
r = urllib.request.Request(f"https://{S}/admin/api/{A}/{p}", data=data, method=method,
headers={"X-Shopify-Access-Token": tok, "Content-Type": "application/json"})
return json.load(urllib.request.urlopen(r, timeout=30))
Q = lambda q, a: {"q": q, "a": a}
FAQS = {
287331975219: [ # grasscloth-wallpapers
Q("What is grasscloth wallcovering?", "Grasscloth is a natural-fiber wallcovering handwoven from grasses, jute, hemp, sisal and similar sustainable fibers. Its organic texture adds depth and tactile richness that paint cannot replicate."),
Q("What rooms suit grasscloth?", "It shines as a feature or accent wall in dining rooms, bedrooms, studies, and entries. In high-moisture or high-scrub areas, treat it as a feature wall or choose a coated natural, since unsealed grasscloth is more delicate than vinyl."),
Q("Does grasscloth have color and seam variation?", "Yes. Because it is woven from real plant fibers, subtle shading and visible seams between panels are inherent to the material and part of its handcrafted appeal. Order all the yardage you need from one dye lot."),
Q("Can I order grasscloth samples first?", "Yes. Designer Wallcoverings offers up to 10 free samples so you can check the weave and colorway in your own light before ordering."),
],
95011799105: [ # faux-leather
Q("What is faux leather wallcovering?", "Faux leather is a vinyl wallcovering engineered to mimic the look and feel of genuine leather. It is cruelty-free and more sustainable since it is not derived from animal products."),
Q("Is faux leather good for high-traffic or commercial spaces?", "Yes. Its enhanced durability makes it well suited to high-traffic and commercial areas where real leather would wear, while keeping a luxurious leather appearance."),
Q("How do you clean faux leather wallcovering?", "The vinyl surface wipes clean with a damp cloth, which is part of why it performs so well in busy residential and commercial interiors."),
Q("Can I order samples before buying?", "Yes. Designer Wallcoverings offers up to 10 free samples so you can compare grain and color in your space."),
],
79865839728: [ # flocked-velvet-wallpaper-collection
Q("What is flocked velvet wallcovering?", "Flock wallcovering was originally created to imitate expensive cut-velvet hangings, using fibers applied to an adhesive-coated ground to form a raised, velvet-like texture. Today the pile is made from synthetic fibers such as polyester, nylon, or rayon."),
Q("What look does flocked velvet create?", "A tactile, dimensional, luxurious surface with a soft raised pattern — ideal for formal rooms, dining rooms, and dramatic feature walls where you want depth and richness."),
Q("How do you care for flocked wallcovering?", "Treat the pile gently: dust lightly and avoid abrasion or heavy scrubbing so the raised velvet texture stays crisp."),
Q("Can I order flocked velvet samples?", "Yes. Designer Wallcoverings offers up to 10 free samples so you can feel the pile and see the colorway before committing."),
],
79865512048: [ # cork
Q("What is cork wallcovering?", "Cork wallcovering is made from the bark of the cork oak tree. It offers a warm, earthy texture with natural variation in pattern and color that makes every panel distinctive."),
Q("Is cork wallcovering sustainable?", "Yes. Cork is harvested from the bark of the tree without cutting it down, making it a renewable, eco-friendly surface."),
Q("What rooms suit cork?", "Cork works beautifully as a feature wall in studies, offices, bedrooms, and living spaces, and its natural structure also helps soften sound in a room."),
Q("Can I order cork samples first?", "Yes. Designer Wallcoverings offers up to 10 free samples so you can see the natural texture and tone in your own light."),
],
93443981377: [ # faux-silk
Q("What is faux silk wallcovering?", "Faux silk captures the soft luster and refined drape of real silk in a more durable, easier-care material — the elegance of silk without its fragility."),
Q("What look does faux silk create?", "A gentle sheen and quiet luxury that suits bedrooms, dining rooms, and formal living spaces where you want a soft, light-catching backdrop."),
Q("Is faux silk more durable than real silk?", "Yes. It is engineered to resist the wear and delicacy of genuine silk while keeping the same refined, lustrous appearance."),
Q("Can I order samples before buying?", "Yes. Designer Wallcoverings offers up to 10 free samples so you can check the sheen and color against your furnishings."),
],
94741528641: [ # metallic-vinyl
Q("What is metallic vinyl wallcovering?", "Metallic vinyl combines a reflective metallic finish with a durable vinyl surface, creating a luminous wall that catches and changes with the light."),
Q("What rooms suit metallic vinyl?", "It makes a striking feature or accent wall in powder rooms, dining rooms, entries, and commercial spaces, where the reflective sheen adds depth and drama."),
Q("Is metallic vinyl durable and cleanable?", "Yes. As a vinyl wallcovering it is scrubbable and hard-wearing, well suited to both residential feature walls and high-traffic commercial interiors."),
Q("Can I order metallic vinyl samples?", "Yes. Designer Wallcoverings offers up to 10 free samples so you can see how the metallic finish reads in your lighting."),
],
294320046131: [ # novasuede-microfiber-suede
Q("What is Novasuede?", "Novasuede is a premium microfiber suede wallcovering with the soft, tactile look of real suede in a durable, cleanable material engineered for walls."),
Q("Where is Novasuede used?", "It creates a luxurious, upholstered-look feature wall in residential and commercial interiors — a rich, soft surface that reads far more expensive than paint."),
Q("How do you care for Novasuede?", "As a microfiber it is more durable and cleanable than natural suede, holding its soft nap in everyday interiors."),
Q("Can I order Novasuede samples first?", "Yes. Designer Wallcoverings offers up to 10 free samples so you can feel the suede texture and check the colorway in your space."),
],
}
changed = skipped = 0
for cid, faq in FAQS.items():
existing = api(f"collections/{cid}/metafields.json?namespace=custom&key=faq")['metafields']
if existing and not FORCE:
print(f" {cid}: custom.faq already set — skip"); skipped += 1; continue
if not APPLY:
print(f" {cid}: would set custom.faq ({len(faq)} Q&A)"); continue
body = {"metafield": {"namespace": "custom", "key": "faq", "type": "json",
"value": json.dumps(faq, ensure_ascii=False)}}
res = api(f"collections/{cid}/metafields.json", "POST", body)
ok = 'metafield' in res
print(f" {cid}: {'SET ✓' if ok else 'FAIL ' + json.dumps(res)[:150]} ({len(faq)} Q&A)")
changed += ok
print(f"\n{'APPLIED' if APPLY else 'DRY-RUN'} — set={changed} skipped={skipped} of {len(FAQS)} collections")
if APPLY:
print("Verify (allow storefront cache): https://designerwallcoverings.com/collections/grasscloth-wallpapers")