Skip to content

Beta

ये App Bridge components नए हैं, और beta के दौरान इनका API किसी minor release में बदल सकता है। इनका व्यवहार एक local E2E suite से असली Shopify admin में जाँचा जाता है। अगर कुछ काम नहीं करता, तो कृपया issue खोलें।

Device और platform integration ​

वे APIs जिन्हें Shopify device और platform integration में रखता है, और वे types जिन्हें सिर्फ़ ये इस्तेमाल करते हैं। इस 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.

इनमें इस्तेमाल: useAppBridge(), ShopifyGlobal

PosCart ​

type
ts
type PosCart = Required<_PosCart>;

References: _PosCartइनमें इस्तेमाल: PosApi

PosClose ​

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

इनमें इस्तेमाल: PosApi

PosDevice ​

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

References: Deviceइनमें इस्तेमाल: PosApi

PosLocation ​

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

References: Locationइनमें इस्तेमाल: 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.

इनमें इस्तेमाल: PosCart

Device ​

interface

name: string

The name of the device.

serialNumber: string

The unique ID associated device ID and app ID..

इनमें इस्तेमाल: 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.

इनमें इस्तेमाल: 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.

इनमें इस्तेमाल: _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.

इनमें इस्तेमाल: CartSubscriber, _PosCart

CartSubscriber ​

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

References: Cartइनमें इस्तेमाल: _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.

इनमें इस्तेमाल: 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.

इनमें इस्तेमाल: _PosCart

DiscountType ​

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

इनमें इस्तेमाल: Discount, _PosCart

Unsubscribe ​

function
ts
type Unsubscribe = () => void;

इनमें इस्तेमाल: _PosCart

Discount ​

interface

amount: number

Amount of discount. Only for fixed or percentage discounts.

discountDescription?: string

Description of discount.

type: DiscountType

Type of discount.

इनमें इस्तेमाल: 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.

इनमें इस्तेमाल: 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.

इनमें इस्तेमाल: useAppBridge(), ShopifyGlobal

ScannerPayload ​

interface

data: string

The scanned barcode data as a string.

इनमें इस्तेमाल: 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.

इनमें इस्तेमाल: useAppBridge(), ShopifyGlobal

WebVitalsCallback ​

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

References: WebVitalsReportइनमें इस्तेमाल: WebVitalsApi

WebVitalsReport ​

interface

metrics: WebVitalsMetric[]

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

इनमें इस्तेमाल: 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.

इनमें इस्तेमाल: WebVitalsReport

MIT License के तहत जारी। Vue logo Evan You द्वारा, CC BY-NC-SA 4.0।