Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import {ReferenceEntityTemplateSchema} from '@shopify/generate-docs';
import {generateCodeBlock} from '../helpers/generateCodeBlock';

const data: ReferenceEntityTemplateSchema = {
name: 'Cash Drawer API',
description: `
The Cash Drawer API is an API exposed to extensions for cash drawer functionality, specifically allowing UI extensions to control cash drawer operations.`,
isVisualComponent: false,
type: 'APIs',
definitions: [
{
title: 'CashDrawerApi',
description: 'Interface for handling cash drawer operations.',
type: 'CashDrawerApi',
},
],
category: 'APIs',
related: [],
examples: {
description: 'Examples of using the Cash Drawer API',
examples: [
{
codeblock: generateCodeBlock(
'Cash Drawer API',
'cash-drawer-api',
'default.example',
),
},
],
},
};

export default data;
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import {
Tile,
extension,
} from '@shopify/ui-extensions/point-of-sale';

export default extension(
'pos.home.tile.render',
(root, api) => {
const tile = root.createComponent(Tile, {
title: 'My app',
subtitle: 'Hello world!',
enabled: true,
onPress: () => {
api.cashDrawer.open();
},
});

root.append(tile);
},
);
2 changes: 2 additions & 0 deletions packages/ui-extensions/src/surfaces/point-of-sale/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ export type {
export type {StandardApi} from './render/api/standard/standard-api';
export type {ActionTargetApi} from './render/api/action-target-api/action-target-api';

export type {CashDrawerApi} from './render/api/cash-drawer-api/cash-drawer-api';

export type {
ConnectivityStateSeverity,
ConnectivityState,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
/**
* The Cash Drawer API in POS UI extensions includes select cash drawer functionality.
*/
export interface CashDrawerApi {
/**
* Opens the connected cash drawer.
*
* @returns Void
*
*/
open(): Promise<void>;
}