Skip to main content

Post-purchase extension points API


Post-purchase checkout extensions allow developers and Plus merchants to add a post-purchase page directly into the Shopify checkout. The page appears after the order is confirmed, but before the Order status page. Post-purchase checkout extensions can use the ShouldRender and Render extension points. For more information, refer to the post-purchase checkout extensions overview.

NameTypeDescription
Checkout::PostPurchase::RenderRenderExtension<PostPurchaseRenderApi<Imported>, AllComponents>The Render extension point is used to render the section in the post-purchase page. Also, it provides additional functionality, such as communicating with Shopify to add items to the initial purchase.
Checkout::PostPurchase::ShouldRender(api: PostPurchaseShouldRenderApi<Imported>) => PostPurchaseShouldRenderResult<Imported>The ShouldRender extension point is used to determine whether a post-purchase page should be shown to the customer. It also allows data to be pre-cached and used when the page renders.

Anchor to PostPurchaseShouldRenderApiPostPurchaseShouldRenderApi

Input given to the ShouldRender extension point (Checkout::PostPurchase::ShouldRender).

NameTypeDescription
inputDataInputDataInput data given to the extension point.
storageStorageGeneral purpose storage for extensions.

A type of extension point that is capable of rendering UI into Checkout natively. This type of extension point receives an object to manipulate the UI as its first argument, and additional data and methods as a second argument. The object that can manipulate the UI is referred to as a RemoteRoot, and is provided by the remote-ui library on which UI Extensions' rendering capabilities are built.

TypeDescription
(root: RemoteRoot<AllowedComponents, true>, input: Input): RenderResult<Input> | voidInput type for RenderExtension.

The output expected from the ShouldRender extension point.

NameTypeDescription
update?(input: Partial<Input<Autocomplete>>) => voidWhether the post-purchase page is requested.

Anchor to PostPurchaseRenderApiPostPurchaseRenderApi

Input given to the render extension point (Checkout::PostPurchase::Render).

NameTypeDescription
inputDataInputDataInput data given to the extension point.
storageStorageGeneral purpose storage for extensions.
calculateChangeset(changeset: Readonly<Changeset> | string) => Promise<CalculateChangesetUnprocessedResult | CalculateChangesetProcessedResult>Returns the calculations that would result from the provided changeset being applied. Used to provide cost-clarity for buyers.
applyChangeset(changeset: string, options: ApplyChangesetOptions<>) => Promise<ApplyChangesetResult>Requests a changeset to be applied to the initial purchase, and to charge the buyer with the difference in total price, if any.
done() => Promise<void>Indicates that the extension has finished running. Redirects customers to the Order status page.

Anchor to ApplyChangesetResultApplyChangesetResult

Requests a changeset to be applied to the initial purchase, and to charge the buyer with the difference in total price if any.

NameTypeDescription
errorsChangesetError[]Represents an error occurred while calculating or applying a changeset.
status"processed" | "partially_processed" | "unprocessed"An enum representing the result of attempting to apply or calculate a changeset.
changesetApplicationsRemainingnumberHow many changesets can still be applied to the initial purchase.

Anchor to ApplyChangesetOptionsApplyChangesetOptions

NameTypeDescription
buyerConsentToSubscriptions?boolean

Anchor to CalculateChangesetProcessedResultCalculateChangesetProcessedResult

Returns a CalculatedPurchase for processed changeset.

NameTypeDescription
errorsChangesetError[]Empty array of errors.
status"processed"Always returns processed.
calculatedPurchaseCalculatedPurchaseReturns CalculatedPurchase.

Represents the updated state of the initial purchase.

NameTypeDescription
subtotalPriceSetMoneyBag<>Updated total price of the purchase with discounts but before shipping, taxes, and tips.
totalPriceSetMoneyBag<>Updated final price of the purchase.
addedTaxLinesAddedTaxLine[]Array of AddedTaxLine.
updatedLineItemsUpdatedLineItem[]Array of UpdatedLineItem.
addedShippingLinesAddedShippingLine[]Array of AddedShippingLine.
totalOutstandingSetMoneyBag<>The amount left unpaid after the update.

Represents a shipping line that was added after a changeset was calculated.

NameTypeDescription
priceSetMoneyBag<>The shipping line price.
presentmentTitlestringThe customer facing line title.

Represents the updated state of a line item after a changeset has been calculated including any added line items.

NameTypeDescription
totalPriceSetMoneyBag<>The discounted total price.
priceSetMoneyBag<>The price per quantity
productIdnumberThe product ID.
variantIdnumberThe variant ID.
sellingPlanId?numberThe selling plan ID.
productHandlestringThe product slug in kebab-case.
quantitynumberHow many items are being purchased in this line.

Represents the information about the tax charged on the associated line item.

NameTypeDescription
priceSetMoneyBag<>The tax amount.
ratenumberThe tax rate to be applied.
titlestringThe name of the tax.

Anchor to CalculateChangesetUnprocessedResultCalculateChangesetUnprocessedResult

Returns an array of ChangesetError, when the changeset can't be processed.

NameTypeDescription
errorsChangesetError[]Array of errors.
status"unprocessed"Always returns unprocessed.
calculatedPurchase?neverNot returned for unprocessed result.

Represents an error occurred while calculating or applying a changeset.

NameTypeDescription
code"payment_required" | "insufficient_inventory" | "changeset_already_applied" | "unsupported_payment_method" | "invalid_request" | "server_error" | "buyer_consent_required" | "subscription_vaulting_error" | "subscription_contract_creation_error" | "subscription_no_shipping_address_error" | "subscription_limit_error" | "order_released_error"An error code corresponding to an error that occurred while calculating or applying a changeset. Useful for grouping errors that can be handled similarily.
messagestringThe error description.

A list of requested changes to be made to the initial purchase.

NameTypeDescription
changes(AddVariantChange | AddShippingLineChange | SetMetafieldChange | AddSubscriptionChange)[]A change request.

Anchor to AddSubscriptionChangeAddSubscriptionChange

Requests a subscription to be added to the initial purchase.

NameTypeDescription
type"add_subscription"A fixed value of "add_subscription".
variantIdnumberThe product variant to add.
sellingPlanIdnumberThe selling plan to apply.
initialShippingPricenumberThe shipping line price without taxes for the first shipping cycle.
recurringShippingPricenumberThe shipping line price without taxes for the recurring shipping cycles.
quantitynumberThe quantity of the specified variant.
shippingOptionShippingOptionAdditional information concerning shipping.
discount?ExplicitDiscountRefer to ExplicitDiscount.

NameTypeDescription
title?string
presentmentTitle?string

Requests to set a metafield on the initial purchase. If a metafield with the same namespace and key pair already exists, then its contents are replaced.

NameTypeDescription
keystringThe metafield key.
namespacestringThe metafield namespace.
valuestring | numberThe metafield value.
valueType"integer" | "string" | "json_string"The metafield value type.
type"set_metafield"A fixed value of "set_metafield".

Anchor to AddShippingLineChangeAddShippingLineChange

Requests a shipping line to be added to the initial purchase.

NameTypeDescription
type"add_shipping_line"A fixed value of "add_shipping_line".
pricenumberThe shipping line price without taxes.
title?stringThe merchant-facing line title.
presentmentTitle?stringThe buyer-facing line title.

Requests a variant to be added to the initial purchase.

NameTypeDescription
type"add_variant"A fixed value of "add_variant".
variantIdnumberThe product variant to add.
quantitynumberThe quantity of the specified variant.
discount?ExplicitDiscountRefer to ExplicitDiscount.

Requests to attach an explicit discount to a compatible change.

NameTypeDescription
valuenumberThe discount value.
valueType"percentage" | "fixed_amount"The discount type.
titlestringThe reason for adding the discount.

General-purpose, key-value browser storage for extensions.

NameTypeDescription
initialDataunknownData in the storage during the first load (read-only).
update(data: any) => Promise<void>Updates the storage to the value that it's given.

The data given as input to both extension points.

NameTypeDescription
extensionPointstringIdentifier for the extension point.
initialPurchasePurchaseInitial purchase.
localestringCheckout customer locale.
shopShopShop where the checkout/order is from.
tokenstringJWT representing the input_data payload. For more information, refer to JWT specification.
versionstringPost Purchase API version.

The shop where the extension is running.

NameTypeDescription
idnumberThe shop's unique identifier.
domainstringThe primary domain of the shop (ending with “.myshopify.com”).
metafieldsMetafield[]Only public listed metafields are available.

Represents the initial purchase's state when the extension is loaded.

NameTypeDescription
referenceIdstringInitial purchase's unique identifier.
customerId?stringThe unique identifier of the buyer.
destinationCountryCode?stringThe unique identifier of the country for shipping.
totalPriceSetMoneyBagThe total price of the purchase, including shipping, taxes and discounts.
lineItemsLineItem[]Items being purchased.

The items purchased.

NameTypeDescription
productProductProduct being purchased.
quantitynumberThe amount of items for the line.
totalPriceSetMoneyBag<>The total price of the line item, with line discounts.
sellingPlanId?numberThe selling plan's unique identifier

The product for purchase.

NameTypeDescription
idnumberThe product's unique identifier.
titlestringThe product title.
variantVariantVariant being purchased.
metafieldsMetafield<>[]Only public listed metafields are available.

The product variant for purchase.

NameTypeDescription
idnumberThe variant's unique identifier.
titlestringThe variant title.
metafieldsMetafield<>[]Only public listed metafields are available.

The metafields associated with a resource. You'll need to individually request which metafields you need in the configuration file.

NameTypeDescription
keystringThe metafield key.
namespacestringThe metafield namespace.
valuestring | numberThe metafield value.
valueType"integer" | "string" | "json_string"The metafield value type.

Represents an amount in both shop and presentment currencies.

NameTypeDescription
shopMoneyMoneyAmount in shop currency.
presentmentMoneyMoneyAmount in presentment currency.

A list of requested changes to be made to the initial purchase.

NameTypeDescription
amountstringThe actual amount.
currencyCodestringIn ISO 4217 format.

Was this page helpful?