Skip to content

Commit 4db33cd

Browse files
committed
implement cash drawer api
1 parent d381ac2 commit 4db33cd

File tree

4 files changed

+67
-0
lines changed

4 files changed

+67
-0
lines changed
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
import {ReferenceEntityTemplateSchema} from '@shopify/generate-docs';
2+
import {generateCodeBlock} from '../helpers/generateCodeBlock';
3+
4+
const data: ReferenceEntityTemplateSchema = {
5+
name: 'Cash Drawer API',
6+
description: `
7+
The Cash Drawer API is an API exposed to extensions for cash drawer functionality, specifically allowing UI extensions to control cash drawer operations.`,
8+
isVisualComponent: false,
9+
type: 'APIs',
10+
definitions: [
11+
{
12+
title: 'CashDrawerApi',
13+
description: 'Interface for handling cash drawer operations.',
14+
type: 'CashDrawerApi',
15+
},
16+
],
17+
category: 'APIs',
18+
related: [],
19+
examples: {
20+
description: 'Examples of using the Cash Drawer API',
21+
examples: [
22+
{
23+
codeblock: generateCodeBlock(
24+
'Cash Drawer API',
25+
'cash-drawer-api',
26+
'default.example',
27+
),
28+
},
29+
],
30+
},
31+
};
32+
33+
export default data;
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import {
2+
Tile,
3+
extension,
4+
} from '@shopify/ui-extensions/point-of-sale';
5+
6+
export default extension(
7+
'pos.home.tile.render',
8+
(root, api) => {
9+
const tile = root.createComponent(Tile, {
10+
title: 'My app',
11+
subtitle: 'Hello world!',
12+
enabled: true,
13+
onPress: () => {
14+
api.cashDrawer.open();
15+
},
16+
});
17+
18+
root.append(tile);
19+
},
20+
);

packages/ui-extensions/src/surfaces/point-of-sale/api.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ export type {
77

88
export type {CartLineItemApi} from './api/cart-line-item-api/cart-line-item-api';
99

10+
export type {CashDrawerApi} from './api/cash-drawer-api/cash-drawer-api';
11+
1012
export type {ActionApi, ActionApiContent} from './api/action-api/action-api';
1113

1214
export type {StandardApi} from './api/standard/standard-api';
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
/**
2+
* The Cash Drawer API in POS UI extensions includes select cash drawer functionality.
3+
*/
4+
export interface CashDrawerApi {
5+
/**
6+
* Opens the connected cash drawer.
7+
*
8+
* @returns Void
9+
*
10+
*/
11+
open(): Promise<void>;
12+
}

0 commit comments

Comments
 (0)