Skip to main content

Delivery
API

The APIs for interacting with delivery and shipping options.

Tip

Not all extension targets implement all APIs. Check the documentation for the extension target you are using to see which APIs are available.

The base API object provided to purchase, and customer-account.order-status extension targets.

StatefulRemoteSubscribable<[]>
required

A list of delivery groups containing information about the delivery of the items the customer intends to purchase.

Was this section helpful?

Returns the full expanded details of a delivery group and automatically re-renders your component when that delivery group changes.

required

DeliveryGroupDetails

targetedCartLines
[]

The cart lines associated to the delivery group.

deliveryOptions
[]

The delivery options available for the delivery group.

groupType

The type of the delivery group.

isDeliveryRequired
boolean

Whether delivery is required for the delivery group.

selectedDeliveryOption

The selected delivery option for the delivery group.

Was this section helpful?

Anchor to useDeliveryGroups
useDeliveryGroups()

Returns the current delivery groups for the checkout, and automatically re-renders your component when delivery address or delivery option selection changes.

[]
Was this section helpful?

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.

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?

Anchor to useShippingOptionTarget
useShippingOptionTarget()

Returns the shipping option the extension is attached to.

{ shippingOptionTarget: ; isTargetSelected: boolean; }
Was this section helpful?

This API object is provided to extensions registered for the purchase.checkout.pickup-point-list.render-after and purchase.checkout.pickup-point-list.render-after extension target.

Anchor to isLocationFormVisible
isLocationFormVisible
StatefulRemoteSubscribable<boolean>
required

Whether the customer location input form is shown to the buyer.

Was this section helpful?

Anchor to pickuplocationlistapiPickupLocationListApi

This API object is provided to extensions registered for the purchase.checkout.pickup-location-list.render-after and purchase.checkout.pickup-location-list.render-after extension target.

Anchor to isLocationFormVisible
isLocationFormVisible
StatefulRemoteSubscribable<boolean>
required

Whether the customer location input form is shown to the buyer.

Was this section helpful?

Delivery group

React

import {
reactExtension,
Banner,
useDeliveryGroups,
useDeliveryGroup,
} from '@shopify/ui-extensions-react/checkout';

export default reactExtension(
'purchase.checkout.block.render',
() => <Extension />,
);

function Extension() {
const deliveryGroups = useDeliveryGroups();
const {
selectedDeliveryOption,
targetedCartLines,
} = useDeliveryGroup(deliveryGroups[0]);

return (
<Banner>
Selected delivery option:{' '}
{selectedDeliveryOption?.title}
</Banner>
);
}

Learn how to use the API with JavaScript (JS) and React. See React Hooks for all available hooks.

Was this section helpful?

Reading the selected shipping option

import {
reactExtension,
Text,
useSubscription,
useShippingOptionTarget,
} from '@shopify/ui-extensions-react/checkout';

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

function Extension() {
const {shippingOptionTarget, isTargetSelected} =
useShippingOptionTarget();
const title = shippingOptionTarget.title;

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