Skip to content
Open
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
8 changes: 8 additions & 0 deletions pos-background/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# POS background extension

Scaffold for a non-visual POS background extension targeting `pos.app.ready.data`.

The background target runs for the full POS session and observes events via
`shopify.addEventListener()`. It does not render UI. See the example handlers in
`src/background-extension.{js,ts}` for `transactioncomplete`,
`cashtrackingsessionstart`, and `cashtrackingsessioncomplete`.
9 changes: 9 additions & 0 deletions pos-background/package.json.liquid
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"name": "{{ handle }}",
"private": true,
"version": "1.0.0",
"license": "UNLICENSED",
"dependencies": {
"@shopify/ui-extensions": "2026.7.x"
}
}
12 changes: 12 additions & 0 deletions pos-background/shopify.extension.toml.liquid
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
api_version = "2026-07"

[[extensions]]
type = "ui_extension"
name = "{{ name }}"
{% if uid %}uid = "{{ uid }}"{% endif %}
handle = "{{ handle }}"
description = "A {{ flavor }} POS background extension"

[[extensions.targeting]]
module = "./src/background-extension.{{ srcFileExtension }}"
target = "pos.app.ready.data"
36 changes: 36 additions & 0 deletions pos-background/src/background-extension.liquid
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import { POS_EVENT_NAMES } from '@shopify/ui-extensions/point-of-sale';
{% if flavor contains "typescript" %}
import type {
TransactionCompleteEvent,
CashTrackingSessionStartEvent,
CashTrackingSessionCompleteEvent,
} from '@shopify/ui-extensions/point-of-sale';
import type { Api } from '@shopify/ui-extensions/pos.app.ready.data';
{% endif %}

export default ({% if flavor contains "typescript" %}api: Api{% else %}_api{% endif %}) => {
try {
shopify.addEventListener(
POS_EVENT_NAMES.TRANSACTION_COMPLETE,
(event{% if flavor contains "typescript" %}: TransactionCompleteEvent{% endif %}) => {
console.log('transaction complete', event);
},
);

shopify.addEventListener(
POS_EVENT_NAMES.CASH_TRACKING_SESSION_START,
(event{% if flavor contains "typescript" %}: CashTrackingSessionStartEvent{% endif %}) => {
console.log('cash tracking session start', event);
},
);

shopify.addEventListener(
POS_EVENT_NAMES.CASH_TRACKING_SESSION_COMPLETE,
(event{% if flavor contains "typescript" %}: CashTrackingSessionCompleteEvent{% endif %}) => {
console.log('cash tracking session complete', event);
},
);
} catch (error) {
console.error('failed to register background extension listeners', error);
}
};
12 changes: 12 additions & 0 deletions pos-background/tsconfig.json.liquid
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"compilerOptions": {
"target": "ES2020",
"checkJs": true,
"allowJs": true,
"moduleResolution": "node",
"esModuleInterop": true,
"noEmit": true,
"skipLibCheck": true
},
"include": ["./src", "./shopify.d.ts"]
}
23 changes: 23 additions & 0 deletions templates.json
Original file line number Diff line number Diff line change
Expand Up @@ -1340,6 +1340,29 @@
],
"minimumCliVersion": "3.85.3"
},
{
"identifier": "pos_background",
"name": "POS background",
"defaultName": "pos-background",
"group": "UI extensions",
"supportLinks": [],
"url": "https://github.com/Shopify/extensions-templates",
"type": "ui_extension",
"extensionPoints": [],
"supportedFlavors": [
{
"name": "TypeScript",
"value": "typescript",
"path": "pos-background"
},
{
"name": "JavaScript",
"value": "vanilla-js",
"path": "pos-background"
}
],
"minimumCliVersion": "3.85.3"
},
{
"identifier": "cart_checkout_validation",
"name": "Cart and checkout validation",
Expand Down