Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add bulkCartUpdate to useCartApi / removes deprecated customer props #2531

Merged
merged 1 commit into from
Dec 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.
vctrchu marked this conversation as resolved.
Show resolved Hide resolved
- 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;
vctrchu marked this conversation as resolved.
Show resolved Hide resolved
}

export interface LineItem {
Expand Down
Loading