Skip to content

POS cart: add optional options arg to addLineItem#4531

Draft
vctrchu wants to merge 1 commit into
2026-07-rcfrom
pos-cart-add-line-item-options
Draft

POS cart: add optional options arg to addLineItem#4531
vctrchu wants to merge 1 commit into
2026-07-rcfrom
pos-cart-add-line-item-options

Conversation

@vctrchu

@vctrchu vctrchu commented Jun 26, 2026

Copy link
Copy Markdown
Contributor

What

Add an optional third argument to the POS cart.addLineItem method so a single call can create a line item and decorate it with line-item properties and cart-level properties:

cart.addLineItem(variantId, quantity, options?: {
  properties?: Record<string, string>;     // line-item properties
  cartProperties?: Record<string, string>; // cart-level properties
});

Introduces the AddLineItemOptions type. Backwards compatible — the third argument is optional, so existing two-argument calls are unchanged.

Why

Cafe-style POS extensions adding a "modified item" (e.g. coffee + modifiers + order metadata) currently chain three extension API calls:

const uuid = await cart.addLineItem(variantId, 1);
await cart.addLineItemProperties(uuid, {modifiers: 'oat milk,extra shot'});
await cart.addCartProperties({orderSource: 'cafe_app'});

Each call awaits its own native SDK call and syncDraftCheckout round-trip — measured at ~3s p50 for the sequential pattern.

@vctrchu

vctrchu commented Jun 26, 2026

Copy link
Copy Markdown
Contributor Author

/snapit

Add an optional third argument to cart.addLineItem so a single call can
create a line item and decorate it with line-item properties and
cart-level properties, instead of chaining addLineItem ->
addLineItemProperties -> addCartProperties.

Introduces the AddLineItemOptions type ({properties?, cartProperties?}).
Backwards compatible: the third argument is optional. Follows the
TAG-friendly options-bag pattern (extend existing method over new method).

Assisted-By: devx/c896ba3a-e6c5-4ba0-ab6b-a5192c47d56a
@shopify-github-actions-access

Copy link
Copy Markdown
Contributor

🫰✨ Thanks @vctrchu! Your snapshots have been published to npm.

Test the snapshots by updating your package.json with the newly published versions:

"@shopify/ui-extensions": "0.0.0-snapshot-20260626012557",
"@shopify/ui-extensions-tester": "0.0.0-snapshot-20260626012557"

@vctrchu vctrchu force-pushed the pos-cart-add-line-item-options branch from f0e902b to e409ce4 Compare June 26, 2026 01:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant