Skip to content

Commit 0ca4dae

Browse files
committed
remove buyer change in web
1 parent 0b3a610 commit 0ca4dae

7 files changed

Lines changed: 16 additions & 102 deletions

File tree

platforms/web/README.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -395,7 +395,6 @@ exactly the fields relevant to that moment.
395395
| `checkout:close` | _(none)_ | The popup was dismissed (by the buyer, by `close()`, or by `focus` loss). |
396396
| `checkout:error` | `{error}` | Session-level fatal error — tear down the embedded context. |
397397
| `checkout:lineItemsChange` | `{checkout, lineItems}` | The cart's line items changed (item added/removed/quantity updated). |
398-
| `checkout:buyerChange` | `{checkout, buyer}` | The buyer's information changed (email, address, etc.). |
399398
| `checkout:totalsChange` | `{checkout, totals}` | The cart totals changed (subtotal, tax, shipping, discounts, total). |
400399
| `checkout:messagesChange` | `{checkout, messages}` | Checkout-level warnings/errors/info shown inside the checkout changed. |
401400

platforms/web/sample/main.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,6 @@ const EVENT_TYPES = [
134134
"checkout:close",
135135
"checkout:error",
136136
"checkout:lineItemsChange",
137-
"checkout:buyerChange",
138137
"checkout:totalsChange",
139138
"checkout:messagesChange",
140139
] as const;

platforms/web/src/checkout.test.ts

Lines changed: 16 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -792,21 +792,24 @@ describe("<shopify-checkout>", () => {
792792
);
793793
});
794794

795-
it("ignores unsupported notifications", () => {
796-
const { checkout, mockCheckoutWindow } = openPopupCheckout();
795+
it.each(["customMethod", "ec.buyer.change"])(
796+
"ignores unsupported notification %s",
797+
(method) => {
798+
const { checkout, mockCheckoutWindow } = openPopupCheckout();
797799

798-
simulateRawMessageEvent(
799-
checkout,
800-
{
801-
jsonrpc: "2.0",
802-
method: "customMethod",
803-
params: {},
804-
},
805-
{ source: mockCheckoutWindow },
806-
);
800+
simulateRawMessageEvent(
801+
checkout,
802+
{
803+
jsonrpc: "2.0",
804+
method,
805+
params: {},
806+
},
807+
{ source: mockCheckoutWindow },
808+
);
807809

808-
expect(mockCheckoutWindow.postMessage).not.toHaveBeenCalled();
809-
});
810+
expect(mockCheckoutWindow.postMessage).not.toHaveBeenCalled();
811+
},
812+
);
810813
});
811814

812815
describe("checkout:start", () => {
@@ -942,23 +945,6 @@ describe("<shopify-checkout>", () => {
942945
});
943946
});
944947

945-
describe("checkout:buyerChange", () => {
946-
it("updates the checkout property and dispatches an ec:buyerChange event", async () => {
947-
const { checkout, mockCheckoutWindow } = openPopupCheckout();
948-
const onBuyerChangeSpy = vi.fn();
949-
const listenForEvent = waitForEvent(checkout, "checkout:buyerChange", onBuyerChangeSpy);
950-
951-
const payload = makeCheckoutPayload();
952-
simulateProtocolMessageEvent(checkout, "ec.buyer.change", payload, {
953-
source: mockCheckoutWindow,
954-
});
955-
await listenForEvent;
956-
957-
expect(checkout.checkout).toBe(payload.checkout);
958-
expect(onBuyerChangeSpy).toHaveBeenCalledOnce();
959-
});
960-
});
961-
962948
describe("checkout:totalsChange", () => {
963949
it("updates the checkout property and dispatches an ec:totalsChange event", async () => {
964950
const { checkout, mockCheckoutWindow } = openPopupCheckout();
@@ -1063,22 +1049,6 @@ describe("<shopify-checkout>", () => {
10631049
expect(event.detail.checkout).toBe(payload.checkout);
10641050
});
10651051

1066-
it("checkout:buyerChange carries {buyer, checkout}", async () => {
1067-
const { checkout, mockCheckoutWindow } = openPopupCheckout();
1068-
const spy = vi.fn();
1069-
const wait = waitForEvent(checkout, "checkout:buyerChange", spy);
1070-
1071-
const payload = makeCheckoutPayload();
1072-
simulateProtocolMessageEvent(checkout, "ec.buyer.change", payload, {
1073-
source: mockCheckoutWindow,
1074-
});
1075-
await wait;
1076-
1077-
const event = spy.mock.calls[0]![0] as CustomEvent;
1078-
expect(event.detail.buyer).toBe(payload.checkout.buyer);
1079-
expect(event.detail.checkout).toBe(payload.checkout);
1080-
});
1081-
10821052
it("checkout:totalsChange carries {totals, checkout}", async () => {
10831053
const { checkout, mockCheckoutWindow } = openPopupCheckout();
10841054
const spy = vi.fn();

platforms/web/src/checkout.ts

Lines changed: 0 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ import type {
1111
CheckoutLineItem,
1212
CheckoutMessage,
1313
Total,
14-
Buyer,
1514
OrderConfirmation,
1615
UcpErrorResponse,
1716
} from "./checkout.types";
@@ -66,7 +65,6 @@ const SHADOW_TEMPLATE = createTemplate(html`
6665
* @event checkout:complete - Dispatched when the checkout was successfully completed
6766
* @event checkout:error - Dispatched on a session-level fatal error
6867
* @event checkout:lineItemsChange - Dispatched when cart line items change
69-
* @event checkout:buyerChange - Dispatched when buyer information changes
7068
* @event checkout:totalsChange - Dispatched when totals change
7169
* @event checkout:messagesChange - Dispatched when checkout messages change
7270
* @event checkout:close - Dispatched when the checkout overlay is closed (synthetic, not part of ECP)
@@ -580,16 +578,6 @@ export class ShopifyCheckout
580578
);
581579
break;
582580
}
583-
case "ec.buyer.change": {
584-
const checkout = (message.body as CheckoutProtocolMessageMap["ec.buyer.change"]).checkout;
585-
this.dispatchEvent(
586-
new ShopifyCheckoutBuyerChangeEvent({
587-
checkout,
588-
buyer: checkout.buyer,
589-
}),
590-
);
591-
break;
592-
}
593581
case "ec.totals.change": {
594582
const checkout = (message.body as CheckoutProtocolMessageMap["ec.totals.change"]).checkout;
595583
this.dispatchEvent(
@@ -761,12 +749,6 @@ export class ShopifyCheckout
761749
options?: boolean | AddEventListenerOptions,
762750
): void;
763751

764-
override addEventListener(
765-
type: "checkout:buyerChange",
766-
listener: TypedEventListener<ShopifyCheckoutBuyerChangeEvent> | null,
767-
options?: boolean | AddEventListenerOptions,
768-
): void;
769-
770752
override addEventListener(
771753
type: "checkout:totalsChange",
772754
listener: TypedEventListener<ShopifyCheckoutTotalsChangeEvent> | null,
@@ -818,13 +800,6 @@ export interface ShopifyCheckoutLineItemsChangeEventDetail {
818800
checkout: Checkout;
819801
}
820802

821-
export interface ShopifyCheckoutBuyerChangeEventDetail {
822-
/** Updated buyer (may be undefined when buyer information is cleared). */
823-
buyer: Buyer | undefined;
824-
/** Full checkout snapshot for handlers that want broader context. */
825-
checkout: Checkout;
826-
}
827-
828803
export interface ShopifyCheckoutTotalsChangeEventDetail {
829804
/** Updated totals. */
830805
totals: readonly Total[];
@@ -884,14 +859,6 @@ export class ShopifyCheckoutLineItemsChangeEvent extends CustomEvent<ShopifyChec
884859
}
885860
}
886861

887-
export class ShopifyCheckoutBuyerChangeEvent extends CustomEvent<ShopifyCheckoutBuyerChangeEventDetail> {
888-
declare type: "checkout:buyerChange";
889-
890-
constructor(detail: ShopifyCheckoutBuyerChangeEventDetail) {
891-
super("checkout:buyerChange", { detail, bubbles: true });
892-
}
893-
}
894-
895862
export class ShopifyCheckoutTotalsChangeEvent extends CustomEvent<ShopifyCheckoutTotalsChangeEventDetail> {
896863
declare type: "checkout:totalsChange";
897864

@@ -918,7 +885,6 @@ const CHECKOUT_PROTOCOL_MESSAGES: (keyof CheckoutProtocolMessageMap)[] = [
918885
"ec.complete",
919886
"ec.error",
920887
"ec.line_items.change",
921-
"ec.buyer.change",
922888
"ec.totals.change",
923889
"ec.messages.change",
924890
"ec.window.open_request",

platforms/web/src/checkout.types.ts

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
// checkout protocol. Embed payload shapes live in `./ucp-embed-types.ts`.
33

44
import type {
5-
Buyer,
65
Checkout,
76
CheckoutLineItem,
87
CheckoutMessage,
@@ -118,11 +117,6 @@ export interface CheckoutEvents {
118117
*/
119118
"checkout:lineItemsChange": CheckoutLineItemsChangeEvent;
120119

121-
/**
122-
* Dispatched when the buyer information changes.
123-
*/
124-
"checkout:buyerChange": CheckoutBuyerChangeEvent;
125-
126120
/**
127121
* Dispatched when the totals change.
128122
*/
@@ -175,16 +169,6 @@ export interface CheckoutLineItemsChangeEvent {
175169
};
176170
}
177171

178-
export interface CheckoutBuyerChangeEvent {
179-
type: "checkout:buyerChange";
180-
detail: {
181-
/** Updated buyer (may be undefined when buyer information is cleared). */
182-
buyer: Buyer | undefined;
183-
/** Full checkout snapshot for handlers that want broader context. */
184-
checkout: Checkout;
185-
};
186-
}
187-
188172
export interface CheckoutTotalsChangeEvent {
189173
type: "checkout:totalsChange";
190174
detail: {
@@ -252,7 +236,6 @@ export interface CheckoutProtocolMessageMap {
252236
"ec.complete": CheckoutPayload;
253237
"ec.error": EcErrorParams;
254238
"ec.line_items.change": CheckoutPayload;
255-
"ec.buyer.change": CheckoutPayload;
256239
"ec.totals.change": CheckoutPayload;
257240
"ec.messages.change": CheckoutPayload;
258241
"ec.window.open_request": { url: string };

platforms/web/src/index.test.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ describe("@shopify/checkout-kit public entry", () => {
1515
pkg.ShopifyCheckoutCloseEvent,
1616
pkg.ShopifyCheckoutErrorEvent,
1717
pkg.ShopifyCheckoutLineItemsChangeEvent,
18-
pkg.ShopifyCheckoutBuyerChangeEvent,
1918
pkg.ShopifyCheckoutTotalsChangeEvent,
2019
pkg.ShopifyCheckoutMessagesChangeEvent,
2120
];

platforms/web/src/index.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ export {
1111
ShopifyCheckoutCloseEvent,
1212
ShopifyCheckoutErrorEvent,
1313
ShopifyCheckoutLineItemsChangeEvent,
14-
ShopifyCheckoutBuyerChangeEvent,
1514
ShopifyCheckoutTotalsChangeEvent,
1615
ShopifyCheckoutMessagesChangeEvent,
1716
} from "./checkout";
@@ -22,7 +21,6 @@ export type {
2221
ShopifyCheckoutCompleteEventDetail,
2322
ShopifyCheckoutErrorEventDetail,
2423
ShopifyCheckoutLineItemsChangeEventDetail,
25-
ShopifyCheckoutBuyerChangeEventDetail,
2624
ShopifyCheckoutTotalsChangeEventDetail,
2725
ShopifyCheckoutMessagesChangeEventDetail,
2826
} from "./checkout";

0 commit comments

Comments
 (0)