order view button
The order view button extension point adds a customized button to the order view page in the Adobe Commerce Admin. When a merchant opens an order, Commerce renders your buttons alongside the built-in ones.
Example customization
The following example creates a Delete button that confirms before opening an iframe, and a Create Return button that opens an iframe with no confirmation.
adminUi: {
order: {
viewButtons: [
{
id: 'order-custom-view-button::delete-order',
label: 'Delete',
type: 'view',
path: '#/delete-order',
confirm: {
message: 'Are you sure you want to proceed to delete order?',
},
level: 0,
sortOrder: 80,
notifications: {
success: 'Order deleted successfully',
error: 'Failed to delete order',
},
},
{
id: 'order-custom-view-button::create-return',
label: 'Create Return',
type: 'view',
path: '#/create-return',
level: 0,
sortOrder: 80,
notifications: {
success: 'Return request created successfully',
error: 'Failed to create return request',
},
},
],
},
},
How it works
- A merchant opens an order in the Commerce Admin.
- Commerce renders the buttons declared in
viewButtonsalongside the built-in ones. - For
viewbuttons, clicking the button opens the configuredpathinside an iframe; the app reads the order ID viauseOrderViewButtonContext()and can close the iframe withuseHostConnection(). - For
workerbuttons, Commerce calls the configuredruntimeActiondirectly with the order ID. No iframe is shown. - If the button declares
notifications, Commerce shows a success or error banner once the action completes.
import { useOrderViewButtonContext } from "@adobe/aio-commerce-lib-admin-ui/web";
function OrderViewButtonPage() {
const { data, error } = useOrderViewButtonContext();
if (error) return null;
return <span>{data.orderId}</span>;
}
Parameters
Field
Type
Required
Description
idstring
Yes
A unique ID to identify the button. The recommended format is
<extensionId>::<buttonName>.labelstring
Yes
The label of the button.
descriptionstring
No
A description of the button, used when the button is ACL-protected.
typestring
Yes
Either
view (opens path in an iframe) or worker (calls runtimeAction directly, with no UI).pathstring
Only for
type: 'view'The relative path in your App Builder app to open in the iframe. The order ID is made available via
useOrderViewButtonContext().runtimeActionstring
Only for
type: 'worker'The runtime action to call, in
<package>/<action> format from your app.config.yaml runtime manifest.confirm.titlestring
No
The title of the confirmation dialog.
confirm.messagestring
No
The message displayed on the confirmation dialog.
levelinteger
No
The position of the button in the toolbar. One of
-1 (left), 0 (center), or 1 (right).sortOrderinteger
No
The order in which the button is placed within its
level.notifications.successstring
No
The banner message shown when the action completes successfully.
notifications.errorstring
No
The banner message shown when the action fails.
sandboxPermissionsarray of strings
No
Applies additional restrictions to the content within an iFrame. Only relevant when
type is view. Allowed values are allow-downloads, allow-modals, and allow-popups.timeoutinteger
No
The timeout, in seconds, for the request sent to your runtime action. Only relevant when
type is worker.aclProtectedboolean
No
When
true, gates the button behind a dedicated Commerce ACL resource scoped to your app. See ACL protection. The default value is false.Sample code
The Adobe Commerce Extensibility Code Samples repository demonstrates how to customize the order view button.