Skip to main content

ShippingOptionItemApi

Requires access to protected customer data for some properties.

This API object is provided to extensions registered for the purchase.checkout.shipping-option-item.render-after or purchase.checkout.shipping-option-item.details.render extension targets.

It extends the StandardApi, provides a target object with information about the shipping method the extension is attached to, and a isTargetSelected boolean indicating whether the shipping method is currently selected in the UI.

See the StandardApi examples for more information on how to use the API.

StatefulRemoteSubscribable<>
required

The shipping option the extension is attached to.

StatefulRemoteSubscribable<boolean>
required

Whether the shipping option the extension is attached to is currently selected in the UI.

Was this section helpful?
import {
reactExtension,
Text,
useApi,
useSubscription,
} from '@shopify/ui-extensions-react/checkout';

export default reactExtension(
'purchase.checkout.shipping-option-item.render-after',
() => <Extension />,
);

function Extension() {
const {target, isTargetSelected} =
useApi<'purchase.checkout.shipping-option-item.render-after'>();
const shippingOption = useSubscription(target);
const title = shippingOption?.title;

const selected = useSubscription(
isTargetSelected,
);

return (
<Text>
Shipping method: {title} is{' '}
{selected ? '' : 'not'} selected.
</Text>
);
}