Skip to main content

Build an inline order status UI extension

Inline extensions are UI extensions that render after, before, or within a piece of UI, at static or block extension targets, on customer account pages.

In this tutorial, you'll build two extensions for the Order status page: one that displays the loyalty points earned for a specific order, and one that encourages customers to write a review.

Inline extension OSP

In this tutorial, you'll learn how to do the following tasks:

  • Create inline extensions that display on the Order status page.
  • Use multiple extension targets to display different interfaces to the customer.
  • Run the extensions locally and test them on a development store.

Requirements

Project

Anchor to Create a customer account UI extension for the order status block targetCreate a customer account UI extension for the order status block target

To create a customer account UI extension, you can use Shopify CLI, which generates starter code for building your extension and automates common development tasks.

  1. Navigate to your app directory:

    Terminal

    cd <directory>
  2. Run the following command to create a new customer account UI extension:

    Terminal

    shopify app generate extension --template customer_account_ui --name customer-account-ui-extension
  3. Select a language for your extension. You can choose from TypeScript, JavaScript, TypeScript React, or JavaScript React.

    Tip

    TypeScript or JavaScript is suitable for smaller projects that require a more straightforward API. TypeScript React or JavaScript React is suitable when you want an easy model for mapping state updates to UI updates. With JavaScript or TypeScript, you need to map state updates yourself. This process is similar to writing an application targeting the DOM, versus using react-dom.

    You should now have a new extension directory in your app's directory. The extension directory includes the extension script at src/index.{file-extension}. The following is an example directory structure:

    Customer account UI extension file structure

    └── my-app
    └── extensions
    └── my-customer-account-ui-extension
    ├── src
    │ └── CustomerAccount.jsx OR CustomerAccount.js // The index page of the customer account UI extension
    ├── locales
    │ ├── en.default.json // The default locale for the customer account UI extension
    │ └── fr.json // The locale file for non-regional French translations
    ├── shopify.extension.toml // The config file for the customer account UI extension
    └── package.json
  1. Start your development server to build and preview your app:

    Terminal

    shopify app dev

    To learn about the processes that are executed when you run dev, refer to the Shopify CLI command reference.

  2. Press p to open the developer console. In the developer console page, click on the preview link for your extension.

Anchor to Set up the target for your order status block extensionSet up the target for your order status block extension

Set up the target for your customer account UI extension. Extension targets control where extensions render.

The example code uses the following target:

customer-account.order-status.block.render

In your extension's configuration file, for the customer-account-order-status-block-render target create an [[extensions.targeting]] section with the following information:

target: An identifier that specifies where you're injecting code into Shopify (the extension target).

module: The path to the file that contains the extension code.

Create a file in your extension's src directory for the target. In this example, you'll create a file for the order status block extension. Make sure that the name of the files match the module paths that you specified.


shopify.extension.toml is the configuration file for your extension.

Info

Whenever you edit your extension configuration file, you need to restart your server for the changes to take effect.

Anchor to Create a customer account UI extension for the order status fulfillment static extension targetCreate a customer account UI extension for the order status fulfillment static extension target

To create a customer account UI extension, you can use Shopify CLI, which generates starter code for building your extension and automates common development tasks.

  1. Navigate to your app directory:

    Terminal

    cd <directory>
  2. Run the following command to create a new customer account UI extension:

    Terminal

    shopify app generate extension --template customer_account_ui --name customer-account-ui-extension
  3. Select a language for your extension. You can choose from TypeScript, JavaScript, TypeScript React, or JavaScript React.

    Tip

    TypeScript or JavaScript is suitable for smaller projects that require a more straightforward API. TypeScript React or JavaScript React is suitable when you want an easy model for mapping state updates to UI updates. With JavaScript or TypeScript, you need to map state updates yourself. This process is similar to writing an application targeting the DOM, versus using react-dom.

    You should now have a new extension directory in your app's directory. The extension directory includes the extension script at src/index.{file-extension}. The following is an example directory structure:

    Customer account UI extension file structure

    └── my-app
    └── extensions
    └── my-customer-account-ui-extension
    ├── src
    │ └── CustomerAccount.jsx OR CustomerAccount.js // The index page of the customer account UI extension
    ├── locales
    │ ├── en.default.json // The default locale for the customer account UI extension
    │ └── fr.json // The locale file for non-regional French translations
    ├── shopify.extension.toml // The config file for the customer account UI extension
    └── package.json
  1. Start your development server to build and preview your app:

    Terminal

    shopify app dev

    To learn about the processes that are executed when you run dev, refer to the Shopify CLI command reference.

  2. Press p to open the developer console. In the developer console page, click on the preview link for your extension.

Anchor to Set up the target for your order status static extensionSet up the target for your order status static extension

Set up the target for your customer account UI extension. Targets control where your extension renders in the customer account flow.

The example code uses the following target:

customer-account.order-status.fulfillment-details.render-after

In your extension's configuration file, for the customer-account-order-status-fulfillment-details-render-after extension target, create an [[extensions.targeting]] section with the following information:

target: An identifier that specifies where you're injecting code into Shopify. module: The path to the file that contains the extension code.

Create a file in your extension's src directory for the target. In this example, you'll create a file for the order status block extension. Make sure that the name of the files match the module paths that you specified.


shopify.extension.toml is the configuration file for your extension.

Info

Whenever you edit your extension configuration file, you need to restart your server for the changes to take effect.

Anchor to Build the order status block extensionBuild the order status block extension

Using checkout UI extension components, add a banner to the Order status page to let the customer know how many points they've earned for the order.

In this example, the number of points is hardcoded. In a production-ready application, you'd retrieve this information by making an API call to your server, or to the Customer Account API if you're storing loyalty points in metafields.

Similar to the profile block, the example adds a View rewards link, which you could link to a full-page extension that displays the customer's rewards information in more detail.


Customer account UI extensions are limited to specific UI components exposed by the platform for security reasons. You can use checkout UI components and customer account UI components to create a UI that feels seamless within the customer accounts experience, and that inherits a merchant's brand settings.

Anchor to Build the order status static extensionBuild the order status static extension

Add some content inside the fulfillment details card to encourage customers to provide a review in exchange for loyalty points.

While this is outside of the scope of this tutorial, the example includes a Write a review button, which you could link to modal that contains a form for the customer to submit their review.


Anchor to Preview the extensionPreview the extension

Preview your extension to make sure that it works as expected.

Run the Shopify CLI dev command to build your app and preview it on your development store.

  1. In a terminal, navigate to your app directory.

  2. Either start or restart your server to build and preview your app:

    Terminal

    shopify app dev
  3. If prompted, select a development store.

  4. Press p to open the developer console.

  5. In the developer console page, click the preview link for one of your extension targets.

The customer accounts experience opens.

Navigate to the Order status page of a customer account to see your extension in action.


Inline extension OSP

Info

By default, block extensions are placed in the first available placement reference.

In a production-ready situation, merchants move this extension to the right location using the checkout editor. To test this, you can add the ?placement-reference=ORDER_SUMMARY1 query parameter to the URL of the Order status page. This moves the extension the next placement reference on the page.

Learn more about testing UI extensions in different placement references.

Was this page helpful?