Product APIAPIs
APIs
The Product API provides an extension with data about the current Product.
Supporting targets
Anchor to productapiProductApi
number
required
The unique identifier for the product.
Anchor to variantId
variantId
number
required
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.
import React from 'react';
import {
Text,
Screen,
ScrollView,
Navigator,
reactExtension,
useApi,
} from '@shopify/ui-extensions-react/point-of-sale';
const Modal = () => {
const api = useApi<'pos.product-details.action.render'>();
return (
<Navigator>
<Screen name="ProductApi" title="Product Api">
<ScrollView>
<Text>{`Product ID: ${api.product.id}`}</Text>
</ScrollView>
</Screen>
</Navigator>
);
};
export default reactExtension('pos.product-details.action.render', () => (
<Modal />
));