Skip to content

Commit 29d4cb5

Browse files
authored
Merge pull request #2531 from Shopify/vic/bulk-cart-update
Add bulkCartUpdate to useCartApi / removes deprecated customer props
2 parents 0383290 + 74b06c4 commit 29d4cb5

File tree

5 files changed

+21
-5
lines changed

5 files changed

+21
-5
lines changed

.changeset/stale-planes-wonder.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@shopify/ui-extensions': minor
3+
---
4+
5+
Add bulkUpdateCart function to POS useCartApi

packages/ui-extensions/docs/surfaces/point-of-sale/staticPages/pages/versions.doc.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,13 +53,15 @@ Refer to the [migration guide](/docs/api/pos-ui-extensions/migrating) for more i
5353
- Removed the deprecated \`badge\` prop from the [List](/docs/api/pos-ui-extensions/components/list) component. Use \`badges\` instead.
5454
- Removed the deprecated \`TextFieldProps\` type from the [TextField](/docs/api/pos-ui-extensions/components/textfield) component.
5555
- Removed \`customValidator\` prop from the [FormattedTextField](/docs/api/pos-ui-extensions/components/formattedtextfield) component.
56+
- Removed \`email\`, \`firstName\`, \`lastName\`, and \`note\` from the [Customer](/docs/api/pos-ui-extensions/apis/cart-api#customer) object.
5657
5758
### Features
5859
5960
- Added [PrintApi](/docs/api/pos-ui-extensions/apis/print-api) and a [PrintPreview](/docs/api/pos-ui-extensions/components/printpreview) component.
6061
- Added \`currency\` prop to the [SessionApi](/docs/api/pos-ui-extensions/apis/session-api).
6162
- [Cart API](/docs/api/pos-ui-extensions/apis/cart-api) updates:
62-
- \`addLineItem\` and \`addCustomSale\` now return a UUID for the created item.
63+
- Added \`bulkUpdateCart\` function for single-operation cart updates.
64+
- The \`addLineItem\` and \`addCustomSale\` functions now return a UUID for the added line item.
6365
- Added [Box](/docs/api/pos-ui-extensions/components/box) component.
6466
- Added Sizing and fill options to the[Image](/docs/api/pos-ui-extensions/components/image) component.
6567
`,

packages/ui-extensions/src/surfaces/point-of-sale/api.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ export type {
8282

8383
export type {
8484
Cart,
85+
CartUpdateInput,
8586
Customer,
8687
LineItem,
8788
Discount,

packages/ui-extensions/src/surfaces/point-of-sale/render/api/cart-api/cart-api.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import type {RemoteSubscribable} from '@remote-ui/async-subscription';
22
import type {
33
Address,
44
Cart,
5+
CartUpdateInput,
56
Customer,
67
CustomSale,
78
SetLineItemDiscountInput,
@@ -27,6 +28,12 @@ export interface CartApiContent {
2728
*/
2829
subscribable: RemoteSubscribable<Cart>;
2930

31+
/** Bulk update the cart
32+
* @param cartState the cart state to set
33+
* @returns the updated cart
34+
*/
35+
bulkCartUpdate(cartState: CartUpdateInput): Promise<Cart>;
36+
3037
/** Apply a cart level discount
3138
* @param type the type of discount applied (example: 'Percentage')
3239
* @param title the title attributed with the discount

packages/ui-extensions/src/surfaces/point-of-sale/types/cart.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,13 @@ export interface Cart {
1212
properties: Record<string, string>;
1313
}
1414

15+
export type CartUpdateInput = Omit<
16+
Cart,
17+
'subtotal' | 'taxTotal' | 'grandTotal'
18+
>;
19+
1520
export interface Customer {
1621
id: number;
17-
email?: string;
18-
firstName?: string;
19-
lastName?: string;
20-
note?: string;
2122
}
2223

2324
export interface LineItem {

0 commit comments

Comments
 (0)