Skip to main content
Migrate to Polaris

Version 2025-07 is the last API version to support React-based UI components. Later versions use web components, native UI elements with built-in accessibility, better performance, and consistent styling with Shopify's design system. Check out the migration guide to upgrade your extension.

Cart Instructions API

Instructions used to create the checkout.

The base API object provided to purchase extension targets.

Anchor to instructions
instructions
StatefulRemoteSubscribable<>
required

The cart instructions used to create the checkout and possibly limit extension capabilities.

These instructions should be checked prior to performing any actions that may be affected by them.

For example, if you intend to add a discount code via the applyDiscountCodeChange method, check discounts.canUpdateDiscountCodes to ensure it's supported in this checkout.

Caution

As of version 2024-07, UI extension code must check for instructions before calling select APIs in case those APIs are not available. See the update guide for more information.

Anchor to useInstructions
useInstructions()

Returns the cart instructions used to create the checkout and possibly limit extension capabilities.

CartInstructions

attributes

Cart instructions related to cart attributes.

delivery

Cart instructions related to delivery.

discounts

Cart instructions related to discounts.

lines

Cart instructions related to cart lines.

metafields

Cart instructions related to metafields.

notes

Cart instructions related to notes.

Examples
import {
Banner,
Button,
useApplyDiscountCodeChange,
useInstructions,
reactExtension,
} from '@shopify/ui-extensions-react/checkout';

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

function Extension() {
const applyDiscountCodeChange =
useApplyDiscountCodeChange();
const instructions = useInstructions();

if (
instructions.discounts.canUpdateDiscountCodes
) {
return (
<Button
onPress={() =>
applyDiscountCodeChange({
type: 'addDiscountCode',
code: 'FREE_SHIPPING',
})
}
>
Apply your loyalty discount
</Button>
);
} else {
return (
<Banner status="warning">
Loyalty discounts are unavailable
</Banner>
);
}
}
Was this page helpful?