Skip to main content

StandardApi

Requires access to protected customer data for some properties.

This base API object is provided to all extension targets.

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

Anchor to analytics
analytics
required

Methods for interacting with Web Pixels, such as emitting an event.

Anchor to appliedGiftCards
appliedGiftCards
StatefulRemoteSubscribable<[]>
required

Gift Cards that have been applied to the checkout.

Anchor to appMetafields
appMetafields
StatefulRemoteSubscribable<[]>
required

The metafields requested in the shopify.extension.toml file. These metafields are updated when there's a change in the merchandise items being purchased by the customer.

Requires access to protected customer data.

Tip

Cart metafields are only available on carts created via the Storefront API version 2023-04 or later.*

Anchor to attributes
attributes
StatefulRemoteSubscribable<[] | undefined>
required

Custom attributes left by the customer to the merchant, either in their cart or during checkout.

Anchor to availablePaymentOptions
availablePaymentOptions
StatefulRemoteSubscribable<[]>
required

All available payment options.

Anchor to buyerJourney
buyerJourney
required

Provides details on the buyer's progression through the checkout.

See buyer journey examples for more information.

Anchor to checkoutSettings
checkoutSettings
StatefulRemoteSubscribable<>
required

Settings applied to the buyer's checkout.

required

Details on the costs the buyer will pay for this checkout.

Anchor to deliveryGroups
deliveryGroups
StatefulRemoteSubscribable<[]>
required

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

Anchor to discountCodes
discountCodes
StatefulRemoteSubscribable<[]>
required

A list of discount codes currently applied to the checkout.

Anchor to discountAllocations
discountAllocations
StatefulRemoteSubscribable<[]>
required

Discounts that have been applied to the entire cart.

Anchor to extension
extension
<Target>
required

Meta information about the extension.

required

Utilities for translating content and formatting values according to the current localization of the checkout.

See localization examples for more information.

Anchor to lines
lines
StatefulRemoteSubscribable<[]>
required

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

Anchor to localization
localization
required

Details about the location, language, and currency of the buyer. For utilities to easily format and translate content based on these details, you can use the i18n object instead.

Anchor to metafields
metafields
StatefulRemoteSubscribable<[]>
required

The metafields that apply to the current checkout.

Metafields are stored locally on the client and are applied to the order object after the checkout completes.

These metafields are shared by all extensions running on checkout, and persist for as long as the customer is working on this checkout.

Once the order is created, you can query these metafields using the GraphQL Admin API

StatefulRemoteSubscribable<string | undefined>
required

A note left by the customer to the merchant, either in their cart or during checkout.

Anchor to query
query
<Data = unknown, Variables = { [key: string]: unknown; }>(query: string, options?: { variables?: Variables; version?: ; }) => Promise<{ data?: Data; errors?: GraphQLError[]; }>
required

Used to query the Storefront GraphQL API with a prefetched token.

See storefront api access examples for more information.

Anchor to selectedPaymentOptions
selectedPaymentOptions
StatefulRemoteSubscribable<[]>
required

Payment options selected by the buyer.

Anchor to sessionToken
sessionToken
required

Provides access to session tokens, which can be used to verify token claims on your app's server.

See session token examples for more information.

Anchor to settings
settings
StatefulRemoteSubscribable<>
required

The settings matching the settings definition written in the shopify.extension.toml file.

See settings examples for more information.

Note

When an extension is being installed in the editor, the settings will be empty until a merchant sets a value. In that case, this object will be updated in real time as a merchant fills in the settings.

required

Shop where the checkout is taking place.

Anchor to storage
storage
required

Key-value storage for the extension target.

required

Methods to interact with the extension's UI.

Anchor to version
version
required

The renderer version being used for the extension.

Anchor to buyerIdentity
buyerIdentity

Information about the buyer that is interacting with the checkout.

Requires access to protected customer data.

Anchor to shippingAddress
shippingAddress
StatefulRemoteSubscribable< | undefined>

The proposed buyer shipping address. During the information step, the address updates when the field is committed (on change) rather than every keystroke. An address value is only present if delivery is required. Otherwise, the subscribable value is undefined.

Requires access to protected customer data.

Anchor to extensionPoint
extensionPoint
Target
required

The identifier that specifies where in Shopify’s UI your code is being injected. This will be one of the targets you have included in your extension’s configuration file.

Deprecated

Deprecated as of version 2023-07, use extension.target instead.

Examples
import {
BlockStack,
reactExtension,
Text,
useApi,
} from '@shopify/ui-extensions-react/checkout';

// 1. Choose an extension target
export default reactExtension(
'purchase.checkout.block.render',
() => <Extension />,
);

function Extension() {
// 2. Use the extension API to gather context from the checkout and shop
const {cost, shop} = useApi();

// 3. Render a UI
return (
<BlockStack>
<Text>Shop name: {shop.name}</Text>
<Text>cost: {cost.totalAmount}</Text>
</BlockStack>
);
}
Was this page helpful?