Skip to content

Commit

Permalink
Merge pull request #2531 from Shopify/vic/bulk-cart-update
Browse files Browse the repository at this point in the history
Add bulkCartUpdate to useCartApi / removes deprecated customer props
  • Loading branch information
vctrchu authored Dec 17, 2024
2 parents 0383290 + 74b06c4 commit 29d4cb5
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 5 deletions.
5 changes: 5 additions & 0 deletions .changeset/stale-planes-wonder.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@shopify/ui-extensions': minor
---

Add bulkUpdateCart function to POS useCartApi
Original file line number Diff line number Diff line change
Expand Up @@ -53,13 +53,15 @@ Refer to the [migration guide](/docs/api/pos-ui-extensions/migrating) for more i
- Removed the deprecated \`badge\` prop from the [List](/docs/api/pos-ui-extensions/components/list) component. Use \`badges\` instead.
- Removed the deprecated \`TextFieldProps\` type from the [TextField](/docs/api/pos-ui-extensions/components/textfield) component.
- Removed \`customValidator\` prop from the [FormattedTextField](/docs/api/pos-ui-extensions/components/formattedtextfield) component.
- Removed \`email\`, \`firstName\`, \`lastName\`, and \`note\` from the [Customer](/docs/api/pos-ui-extensions/apis/cart-api#customer) object.
### Features
- Added [PrintApi](/docs/api/pos-ui-extensions/apis/print-api) and a [PrintPreview](/docs/api/pos-ui-extensions/components/printpreview) component.
- Added \`currency\` prop to the [SessionApi](/docs/api/pos-ui-extensions/apis/session-api).
- [Cart API](/docs/api/pos-ui-extensions/apis/cart-api) updates:
- \`addLineItem\` and \`addCustomSale\` now return a UUID for the created item.
- Added \`bulkUpdateCart\` function for single-operation cart updates.
- The \`addLineItem\` and \`addCustomSale\` functions now return a UUID for the added line item.
- Added [Box](/docs/api/pos-ui-extensions/components/box) component.
- Added Sizing and fill options to the[Image](/docs/api/pos-ui-extensions/components/image) component.
`,
Expand Down
1 change: 1 addition & 0 deletions packages/ui-extensions/src/surfaces/point-of-sale/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ export type {

export type {
Cart,
CartUpdateInput,
Customer,
LineItem,
Discount,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import type {RemoteSubscribable} from '@remote-ui/async-subscription';
import type {
Address,
Cart,
CartUpdateInput,
Customer,
CustomSale,
SetLineItemDiscountInput,
Expand All @@ -27,6 +28,12 @@ export interface CartApiContent {
*/
subscribable: RemoteSubscribable<Cart>;

/** Bulk update the cart
* @param cartState the cart state to set
* @returns the updated cart
*/
bulkCartUpdate(cartState: CartUpdateInput): Promise<Cart>;

/** Apply a cart level discount
* @param type the type of discount applied (example: 'Percentage')
* @param title the title attributed with the discount
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,13 @@ export interface Cart {
properties: Record<string, string>;
}

export type CartUpdateInput = Omit<
Cart,
'subtotal' | 'taxTotal' | 'grandTotal'
>;

export interface Customer {
id: number;
email?: string;
firstName?: string;
lastName?: string;
note?: string;
}

export interface LineItem {
Expand Down

0 comments on commit 29d4cb5

Please sign in to comment.