Product APIAPIs
APIs
The Product API provides an extension with data about the current Product.
Supporting targets
Anchor to productapiProductApi
- numberrequired
The unique identifier for the product.
- Anchor to variantIdvariantIdnumberrequired
The unique identifier for the product variant.
Was this section helpful?
Anchor to examplesExamples
Examples of using the Product API.
Anchor to example-retrieve-the-id-of-the-product.Retrieve the ID of the product.
Was this section helpful?
Retrieve the ID of the product.
jsx
import {render} from 'preact';
export default async () => {
render(<Extension />, document.body);
};
const Extension = () => {
return (
<s-navigator initial-screen-name="ProductApi">
<s-screen name="ProductApi" title="Product Api">
<s-scroll-box>
<s-text>Product ID: {shopify.product.id}</s-text>
</s-scroll-box>
</s-screen>
</s-navigator>
);
};
Examples
Retrieve the ID of the product.
jsx
import {render} from 'preact'; export default async () => { render(<Extension />, document.body); }; const Extension = () => { return ( <s-navigator initial-screen-name="ProductApi"> <s-screen name="ProductApi" title="Product Api"> <s-scroll-box> <s-text>Product ID: {shopify.product.id}</s-text> </s-scroll-box> </s-screen> </s-navigator> ); };