Last active
January 2, 2025 15:24
-
-
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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