Skip to content

Bêta

Ces composants App Bridge sont nouveaux, et leur API peut changer dans une version mineure pendant la bêta. Leur comportement est vérifié dans une vraie interface d'administration Shopify par une suite E2E locale. Si quelque chose ne fonctionne pas, ouvrez une issue.

Intégration des appareils et de la plateforme ​

Les API que Shopify range dans intégration des appareils et de la plateforme, et les types qu'elles seules utilisent. Sur cette page : PosApi, ScannerApi, WebVitalsApi.

PosApi ​

interface

cart: PosCart

Provides methods to read and modify the current POS cart, including line items, discounts, customers, and properties.

close: PosClose

Closes the app and returns to the POS screen.

device: PosDevice

Returns information about the POS device, including its name and serial number. Rejects when the host does not answer, or answers without a device.

location: PosLocation

Returns information about the current POS location, including its ID, name, address, and status. Rejects when the host does not answer, or answers without a location.

Utilisé dans : useAppBridge(), ShopifyGlobal

PosCart ​

type
ts
type PosCart = Required<_PosCart>;

Références : _PosCartUtilisé dans : PosApi

PosClose ​

function
ts
type PosClose = () => Promise<void>;

Utilisé dans : PosApi

PosDevice ​

function
ts
type PosDevice = () => Promise<Device>;

Références : DeviceUtilisé dans : PosApi

PosLocation ​

function
ts
type PosLocation = () => Promise<Location>;

Références : LocationUtilisé dans : PosApi

_PosCart ​

interface

fetch?(): Promise<Cart>

Fetch the current cart.

subscribe?(onSubscribe: CartSubscriber): Unsubscribe

Subscribe the cart changes.

setCustomer?(customer: Customer): Promise<void>

Add a new or existing customer to the cart.

removeCustomer?(): Promise<void>

Remove the current customer from the cart.

addAddress?(address: Address): Promise<void>

Add a new address to a customer.

updateAddress?(index: number, address: Address): Promise<void>

Update an address for a customer.

applyCartDiscount?(type: DiscountType, discountDescription: string, amount: string): Promise<void>

Apply a percentage or fixed amount discount to the whole cart.

applyCartCodeDiscount?(code: string): Promise<void>

Apply a code discount to the whole cart.

removeCartDiscount?(): Promise<void>

Remove the discount applied to the whole cart.

removeAllDiscounts?(disableAutomaticDiscounts: boolean): Promise<void>

Clears all applied discounts from the cart and optionally disables automatic discounts.

addCartProperties?(properties: Record<string, string>): Promise<void>

Add properties for the cart.

removeCartProperties?(keys: string[]): Promise<void>

Remove properties from the cart.

addCustomSale?(customSale: CustomSale): Promise<void>

Add custom sale for the cart.

clear?(): Promise<void>

Clear all contents from the cart.

addLineItem?(variantId: number, quantity: number): Promise<void>

Add a product to the cart.

updateLineItem?(uuid: string, quantity: number): Promise<void>

Make changes to a line item in the cart.

removeLineItem?(uuid: string): Promise<void>

Remove a line item in the cart.

setLineItemDiscount?(uuid: string, type: DiscountType, discountDescription: string, amount: string): Promise<void>

Apply a discount to a line item.

removeLineItemDiscount?(uuid: string): Promise<void>

Remove a discount from a line item.

addLineItemProperties?(uuid: string, properties: Record<string, string>): Promise<void>

Add properties to a line item.

removeLineItemProperties?(uuid: string, properties: string[]): Promise<void>

Remove properties from a line item.

Utilisé dans : PosCart

Device ​

interface

name: string

The name of the device.

serialNumber: string

The unique ID associated device ID and app ID..

Utilisé dans : PosDevice

Location ​

interface

id: number

The ID of current location.

active: boolean

The status of current location.

name: string

The name of current location.

locationType?: string

The type of current location.

address1?: string

The primary address of current location.

address2?: string

Any extra information associated with the address (Apartment #, Suite #, Unit #, etc.).

zip?: string

The ZIP or postal code of the address.

city?: string

The name of the city.

province?: string

TThe province or state of the address.

countryCode?: string

The Country Code in ISO 3166-1 (alpha-2) format.

countryName?: string

The country of the address.

phone?: string

The phone number of the location.

Utilisé dans : PosLocation

Address ​

interface

address1?: string

The customer's primary address.

address2?: string

Any extra information associated with the address (Apartment #, Suite #, Unit #, etc.).

city?: string

The name of the customer's city.

company?: string

The company name associated with address.

firstName?: string

The first name of the customer.

lastName?: string

The last name of the customer.

phone?: string

The phone number of the customer.

province?: string

The province or state of the address.

country?: string

The country of the address.

zip?: string

The ZIP or postal code of the address.

name?: string

The name of the address.

provinceCode?: string

The acronym of the province or state.

countryCode?: string

The Country Code in ISO 3166-1 (alpha-2) format.

Utilisé dans : _PosCart

Cart ​

interface

subTotal: string

The total cost of the current cart including discounts, but before taxes and shipping. Value is based on the shop's existing currency settings.

taxTotal: string

The sum of taxes for the current cart. Value is based on the shop's existing currency settings.

grandTotal: string

The total cost of the current cart, after taxes and discounts have been applied. Value is based on the shop's existing currency settings.

cartDiscount?: Discount

The current discount applied to the entire cart.

cartDiscounts?: Discount[]

All current discounts applied to the entire cart and line items.

customer?: Customer

The customer associated to the current cart.

lineItems: LineItem[]

A list of lineItem objects.

properties: Record<string, string>

A list of objects containing cart properties.

Utilisé dans : CartSubscriber, _PosCart

CartSubscriber ​

function
ts
type CartSubscriber = (cart: Cart) => void;

Références : CartUtilisé dans : _PosCart

Customer ​

interface

id: number

The ID of existing customer.

email?: string

The email for a new customer.

firstName?: string

The first name for new customer.

lastName?: string

The last name for new customer.

note?: string

The note for new customer.

Utilisé dans : Cart, _PosCart

CustomSale ​

interface

price: number

Price of line item

quantity: number

Quantity of line item.

title: string

Title of line item.

taxable: boolean

If line item charges tax.

Utilisé dans : _PosCart

DiscountType ​

type
ts
type DiscountType = "Percentage" | "FixedAmount";

Utilisé dans : Discount, _PosCart

Unsubscribe ​

function
ts
type Unsubscribe = () => void;

Utilisé dans : _PosCart

Discount ​

interface

amount: number

Amount of discount. Only for fixed or percentage discounts.

discountDescription?: string

Description of discount.

type: DiscountType

Type of discount.

Utilisé dans : Cart, LineItem

LineItem ​

interface

uuid: string

Unique id of line item

price?: number

Price of line item

quantity: number

Quantity of line item.

title?: string

Title of line item.

variantId?: number

Variant identifier for line item.

productId?: number

Product identifier for line item.

discounts: Discount[]

Discount applied to line item.

taxable: boolean

If line item charges tax.

sku?: string

Stock keeping unit of the line item.

vendor?: string

Vendor of line item.

properties: { [key: string]: string; }

Properties of the line item.

isGiftCard: boolean

If the line item is a gift card.

Utilisé dans : Cart

ScannerApi ​

interface

capture(): Promise<ScannerPayload>

Opens the device camera to scan a barcode. Returns a Promise that resolves to a ScannerPayload containing the scanned data. A new call to capture rejects a pending call with an AbortError.

Utilisé dans : useAppBridge(), ShopifyGlobal

ScannerPayload ​

interface

data: string

The scanned barcode data as a string.

Utilisé dans : useAppBridge(), ScannerApi

WebVitalsApi ​

interface

onReport?: (callback: WebVitalsCallback | null) => Promise<void>

Registers a callback to receive Web Vitals performance data. Pass null to unregister a previously registered callback.

Utilisé dans : useAppBridge(), ShopifyGlobal

WebVitalsCallback ​

function
ts
type WebVitalsCallback = (payload: WebVitalsReport) => void | Promise<void>;

Références : WebVitalsReportUtilisé dans : WebVitalsApi

WebVitalsReport ​

interface

metrics: WebVitalsMetric[]

The array of Web Vitals metric measurements included in this report.

Utilisé dans : WebVitalsCallback

WebVitalsMetric ​

interface

id: string

A unique identifier for this metric measurement instance.

name: string

The name of the metric, such as LCP, FCP, CLS, INP, or TTFB.

value: number

The measured value of the metric. Units depend on the metric name (milliseconds for timing metrics, unitless for CLS).

country?: string

The country code where the metric was collected, if available.

version?: string

The App Bridge build version that produced the metric, in the form <package-version> or <package-version>+<short-commit-sha>. Used to attribute reports to a specific deploy.

Utilisé dans : WebVitalsReport

Publié sous licence MIT. Logo Vue par Evan You, CC BY-NC-SA 4.0.