Skip to content

Instantly share code, notes, and snippets.

@junaidkbr
Last active January 2, 2025 15:24
Show Gist options
  • Save junaidkbr/88f0677a7e2ca3e1c8b0a38768553cf1 to your computer and use it in GitHub Desktop.
Save junaidkbr/88f0677a7e2ca3e1c8b0a38768553cf1 to your computer and use it in GitHub Desktop.
Open Shopify editor for Shopify resources (page, product, collection, article) from the frontend
const shopName = window.Shopify.shop.replace(".myshopify.com", "");
const { rtyp: resourceType, rid: resourceId } = window.__st;
if (["product", "collection", "page", "article"].includes(resourceType)) {
const url = `https://admin.shopify.com/store/${shopName}/${resourceType}s/${resourceId}`;
window.open(url, "_blank");
} else {
alert("Unsupported resource type");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment