Cart Line Item APIAPIs
APIs
The Cart Line Item API provides an extension with data about the current Cart Line Item.
Supporting targets
Anchor to cartlineitemapiCartLineItemApi
Anchor to cartLineItem
cartLineItem
required
The selected line item in the merchant’s current cart.
Was this section helpful?
Anchor to examplesExamples
Examples of using the Cart Line Item API.
Anchor to example-retrieve-the-id-of-the-cart-line-item.Retrieve the ID of the cart line item.
Was this section helpful?
Retrieve the ID of the cart line item.
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.cart.line-item-details.action.render'>();
return (
<Navigator>
<Screen name="CartLineItemApi" title="Cart Line Item Api">
<ScrollView>
<Text>{`Cart Line Item ID: ${api.cartLineItem.id}`}</Text>
</ScrollView>
</Screen>
</Navigator>
);
};
export default reactExtension(
'pos.cart.line-item-details.action.render',
() => <Modal />,
);