From ec6a371f6cde6d1ce58a18025d1d2d7c2ce3b400 Mon Sep 17 00:00:00 2001 From: DevDaniloSants Date: Mon, 19 Jan 2026 15:41:27 -0300 Subject: [PATCH 01/18] fix: add segment props --- vtex/actions/cart/simulation.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/vtex/actions/cart/simulation.ts b/vtex/actions/cart/simulation.ts index 4bb75b72c..bc5c547bb 100644 --- a/vtex/actions/cart/simulation.ts +++ b/vtex/actions/cart/simulation.ts @@ -13,6 +13,7 @@ export interface Props { postalCode: string; country: string; RnbBehavior?: 0 | 1; + sc?: number; } /** @@ -24,6 +25,7 @@ const action = async ( props: Props, req: Request, ctx: AppContext, + sc?: number, ): Promise => { const cookie = req.headers.get("cookie") ?? ""; const { vcsDeprecated } = ctx; @@ -35,7 +37,7 @@ const action = async ( ]( { RnbBehavior, - sc: segment?.payload.channel, + sc: sc ?? segment?.payload.channel, }, { body: { items, country, postalCode }, From 0a09fce2d94e5c96a484c8052e0ad988139961af Mon Sep 17 00:00:00 2001 From: DevDaniloSants Date: Mon, 19 Jan 2026 15:44:43 -0300 Subject: [PATCH 02/18] fix: add sc props --- vtex/actions/cart/simulation.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/vtex/actions/cart/simulation.ts b/vtex/actions/cart/simulation.ts index bc5c547bb..a1058e34e 100644 --- a/vtex/actions/cart/simulation.ts +++ b/vtex/actions/cart/simulation.ts @@ -25,11 +25,10 @@ const action = async ( props: Props, req: Request, ctx: AppContext, - sc?: number, ): Promise => { const cookie = req.headers.get("cookie") ?? ""; const { vcsDeprecated } = ctx; - const { items, postalCode, country, RnbBehavior = 1 } = props; + const { items, postalCode, country, RnbBehavior = 1, sc } = props; const segment = getSegmentFromBag(ctx); const response = await vcsDeprecated[ From e37d3d774ca0ef970457e13c6f752d4ac3da236a Mon Sep 17 00:00:00 2001 From: devdaniloWicomm Date: Thu, 22 Jan 2026 15:54:14 -0300 Subject: [PATCH 03/18] Update vtex/actions/cart/simulation.ts Co-authored-by: Gabriel Matos Boubee <108771428+gabrielMatosBoubee@users.noreply.github.com> --- vtex/actions/cart/simulation.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vtex/actions/cart/simulation.ts b/vtex/actions/cart/simulation.ts index a1058e34e..394952497 100644 --- a/vtex/actions/cart/simulation.ts +++ b/vtex/actions/cart/simulation.ts @@ -36,7 +36,7 @@ const action = async ( ]( { RnbBehavior, - sc: sc ?? segment?.payload.channel, + sc: sc ?? ctx.allowMixedSegments ? segment?.payload.channel : ctx.salesChannel, }, { body: { items, country, postalCode }, From 15254dcb0f7ac66b0b4cf68b1a9dc5ff3926bdaf Mon Sep 17 00:00:00 2001 From: DevDaniloSants Date: Mon, 2 Feb 2026 14:22:52 -0300 Subject: [PATCH 04/18] feat: add sc props --- vtex/actions/cart/addItems.ts | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/vtex/actions/cart/addItems.ts b/vtex/actions/cart/addItems.ts index c8b883f7c..0b1d799cb 100644 --- a/vtex/actions/cart/addItems.ts +++ b/vtex/actions/cart/addItems.ts @@ -16,6 +16,7 @@ export interface Item { export interface Props { orderItems: Item[]; allowedOutdatedData?: Array<"paymentData">; + sc?: string; } /** @@ -29,28 +30,29 @@ const action = async ( ctx: AppContext, ): Promise => { const { vcsDeprecated } = ctx; - const { - orderItems, - allowedOutdatedData = ["paymentData"], - } = props; + const { orderItems, allowedOutdatedData = ["paymentData"], sc } = props; const { orderFormId } = parseCookie(req.headers); const cookie = req.headers.get("cookie") ?? ""; const segment = getSegmentFromBag(ctx); try { - const response = await vcsDeprecated - ["POST /api/checkout/pub/orderForm/:orderFormId/items"]({ + const response = await vcsDeprecated[ + "POST /api/checkout/pub/orderForm/:orderFormId/items" + ]( + { orderFormId, allowedOutdatedData, - sc: segment?.payload.channel, - }, { + sc: sc ?? segment?.payload.channel, + }, + { body: { orderItems }, headers: { "content-type": "application/json", accept: "application/json", cookie, }, - }); + }, + ); proxySetCookie(response.headers, ctx.response.headers, req.url); From 159eedf1fb6b15ab26a1020be1b6dac5773f921b Mon Sep 17 00:00:00 2001 From: DevDaniloSants Date: Tue, 3 Feb 2026 08:49:11 -0300 Subject: [PATCH 05/18] feat: add sc opcional via props --- vtex/actions/cart/addItems.ts | 5 ++- vtex/actions/cart/getInstallment.ts | 21 +++++++++---- vtex/actions/cart/removeItemAttachment.ts | 33 +++++++++++++------- vtex/actions/cart/removeItems.ts | 34 +++++++++++++------- vtex/actions/cart/simulation.ts | 5 ++- vtex/actions/cart/updateAttachment.ts | 19 +++++++++--- vtex/actions/cart/updateCoupons.ts | 20 ++++++++---- vtex/actions/cart/updateItemAttachment.ts | 38 +++++++++++++---------- vtex/actions/cart/updateItemPrice.ts | 23 ++++++++------ vtex/actions/cart/updateItems.ts | 19 +++++++++--- vtex/actions/cart/updateProfile.ts | 20 ++++++++---- vtex/actions/cart/updateUser.ts | 24 ++++++++++---- 12 files changed, 178 insertions(+), 83 deletions(-) diff --git a/vtex/actions/cart/addItems.ts b/vtex/actions/cart/addItems.ts index 0b1d799cb..8886a616c 100644 --- a/vtex/actions/cart/addItems.ts +++ b/vtex/actions/cart/addItems.ts @@ -42,7 +42,10 @@ const action = async ( { orderFormId, allowedOutdatedData, - sc: sc ?? segment?.payload.channel, + sc: + (sc ?? ctx.allowMixedSegments) + ? segment?.payload.channel + : ctx.salesChannel, }, { body: { orderItems }, diff --git a/vtex/actions/cart/getInstallment.ts b/vtex/actions/cart/getInstallment.ts index 17beb3838..e2f5e1154 100644 --- a/vtex/actions/cart/getInstallment.ts +++ b/vtex/actions/cart/getInstallment.ts @@ -6,6 +6,7 @@ import { getSegmentFromBag } from "../../utils/segment.ts"; export interface Props { paymentSystem: number; + sc?: string; } /** @@ -19,16 +20,24 @@ const action = async ( ctx: AppContext, ): Promise => { const { vcsDeprecated } = ctx; - const { paymentSystem } = props; + const { paymentSystem, sc } = props; const { orderFormId } = parseCookie(req.headers); const cookie = req.headers.get("cookie") ?? ""; const segment = getSegmentFromBag(ctx); - const response = await vcsDeprecated - ["GET /api/checkout/pub/orderForm/:orderFormId/installments"]( - { orderFormId, paymentSystem, sc: segment?.payload.channel }, - { headers: { accept: "application/json", cookie } }, - ); + const response = await vcsDeprecated[ + "GET /api/checkout/pub/orderForm/:orderFormId/installments" + ]( + { + orderFormId, + paymentSystem, + sc: + (sc ?? ctx.allowMixedSegments) + ? segment?.payload.channel + : ctx.salesChannel, + }, + { headers: { accept: "application/json", cookie } }, + ); proxySetCookie(response.headers, ctx.response.headers, req.url); diff --git a/vtex/actions/cart/removeItemAttachment.ts b/vtex/actions/cart/removeItemAttachment.ts index 16be3a213..a76ec0236 100644 --- a/vtex/actions/cart/removeItemAttachment.ts +++ b/vtex/actions/cart/removeItemAttachment.ts @@ -12,6 +12,7 @@ export interface Props { content: Record; expectedOrderFormSections?: string[]; noSplitItem?: boolean; + sc?: string; } export const DEFAULT_EXPECTED_SECTIONS = [ @@ -48,23 +49,33 @@ const action = async ( content, noSplitItem = true, expectedOrderFormSections = DEFAULT_EXPECTED_SECTIONS, + sc, } = props; const { orderFormId } = parseCookie(req.headers); const cookie = req.headers.get("cookie") ?? ""; const segment = getSegmentFromBag(ctx); - const response = await vcsDeprecated - ["DELETE /api/checkout/pub/orderForm/:orderFormId/items/:index/attachments/:attachment"]( - { orderFormId, attachment, index, sc: segment?.payload.channel }, - { - body: { content, noSplitItem, expectedOrderFormSections }, - headers: { - accept: "application/json", - "content-type": "application/json", - cookie, - }, + const response = await vcsDeprecated[ + "DELETE /api/checkout/pub/orderForm/:orderFormId/items/:index/attachments/:attachment" + ]( + { + orderFormId, + attachment, + index, + sc: + (sc ?? ctx.allowMixedSegments) + ? segment?.payload.channel + : ctx.salesChannel, + }, + { + body: { content, noSplitItem, expectedOrderFormSections }, + headers: { + accept: "application/json", + "content-type": "application/json", + cookie, }, - ); + }, + ); proxySetCookie(response.headers, ctx.response.headers, req.url); diff --git a/vtex/actions/cart/removeItems.ts b/vtex/actions/cart/removeItems.ts index 5ad34095c..e8b0f9678 100644 --- a/vtex/actions/cart/removeItems.ts +++ b/vtex/actions/cart/removeItems.ts @@ -4,32 +4,44 @@ import { parseCookie } from "../../utils/orderForm.ts"; import type { OrderForm } from "../../utils/types.ts"; import { getSegmentFromBag } from "../../utils/segment.ts"; +export interface Props { + sc?: string; +} + /** * @docs https://developers.vtex.com/docs/api-reference/checkout-api#post-/api/checkout/pub/orderForm/-orderFormId-/items/removeAll * @title Remove Items from Cart * @description Remove all items from the cart */ const action = async ( - _props: unknown, + props: Props, req: Request, ctx: AppContext, ): Promise => { const { vcsDeprecated } = ctx; + const { sc } = props; const { orderFormId } = parseCookie(req.headers); const cookie = req.headers.get("cookie") ?? ""; const segment = getSegmentFromBag(ctx); - const response = await vcsDeprecated - ["POST /api/checkout/pub/orderForm/:orderFormId/items/removeAll"]( - { orderFormId, sc: segment?.payload.channel }, - { - headers: { - "content-type": "application/json", - accept: "application/json", - cookie, - }, + const response = await vcsDeprecated[ + "POST /api/checkout/pub/orderForm/:orderFormId/items/removeAll" + ]( + { + orderFormId, + sc: + (sc ?? ctx.allowMixedSegments) + ? segment?.payload.channel + : ctx.salesChannel, + }, + { + headers: { + "content-type": "application/json", + accept: "application/json", + cookie, }, - ); + }, + ); proxySetCookie(response.headers, ctx.response.headers, req.url); diff --git a/vtex/actions/cart/simulation.ts b/vtex/actions/cart/simulation.ts index 394952497..fd8909630 100644 --- a/vtex/actions/cart/simulation.ts +++ b/vtex/actions/cart/simulation.ts @@ -36,7 +36,10 @@ const action = async ( ]( { RnbBehavior, - sc: sc ?? ctx.allowMixedSegments ? segment?.payload.channel : ctx.salesChannel, + sc: + (sc ?? ctx.allowMixedSegments) + ? segment?.payload.channel + : ctx.salesChannel, }, { body: { items, country, postalCode }, diff --git a/vtex/actions/cart/updateAttachment.ts b/vtex/actions/cart/updateAttachment.ts index 37cf4c40b..2f315b572 100644 --- a/vtex/actions/cart/updateAttachment.ts +++ b/vtex/actions/cart/updateAttachment.ts @@ -10,6 +10,7 @@ export interface Props { expectedOrderFormSections?: string[]; // deno-lint-ignore no-explicit-any body: any; + sc?: string; } /** @@ -26,6 +27,7 @@ const action = async ( attachment, body, expectedOrderFormSections = DEFAULT_EXPECTED_SECTIONS, + sc, } = props; const { orderFormId } = parseCookie(req.headers); @@ -36,19 +38,26 @@ const action = async ( const cookie = req.headers.get("cookie") ?? ""; const segment = getSegmentFromBag(ctx); - const response = await vcsDeprecated - ["POST /api/checkout/pub/orderForm/:orderFormId/attachments/:attachment"]({ + const response = await vcsDeprecated[ + "POST /api/checkout/pub/orderForm/:orderFormId/attachments/:attachment" + ]( + { orderFormId, attachment, - sc: segment?.payload.channel, - }, { + sc: + (sc ?? ctx.allowMixedSegments) + ? segment?.payload.channel + : ctx.salesChannel, + }, + { body: { expectedOrderFormSections, ...body }, headers: { accept: "application/json", "content-type": "application/json", cookie, }, - }); + }, + ); proxySetCookie(response.headers, ctx.response.headers, req.url); diff --git a/vtex/actions/cart/updateCoupons.ts b/vtex/actions/cart/updateCoupons.ts index 852c42065..1cea5b0b8 100644 --- a/vtex/actions/cart/updateCoupons.ts +++ b/vtex/actions/cart/updateCoupons.ts @@ -6,6 +6,7 @@ import { getSegmentFromBag } from "../../utils/segment.ts"; export interface Props { text: string; + sc?: string; } /** @@ -19,23 +20,30 @@ const action = async ( ctx: AppContext, ): Promise => { const { vcsDeprecated } = ctx; - const { text } = props; + const { text, sc } = props; const cookie = req.headers.get("cookie") ?? ""; const { orderFormId } = parseCookie(req.headers); const segment = getSegmentFromBag(ctx); - const response = await vcsDeprecated - ["POST /api/checkout/pub/orderForm/:orderFormId/coupons"]({ + const response = await vcsDeprecated[ + "POST /api/checkout/pub/orderForm/:orderFormId/coupons" + ]( + { orderFormId, - sc: segment?.payload.channel, - }, { + sc: + (sc ?? ctx.allowMixedSegments) + ? segment?.payload.channel + : ctx.salesChannel, + }, + { body: { text }, headers: { accept: "application/json", "content-type": "application/json", cookie, }, - }); + }, + ); proxySetCookie(response.headers, ctx.response.headers, req.url); diff --git a/vtex/actions/cart/updateItemAttachment.ts b/vtex/actions/cart/updateItemAttachment.ts index 3b20412fe..2575ef8b4 100644 --- a/vtex/actions/cart/updateItemAttachment.ts +++ b/vtex/actions/cart/updateItemAttachment.ts @@ -12,6 +12,7 @@ export interface Props { content: Record; expectedOrderFormSections?: string[]; noSplitItem?: boolean; + sc?: string; } export const DEFAULT_EXPECTED_SECTIONS = [ @@ -48,28 +49,33 @@ const action = async ( content, noSplitItem = true, expectedOrderFormSections = DEFAULT_EXPECTED_SECTIONS, + sc, } = props; const { orderFormId } = parseCookie(req.headers); const cookie = req.headers.get("cookie") ?? ""; const segment = getSegmentFromBag(ctx); - const response = await vcsDeprecated - ["POST /api/checkout/pub/orderForm/:orderFormId/items/:index/attachments/:attachment"]( - { - orderFormId, - attachment, - index, - sc: segment?.payload.channel, + const response = await vcsDeprecated[ + "POST /api/checkout/pub/orderForm/:orderFormId/items/:index/attachments/:attachment" + ]( + { + orderFormId, + attachment, + index, + sc: + (sc ?? ctx.allowMixedSegments) + ? segment?.payload.channel + : ctx.salesChannel, + }, + { + body: { content, noSplitItem, expectedOrderFormSections }, + headers: { + accept: "application/json", + "content-type": "application/json", + cookie, }, - { - body: { content, noSplitItem, expectedOrderFormSections }, - headers: { - accept: "application/json", - "content-type": "application/json", - cookie, - }, - }, - ); + }, + ); proxySetCookie(response.headers, ctx.response.headers, req.url); diff --git a/vtex/actions/cart/updateItemPrice.ts b/vtex/actions/cart/updateItemPrice.ts index 034bcbc84..55b70d2cd 100644 --- a/vtex/actions/cart/updateItemPrice.ts +++ b/vtex/actions/cart/updateItemPrice.ts @@ -7,6 +7,7 @@ import { getSegmentFromBag } from "../../utils/segment.ts"; export interface Props { itemIndex: number; price: number; + sc?: string; } /** @@ -20,27 +21,31 @@ const action = async ( ctx: AppContext, ): Promise => { const { vcsDeprecated } = ctx; - const { - itemIndex, - price, - } = props; + const { itemIndex, price, sc } = props; const { orderFormId } = parseCookie(req.headers); const cookie = req.headers.get("cookie") ?? ""; const segment = getSegmentFromBag(ctx); - const response = await vcsDeprecated - ["PUT /api/checkout/pub/orderForm/:orderFormId/items/:index/price"]({ + const response = await vcsDeprecated[ + "PUT /api/checkout/pub/orderForm/:orderFormId/items/:index/price" + ]( + { orderFormId, index: itemIndex, - sc: segment?.payload.channel, - }, { + sc: + (sc ?? ctx.allowMixedSegments) + ? segment?.payload.channel + : ctx.salesChannel, + }, + { body: { price }, headers: { accept: "application/json", "content-type": "application/json", cookie, }, - }); + }, + ); proxySetCookie(response.headers, ctx.response.headers, req.url); diff --git a/vtex/actions/cart/updateItems.ts b/vtex/actions/cart/updateItems.ts index bb0ea3e8c..1bace809f 100644 --- a/vtex/actions/cart/updateItems.ts +++ b/vtex/actions/cart/updateItems.ts @@ -13,6 +13,7 @@ export interface Props { orderItems: Item[]; allowedOutdatedData?: Array<"paymentData">; noSplitItem?: boolean; + sc?: string; } /** @@ -30,24 +31,32 @@ const action = async ( orderItems, allowedOutdatedData = ["paymentData"], noSplitItem, + sc, } = props; const { orderFormId } = parseCookie(req.headers); const cookie = req.headers.get("cookie") ?? ""; const segment = getSegmentFromBag(ctx); - const response = await vcsDeprecated - ["POST /api/checkout/pub/orderForm/:orderFormId/items/update"]({ + const response = await vcsDeprecated[ + "POST /api/checkout/pub/orderForm/:orderFormId/items/update" + ]( + { orderFormId, allowedOutdatedData, - sc: segment?.payload.channel, - }, { + sc: + (sc ?? ctx.allowMixedSegments) + ? segment?.payload.channel + : ctx.salesChannel, + }, + { body: { orderItems, noSplitItem: Boolean(noSplitItem) }, headers: { "content-type": "application/json", accept: "application/json", cookie, }, - }); + }, + ); proxySetCookie(response.headers, ctx.response.headers, req.url); diff --git a/vtex/actions/cart/updateProfile.ts b/vtex/actions/cart/updateProfile.ts index cb621dc91..e39e3d5ed 100644 --- a/vtex/actions/cart/updateProfile.ts +++ b/vtex/actions/cart/updateProfile.ts @@ -6,6 +6,7 @@ import { getSegmentFromBag } from "../../utils/segment.ts"; export interface Props { ignoreProfileData: boolean; + sc?: string; } /** @@ -19,23 +20,30 @@ const action = async ( ctx: AppContext, ): Promise => { const { vcsDeprecated } = ctx; - const { ignoreProfileData } = props; + const { ignoreProfileData, sc } = props; const { orderFormId } = parseCookie(req.headers); const cookie = req.headers.get("cookie") ?? ""; const segment = getSegmentFromBag(ctx); - const response = await vcsDeprecated - ["PATCH /api/checkout/pub/orderForm/:orderFormId/profile"]({ + const response = await vcsDeprecated[ + "PATCH /api/checkout/pub/orderForm/:orderFormId/profile" + ]( + { orderFormId, - sc: segment?.payload.channel, - }, { + sc: + (sc ?? ctx.allowMixedSegments) + ? segment?.payload.channel + : ctx.salesChannel, + }, + { body: { ignoreProfileData }, headers: { "content-type": "application/json", accept: "application/json", cookie, }, - }); + }, + ); proxySetCookie(response.headers, ctx.response.headers, req.url); diff --git a/vtex/actions/cart/updateUser.ts b/vtex/actions/cart/updateUser.ts index dca9184e8..f050c80d0 100644 --- a/vtex/actions/cart/updateUser.ts +++ b/vtex/actions/cart/updateUser.ts @@ -4,31 +4,43 @@ import { parseCookie } from "../../utils/orderForm.ts"; import type { OrderForm } from "../../utils/types.ts"; import { getSegmentFromBag } from "../../utils/segment.ts"; +export interface Props { + sc?: string; +} + /** * @docs https://developers.vtex.com/docs/api-reference/checkout-api#get-/checkout/changeToAnonymousUser/-orderFormId- * @title Update User * @description Update the user */ const action = async ( - _props: unknown, + props: Props, req: Request, ctx: AppContext, ): Promise => { const { vcsDeprecated } = ctx; + const { sc } = props; const { orderFormId } = parseCookie(req.headers); const cookie = req.headers.get("cookie") ?? ""; const segment = getSegmentFromBag(ctx); - const response = await vcsDeprecated - ["GET /api/checkout/changeToAnonymousUser/:orderFormId"]({ + const response = await vcsDeprecated[ + "GET /api/checkout/changeToAnonymousUser/:orderFormId" + ]( + { orderFormId, - sc: segment?.payload.channel, - }, { + sc: + (sc ?? ctx.allowMixedSegments) + ? segment?.payload.channel + : ctx.salesChannel, + }, + { headers: { accept: "application/json", cookie, }, - }); + }, + ); proxySetCookie(response.headers, ctx.response.headers, req.url); From 21cd8418ff328dc56110f7a1855927e7ac0ea42e Mon Sep 17 00:00:00 2001 From: DevDaniloSants Date: Tue, 3 Feb 2026 08:52:32 -0300 Subject: [PATCH 06/18] fix: ajusta a tipagem do sc para number --- vtex/actions/cart/addItems.ts | 2 +- vtex/actions/cart/getInstallment.ts | 2 +- vtex/actions/cart/removeItemAttachment.ts | 2 +- vtex/actions/cart/removeItems.ts | 2 +- vtex/actions/cart/updateAttachment.ts | 2 +- vtex/actions/cart/updateCoupons.ts | 2 +- vtex/actions/cart/updateItemAttachment.ts | 2 +- vtex/actions/cart/updateItemPrice.ts | 2 +- vtex/actions/cart/updateItems.ts | 2 +- vtex/actions/cart/updateProfile.ts | 2 +- vtex/actions/cart/updateUser.ts | 2 +- 11 files changed, 11 insertions(+), 11 deletions(-) diff --git a/vtex/actions/cart/addItems.ts b/vtex/actions/cart/addItems.ts index 8886a616c..9c8b5d01c 100644 --- a/vtex/actions/cart/addItems.ts +++ b/vtex/actions/cart/addItems.ts @@ -16,7 +16,7 @@ export interface Item { export interface Props { orderItems: Item[]; allowedOutdatedData?: Array<"paymentData">; - sc?: string; + sc?: number; } /** diff --git a/vtex/actions/cart/getInstallment.ts b/vtex/actions/cart/getInstallment.ts index e2f5e1154..75fe84c2e 100644 --- a/vtex/actions/cart/getInstallment.ts +++ b/vtex/actions/cart/getInstallment.ts @@ -6,7 +6,7 @@ import { getSegmentFromBag } from "../../utils/segment.ts"; export interface Props { paymentSystem: number; - sc?: string; + sc?: number; } /** diff --git a/vtex/actions/cart/removeItemAttachment.ts b/vtex/actions/cart/removeItemAttachment.ts index a76ec0236..c908937c3 100644 --- a/vtex/actions/cart/removeItemAttachment.ts +++ b/vtex/actions/cart/removeItemAttachment.ts @@ -12,7 +12,7 @@ export interface Props { content: Record; expectedOrderFormSections?: string[]; noSplitItem?: boolean; - sc?: string; + sc?: number; } export const DEFAULT_EXPECTED_SECTIONS = [ diff --git a/vtex/actions/cart/removeItems.ts b/vtex/actions/cart/removeItems.ts index e8b0f9678..cc2823b99 100644 --- a/vtex/actions/cart/removeItems.ts +++ b/vtex/actions/cart/removeItems.ts @@ -5,7 +5,7 @@ import type { OrderForm } from "../../utils/types.ts"; import { getSegmentFromBag } from "../../utils/segment.ts"; export interface Props { - sc?: string; + sc?: number; } /** diff --git a/vtex/actions/cart/updateAttachment.ts b/vtex/actions/cart/updateAttachment.ts index 2f315b572..2fba50ca8 100644 --- a/vtex/actions/cart/updateAttachment.ts +++ b/vtex/actions/cart/updateAttachment.ts @@ -10,7 +10,7 @@ export interface Props { expectedOrderFormSections?: string[]; // deno-lint-ignore no-explicit-any body: any; - sc?: string; + sc?: number; } /** diff --git a/vtex/actions/cart/updateCoupons.ts b/vtex/actions/cart/updateCoupons.ts index 1cea5b0b8..012e15524 100644 --- a/vtex/actions/cart/updateCoupons.ts +++ b/vtex/actions/cart/updateCoupons.ts @@ -6,7 +6,7 @@ import { getSegmentFromBag } from "../../utils/segment.ts"; export interface Props { text: string; - sc?: string; + sc?: number; } /** diff --git a/vtex/actions/cart/updateItemAttachment.ts b/vtex/actions/cart/updateItemAttachment.ts index 2575ef8b4..007aa737f 100644 --- a/vtex/actions/cart/updateItemAttachment.ts +++ b/vtex/actions/cart/updateItemAttachment.ts @@ -12,7 +12,7 @@ export interface Props { content: Record; expectedOrderFormSections?: string[]; noSplitItem?: boolean; - sc?: string; + sc?: number; } export const DEFAULT_EXPECTED_SECTIONS = [ diff --git a/vtex/actions/cart/updateItemPrice.ts b/vtex/actions/cart/updateItemPrice.ts index 55b70d2cd..bc2183570 100644 --- a/vtex/actions/cart/updateItemPrice.ts +++ b/vtex/actions/cart/updateItemPrice.ts @@ -7,7 +7,7 @@ import { getSegmentFromBag } from "../../utils/segment.ts"; export interface Props { itemIndex: number; price: number; - sc?: string; + sc?: number; } /** diff --git a/vtex/actions/cart/updateItems.ts b/vtex/actions/cart/updateItems.ts index 1bace809f..f63ee8d66 100644 --- a/vtex/actions/cart/updateItems.ts +++ b/vtex/actions/cart/updateItems.ts @@ -13,7 +13,7 @@ export interface Props { orderItems: Item[]; allowedOutdatedData?: Array<"paymentData">; noSplitItem?: boolean; - sc?: string; + sc?: number; } /** diff --git a/vtex/actions/cart/updateProfile.ts b/vtex/actions/cart/updateProfile.ts index e39e3d5ed..0d8ad856c 100644 --- a/vtex/actions/cart/updateProfile.ts +++ b/vtex/actions/cart/updateProfile.ts @@ -6,7 +6,7 @@ import { getSegmentFromBag } from "../../utils/segment.ts"; export interface Props { ignoreProfileData: boolean; - sc?: string; + sc?: number; } /** diff --git a/vtex/actions/cart/updateUser.ts b/vtex/actions/cart/updateUser.ts index f050c80d0..472a4bbc9 100644 --- a/vtex/actions/cart/updateUser.ts +++ b/vtex/actions/cart/updateUser.ts @@ -5,7 +5,7 @@ import type { OrderForm } from "../../utils/types.ts"; import { getSegmentFromBag } from "../../utils/segment.ts"; export interface Props { - sc?: string; + sc?: number; } /** From e641b31f2dd232451f943e8fca0adbbe531eb2cc Mon Sep 17 00:00:00 2001 From: devdaniloWicomm Date: Tue, 3 Feb 2026 09:04:33 -0300 Subject: [PATCH 07/18] Update vtex/actions/cart/addItems.ts Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> --- vtex/actions/cart/addItems.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/vtex/actions/cart/addItems.ts b/vtex/actions/cart/addItems.ts index 9c8b5d01c..6d0390de0 100644 --- a/vtex/actions/cart/addItems.ts +++ b/vtex/actions/cart/addItems.ts @@ -43,9 +43,9 @@ const action = async ( orderFormId, allowedOutdatedData, sc: - (sc ?? ctx.allowMixedSegments) + sc ?? (ctx.allowMixedSegments ? segment?.payload.channel - : ctx.salesChannel, + : ctx.salesChannel), }, { body: { orderItems }, From bf6170ad4788ec1657fcf5d4ec3958612c4edb13 Mon Sep 17 00:00:00 2001 From: devdaniloWicomm Date: Tue, 3 Feb 2026 09:05:02 -0300 Subject: [PATCH 08/18] Update vtex/actions/cart/updateProfile.ts Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> --- vtex/actions/cart/updateProfile.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/vtex/actions/cart/updateProfile.ts b/vtex/actions/cart/updateProfile.ts index 0d8ad856c..f03d58653 100644 --- a/vtex/actions/cart/updateProfile.ts +++ b/vtex/actions/cart/updateProfile.ts @@ -31,9 +31,9 @@ const action = async ( { orderFormId, sc: - (sc ?? ctx.allowMixedSegments) + sc ?? (ctx.allowMixedSegments ? segment?.payload.channel - : ctx.salesChannel, + : ctx.salesChannel), }, { body: { ignoreProfileData }, From de7c1c4ab0782260a446cee4b74c61aad0153869 Mon Sep 17 00:00:00 2001 From: devdaniloWicomm Date: Tue, 3 Feb 2026 09:05:24 -0300 Subject: [PATCH 09/18] Update vtex/actions/cart/updateUser.ts Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> --- vtex/actions/cart/updateUser.ts | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/vtex/actions/cart/updateUser.ts b/vtex/actions/cart/updateUser.ts index 472a4bbc9..73d63de80 100644 --- a/vtex/actions/cart/updateUser.ts +++ b/vtex/actions/cart/updateUser.ts @@ -29,10 +29,9 @@ const action = async ( ]( { orderFormId, - sc: - (sc ?? ctx.allowMixedSegments) - ? segment?.payload.channel - : ctx.salesChannel, + sc: sc ?? (ctx.allowMixedSegments + ? segment?.payload.channel + : ctx.salesChannel), }, { headers: { From cdd859ed0a1d049e7e0c18a08184652676a0a01e Mon Sep 17 00:00:00 2001 From: devdaniloWicomm Date: Tue, 3 Feb 2026 09:05:50 -0300 Subject: [PATCH 10/18] Update vtex/actions/cart/updateItemPrice.ts Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> --- vtex/actions/cart/updateItemPrice.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/vtex/actions/cart/updateItemPrice.ts b/vtex/actions/cart/updateItemPrice.ts index bc2183570..d3c7c96e7 100644 --- a/vtex/actions/cart/updateItemPrice.ts +++ b/vtex/actions/cart/updateItemPrice.ts @@ -33,9 +33,9 @@ const action = async ( orderFormId, index: itemIndex, sc: - (sc ?? ctx.allowMixedSegments) + sc ?? (ctx.allowMixedSegments ? segment?.payload.channel - : ctx.salesChannel, + : ctx.salesChannel), }, { body: { price }, From 46553423af511f56d784cb20bd2bd76266fee2a6 Mon Sep 17 00:00:00 2001 From: devdaniloWicomm Date: Tue, 3 Feb 2026 09:06:36 -0300 Subject: [PATCH 11/18] Update vtex/actions/cart/getInstallment.ts Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> --- vtex/actions/cart/getInstallment.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/vtex/actions/cart/getInstallment.ts b/vtex/actions/cart/getInstallment.ts index 75fe84c2e..ff773e2dd 100644 --- a/vtex/actions/cart/getInstallment.ts +++ b/vtex/actions/cart/getInstallment.ts @@ -32,9 +32,9 @@ const action = async ( orderFormId, paymentSystem, sc: - (sc ?? ctx.allowMixedSegments) + sc ?? (ctx.allowMixedSegments ? segment?.payload.channel - : ctx.salesChannel, + : ctx.salesChannel), }, { headers: { accept: "application/json", cookie } }, ); From df6bb114e81df034c5c174ad03d5d330c4e795ca Mon Sep 17 00:00:00 2001 From: devdaniloWicomm Date: Tue, 3 Feb 2026 09:06:53 -0300 Subject: [PATCH 12/18] Update vtex/actions/cart/removeItemAttachment.ts Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> --- vtex/actions/cart/removeItemAttachment.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/vtex/actions/cart/removeItemAttachment.ts b/vtex/actions/cart/removeItemAttachment.ts index c908937c3..990eb139a 100644 --- a/vtex/actions/cart/removeItemAttachment.ts +++ b/vtex/actions/cart/removeItemAttachment.ts @@ -63,9 +63,9 @@ const action = async ( attachment, index, sc: - (sc ?? ctx.allowMixedSegments) + sc ?? (ctx.allowMixedSegments ? segment?.payload.channel - : ctx.salesChannel, + : ctx.salesChannel), }, { body: { content, noSplitItem, expectedOrderFormSections }, From 79614c72971c422d8fb2b2e78f0724f017dc61ff Mon Sep 17 00:00:00 2001 From: devdaniloWicomm Date: Tue, 3 Feb 2026 09:07:10 -0300 Subject: [PATCH 13/18] Update vtex/actions/cart/removeItems.ts Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> --- vtex/actions/cart/removeItems.ts | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/vtex/actions/cart/removeItems.ts b/vtex/actions/cart/removeItems.ts index cc2823b99..ed19974b2 100644 --- a/vtex/actions/cart/removeItems.ts +++ b/vtex/actions/cart/removeItems.ts @@ -29,10 +29,9 @@ const action = async ( ]( { orderFormId, - sc: - (sc ?? ctx.allowMixedSegments) - ? segment?.payload.channel - : ctx.salesChannel, + sc: sc ?? (ctx.allowMixedSegments + ? segment?.payload.channel + : ctx.salesChannel), }, { headers: { From 9cc0f29fba12b4764ae60e8780bf05ba4408c11e Mon Sep 17 00:00:00 2001 From: devdaniloWicomm Date: Tue, 3 Feb 2026 09:07:31 -0300 Subject: [PATCH 14/18] Update vtex/actions/cart/updateItemAttachment.ts Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> --- vtex/actions/cart/updateItemAttachment.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/vtex/actions/cart/updateItemAttachment.ts b/vtex/actions/cart/updateItemAttachment.ts index 007aa737f..49d43cacd 100644 --- a/vtex/actions/cart/updateItemAttachment.ts +++ b/vtex/actions/cart/updateItemAttachment.ts @@ -62,10 +62,10 @@ const action = async ( orderFormId, attachment, index, - sc: - (sc ?? ctx.allowMixedSegments) + sc: sc ?? + (ctx.allowMixedSegments ? segment?.payload.channel - : ctx.salesChannel, + : ctx.salesChannel), }, { body: { content, noSplitItem, expectedOrderFormSections }, From 96df3fb7b4e1a9efa036a96e365d089b25d33ca3 Mon Sep 17 00:00:00 2001 From: devdaniloWicomm Date: Tue, 3 Feb 2026 09:07:52 -0300 Subject: [PATCH 15/18] Update vtex/actions/cart/updateCoupons.ts Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> --- vtex/actions/cart/updateCoupons.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/vtex/actions/cart/updateCoupons.ts b/vtex/actions/cart/updateCoupons.ts index 012e15524..669ff6720 100644 --- a/vtex/actions/cart/updateCoupons.ts +++ b/vtex/actions/cart/updateCoupons.ts @@ -31,9 +31,9 @@ const action = async ( { orderFormId, sc: - (sc ?? ctx.allowMixedSegments) + sc ?? (ctx.allowMixedSegments ? segment?.payload.channel - : ctx.salesChannel, + : ctx.salesChannel), }, { body: { text }, From a4362fcc9c29a484c7c628e22340cf91b1f3bb9a Mon Sep 17 00:00:00 2001 From: DevDaniloSants Date: Wed, 4 Feb 2026 16:08:50 -0300 Subject: [PATCH 16/18] feat: add allowMixedSegments via props e arruma a tipagem do 'sc' para string --- vtex/actions/cart/addItems.ts | 5 ++-- vtex/actions/cart/getInstallment.ts | 7 +++--- vtex/actions/cart/removeItems.ts | 8 +++--- vtex/actions/cart/simulation.ts | 2 +- vtex/actions/cart/updateAttachment.ts | 2 +- vtex/actions/cart/updateCoupons.ts | 7 +++--- vtex/actions/cart/updateItemAttachment.ts | 9 +++---- vtex/actions/cart/updateItemPrice.ts | 7 +++--- vtex/actions/cart/updateItems.ts | 2 +- vtex/actions/cart/updateProfile.ts | 7 +++--- vtex/actions/cart/updateUser.ts | 8 +++--- vtex/mod.ts | 30 ++++++++++++++--------- 12 files changed, 49 insertions(+), 45 deletions(-) diff --git a/vtex/actions/cart/addItems.ts b/vtex/actions/cart/addItems.ts index 6d0390de0..8f7cf74ee 100644 --- a/vtex/actions/cart/addItems.ts +++ b/vtex/actions/cart/addItems.ts @@ -16,7 +16,7 @@ export interface Item { export interface Props { orderItems: Item[]; allowedOutdatedData?: Array<"paymentData">; - sc?: number; + sc?: string; } /** @@ -43,7 +43,8 @@ const action = async ( orderFormId, allowedOutdatedData, sc: - sc ?? (ctx.allowMixedSegments + sc ?? + (ctx.allowMixedSegments ? segment?.payload.channel : ctx.salesChannel), }, diff --git a/vtex/actions/cart/getInstallment.ts b/vtex/actions/cart/getInstallment.ts index ff773e2dd..b66b3f863 100644 --- a/vtex/actions/cart/getInstallment.ts +++ b/vtex/actions/cart/getInstallment.ts @@ -6,7 +6,7 @@ import { getSegmentFromBag } from "../../utils/segment.ts"; export interface Props { paymentSystem: number; - sc?: number; + sc?: string; } /** @@ -32,9 +32,8 @@ const action = async ( orderFormId, paymentSystem, sc: - sc ?? (ctx.allowMixedSegments - ? segment?.payload.channel - : ctx.salesChannel), + sc ?? + (ctx.allowMixedSegments ? segment?.payload.channel : ctx.salesChannel), }, { headers: { accept: "application/json", cookie } }, ); diff --git a/vtex/actions/cart/removeItems.ts b/vtex/actions/cart/removeItems.ts index ed19974b2..32449dd17 100644 --- a/vtex/actions/cart/removeItems.ts +++ b/vtex/actions/cart/removeItems.ts @@ -5,7 +5,7 @@ import type { OrderForm } from "../../utils/types.ts"; import { getSegmentFromBag } from "../../utils/segment.ts"; export interface Props { - sc?: number; + sc?: string; } /** @@ -29,9 +29,9 @@ const action = async ( ]( { orderFormId, - sc: sc ?? (ctx.allowMixedSegments - ? segment?.payload.channel - : ctx.salesChannel), + sc: + sc ?? + (ctx.allowMixedSegments ? segment?.payload.channel : ctx.salesChannel), }, { headers: { diff --git a/vtex/actions/cart/simulation.ts b/vtex/actions/cart/simulation.ts index fd8909630..18bad9e90 100644 --- a/vtex/actions/cart/simulation.ts +++ b/vtex/actions/cart/simulation.ts @@ -13,7 +13,7 @@ export interface Props { postalCode: string; country: string; RnbBehavior?: 0 | 1; - sc?: number; + sc?: string; } /** diff --git a/vtex/actions/cart/updateAttachment.ts b/vtex/actions/cart/updateAttachment.ts index 2fba50ca8..2f315b572 100644 --- a/vtex/actions/cart/updateAttachment.ts +++ b/vtex/actions/cart/updateAttachment.ts @@ -10,7 +10,7 @@ export interface Props { expectedOrderFormSections?: string[]; // deno-lint-ignore no-explicit-any body: any; - sc?: number; + sc?: string; } /** diff --git a/vtex/actions/cart/updateCoupons.ts b/vtex/actions/cart/updateCoupons.ts index 669ff6720..77070d430 100644 --- a/vtex/actions/cart/updateCoupons.ts +++ b/vtex/actions/cart/updateCoupons.ts @@ -6,7 +6,7 @@ import { getSegmentFromBag } from "../../utils/segment.ts"; export interface Props { text: string; - sc?: number; + sc?: string; } /** @@ -31,9 +31,8 @@ const action = async ( { orderFormId, sc: - sc ?? (ctx.allowMixedSegments - ? segment?.payload.channel - : ctx.salesChannel), + sc ?? + (ctx.allowMixedSegments ? segment?.payload.channel : ctx.salesChannel), }, { body: { text }, diff --git a/vtex/actions/cart/updateItemAttachment.ts b/vtex/actions/cart/updateItemAttachment.ts index 49d43cacd..ffa728208 100644 --- a/vtex/actions/cart/updateItemAttachment.ts +++ b/vtex/actions/cart/updateItemAttachment.ts @@ -12,7 +12,7 @@ export interface Props { content: Record; expectedOrderFormSections?: string[]; noSplitItem?: boolean; - sc?: number; + sc?: string; } export const DEFAULT_EXPECTED_SECTIONS = [ @@ -62,10 +62,9 @@ const action = async ( orderFormId, attachment, index, - sc: sc ?? - (ctx.allowMixedSegments - ? segment?.payload.channel - : ctx.salesChannel), + sc: + sc ?? + (ctx.allowMixedSegments ? segment?.payload.channel : ctx.salesChannel), }, { body: { content, noSplitItem, expectedOrderFormSections }, diff --git a/vtex/actions/cart/updateItemPrice.ts b/vtex/actions/cart/updateItemPrice.ts index d3c7c96e7..a3c75bd41 100644 --- a/vtex/actions/cart/updateItemPrice.ts +++ b/vtex/actions/cart/updateItemPrice.ts @@ -7,7 +7,7 @@ import { getSegmentFromBag } from "../../utils/segment.ts"; export interface Props { itemIndex: number; price: number; - sc?: number; + sc?: string; } /** @@ -33,9 +33,8 @@ const action = async ( orderFormId, index: itemIndex, sc: - sc ?? (ctx.allowMixedSegments - ? segment?.payload.channel - : ctx.salesChannel), + sc ?? + (ctx.allowMixedSegments ? segment?.payload.channel : ctx.salesChannel), }, { body: { price }, diff --git a/vtex/actions/cart/updateItems.ts b/vtex/actions/cart/updateItems.ts index f63ee8d66..1bace809f 100644 --- a/vtex/actions/cart/updateItems.ts +++ b/vtex/actions/cart/updateItems.ts @@ -13,7 +13,7 @@ export interface Props { orderItems: Item[]; allowedOutdatedData?: Array<"paymentData">; noSplitItem?: boolean; - sc?: number; + sc?: string; } /** diff --git a/vtex/actions/cart/updateProfile.ts b/vtex/actions/cart/updateProfile.ts index f03d58653..8284ddddf 100644 --- a/vtex/actions/cart/updateProfile.ts +++ b/vtex/actions/cart/updateProfile.ts @@ -6,7 +6,7 @@ import { getSegmentFromBag } from "../../utils/segment.ts"; export interface Props { ignoreProfileData: boolean; - sc?: number; + sc?: string; } /** @@ -31,9 +31,8 @@ const action = async ( { orderFormId, sc: - sc ?? (ctx.allowMixedSegments - ? segment?.payload.channel - : ctx.salesChannel), + sc ?? + (ctx.allowMixedSegments ? segment?.payload.channel : ctx.salesChannel), }, { body: { ignoreProfileData }, diff --git a/vtex/actions/cart/updateUser.ts b/vtex/actions/cart/updateUser.ts index 73d63de80..453530c91 100644 --- a/vtex/actions/cart/updateUser.ts +++ b/vtex/actions/cart/updateUser.ts @@ -5,7 +5,7 @@ import type { OrderForm } from "../../utils/types.ts"; import { getSegmentFromBag } from "../../utils/segment.ts"; export interface Props { - sc?: number; + sc?: string; } /** @@ -29,9 +29,9 @@ const action = async ( ]( { orderFormId, - sc: sc ?? (ctx.allowMixedSegments - ? segment?.payload.channel - : ctx.salesChannel), + sc: + sc ?? + (ctx.allowMixedSegments ? segment?.payload.channel : ctx.salesChannel), }, { headers: { diff --git a/vtex/mod.ts b/vtex/mod.ts index 3d89168fd..bc8a30522 100644 --- a/vtex/mod.ts +++ b/vtex/mod.ts @@ -105,6 +105,12 @@ export interface Props { */ extraTerms?: string[]; }; + + /** + * @title Allow Mixed Segments + * @description Allow mixed segments in cart operations + */ + allowMixedSegments?: boolean; } export const color = 0xf71963; /** @@ -114,10 +120,14 @@ export const color = 0xf71963; * @category Ecommmerce * @logo https://assets.decocache.com/mcp/0d6e795b-cefd-4853-9a51-93b346c52c3f/VTEX.svg */ -export default function VTEX( - { appKey, appToken, account, publicUrl: _publicUrl, salesChannel, ...props }: - Props, -) { +export default function VTEX({ + appKey, + appToken, + account, + publicUrl: _publicUrl, + salesChannel, + ...props +}: Props) { const publicUrl = _publicUrl?.startsWith("https://") ? _publicUrl : `https://${_publicUrl}`; @@ -125,12 +135,12 @@ export default function VTEX( appKey && headers.set( "X-VTEX-API-AppKey", - typeof appKey === "string" ? appKey : appKey?.get?.() ?? "", + typeof appKey === "string" ? appKey : (appKey?.get?.() ?? ""), ); appToken && headers.set( "X-VTEX-API-AppToken", - typeof appToken === "string" ? appToken : appToken?.get?.() ?? "", + typeof appToken === "string" ? appToken : (appToken?.get?.() ?? ""), ); const sp = createHttpClient({ base: `https://sp.vtex.com`, @@ -181,8 +191,8 @@ export default function VTEX( }); const cachedSearchTerms = [ - ...(props.cachedSearchTerms?.terms?.searches ?? []).map((search) => - search.term + ...(props.cachedSearchTerms?.terms?.searches ?? []).map( + (search) => search.term, ), ...(props.cachedSearchTerms?.extraTerms ?? []), ]; @@ -202,9 +212,7 @@ export default function VTEX( sub, cachedSearchTerms, }; - const app: A, - ]> = { + const app: A]> = { state, manifest, middleware, From 257837e6617ed0d80c29188698a738d78889e39e Mon Sep 17 00:00:00 2001 From: devdaniloWicomm Date: Wed, 4 Feb 2026 16:12:21 -0300 Subject: [PATCH 17/18] Update vtex/actions/cart/removeItemAttachment.ts Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> --- vtex/actions/cart/removeItemAttachment.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vtex/actions/cart/removeItemAttachment.ts b/vtex/actions/cart/removeItemAttachment.ts index 990eb139a..2802a086c 100644 --- a/vtex/actions/cart/removeItemAttachment.ts +++ b/vtex/actions/cart/removeItemAttachment.ts @@ -12,7 +12,7 @@ export interface Props { content: Record; expectedOrderFormSections?: string[]; noSplitItem?: boolean; - sc?: number; + sc?: string; } export const DEFAULT_EXPECTED_SECTIONS = [ From f639a01d3f38851137bf53af820b442ffb9ea86f Mon Sep 17 00:00:00 2001 From: Danilo Santos Date: Mon, 9 Feb 2026 20:30:55 -0300 Subject: [PATCH 18/18] fix: ajusta o sc para utilizaro sc se existir --- vtex/actions/cart/addItems.ts | 2 +- vtex/actions/cart/getInstallment.ts | 6 ++++-- vtex/actions/cart/removeItemAttachment.ts | 5 +++-- vtex/actions/cart/removeItems.ts | 6 ++++-- vtex/actions/cart/simulation.ts | 5 +++-- vtex/actions/cart/updateAttachment.ts | 7 ++++--- vtex/actions/cart/updateCoupons.ts | 6 ++++-- vtex/actions/cart/updateItemAttachment.ts | 6 ++++-- vtex/actions/cart/updateItemPrice.ts | 6 ++++-- vtex/actions/cart/updateItems.ts | 5 +++-- vtex/actions/cart/updateProfile.ts | 6 ++++-- vtex/actions/cart/updateUser.ts | 6 ++++-- 12 files changed, 42 insertions(+), 24 deletions(-) diff --git a/vtex/actions/cart/addItems.ts b/vtex/actions/cart/addItems.ts index 8f7cf74ee..8f5f2c86d 100644 --- a/vtex/actions/cart/addItems.ts +++ b/vtex/actions/cart/addItems.ts @@ -43,7 +43,7 @@ const action = async ( orderFormId, allowedOutdatedData, sc: - sc ?? + sc ? sc : (ctx.allowMixedSegments ? segment?.payload.channel : ctx.salesChannel), diff --git a/vtex/actions/cart/getInstallment.ts b/vtex/actions/cart/getInstallment.ts index b66b3f863..bb9d49fd3 100644 --- a/vtex/actions/cart/getInstallment.ts +++ b/vtex/actions/cart/getInstallment.ts @@ -32,8 +32,10 @@ const action = async ( orderFormId, paymentSystem, sc: - sc ?? - (ctx.allowMixedSegments ? segment?.payload.channel : ctx.salesChannel), + sc ? sc : + (ctx.allowMixedSegments + ? segment?.payload.channel + : ctx.salesChannel) }, { headers: { accept: "application/json", cookie } }, ); diff --git a/vtex/actions/cart/removeItemAttachment.ts b/vtex/actions/cart/removeItemAttachment.ts index 2802a086c..726107c69 100644 --- a/vtex/actions/cart/removeItemAttachment.ts +++ b/vtex/actions/cart/removeItemAttachment.ts @@ -63,9 +63,10 @@ const action = async ( attachment, index, sc: - sc ?? (ctx.allowMixedSegments + sc ? sc : + (ctx.allowMixedSegments ? segment?.payload.channel - : ctx.salesChannel), + : ctx.salesChannel) }, { body: { content, noSplitItem, expectedOrderFormSections }, diff --git a/vtex/actions/cart/removeItems.ts b/vtex/actions/cart/removeItems.ts index 32449dd17..ebaea6220 100644 --- a/vtex/actions/cart/removeItems.ts +++ b/vtex/actions/cart/removeItems.ts @@ -30,8 +30,10 @@ const action = async ( { orderFormId, sc: - sc ?? - (ctx.allowMixedSegments ? segment?.payload.channel : ctx.salesChannel), + sc ? sc : + (ctx.allowMixedSegments + ? segment?.payload.channel + : ctx.salesChannel) }, { headers: { diff --git a/vtex/actions/cart/simulation.ts b/vtex/actions/cart/simulation.ts index 18bad9e90..d9f158de0 100644 --- a/vtex/actions/cart/simulation.ts +++ b/vtex/actions/cart/simulation.ts @@ -37,9 +37,10 @@ const action = async ( { RnbBehavior, sc: - (sc ?? ctx.allowMixedSegments) + sc ? sc : + (ctx.allowMixedSegments ? segment?.payload.channel - : ctx.salesChannel, + : ctx.salesChannel), }, { body: { items, country, postalCode }, diff --git a/vtex/actions/cart/updateAttachment.ts b/vtex/actions/cart/updateAttachment.ts index 2f315b572..e56d89298 100644 --- a/vtex/actions/cart/updateAttachment.ts +++ b/vtex/actions/cart/updateAttachment.ts @@ -45,9 +45,10 @@ const action = async ( orderFormId, attachment, sc: - (sc ?? ctx.allowMixedSegments) - ? segment?.payload.channel - : ctx.salesChannel, + sc ? sc : + (ctx.allowMixedSegments + ? segment?.payload.channel + : ctx.salesChannel), }, { body: { expectedOrderFormSections, ...body }, diff --git a/vtex/actions/cart/updateCoupons.ts b/vtex/actions/cart/updateCoupons.ts index 77070d430..417b04c04 100644 --- a/vtex/actions/cart/updateCoupons.ts +++ b/vtex/actions/cart/updateCoupons.ts @@ -31,8 +31,10 @@ const action = async ( { orderFormId, sc: - sc ?? - (ctx.allowMixedSegments ? segment?.payload.channel : ctx.salesChannel), + sc ? sc : + (ctx.allowMixedSegments + ? segment?.payload.channel + : ctx.salesChannel), }, { body: { text }, diff --git a/vtex/actions/cart/updateItemAttachment.ts b/vtex/actions/cart/updateItemAttachment.ts index ffa728208..6ab1c1dc0 100644 --- a/vtex/actions/cart/updateItemAttachment.ts +++ b/vtex/actions/cart/updateItemAttachment.ts @@ -63,8 +63,10 @@ const action = async ( attachment, index, sc: - sc ?? - (ctx.allowMixedSegments ? segment?.payload.channel : ctx.salesChannel), + sc ? sc : + (ctx.allowMixedSegments + ? segment?.payload.channel + : ctx.salesChannel), }, { body: { content, noSplitItem, expectedOrderFormSections }, diff --git a/vtex/actions/cart/updateItemPrice.ts b/vtex/actions/cart/updateItemPrice.ts index a3c75bd41..e16cda9b8 100644 --- a/vtex/actions/cart/updateItemPrice.ts +++ b/vtex/actions/cart/updateItemPrice.ts @@ -33,8 +33,10 @@ const action = async ( orderFormId, index: itemIndex, sc: - sc ?? - (ctx.allowMixedSegments ? segment?.payload.channel : ctx.salesChannel), + sc ? sc : + (ctx.allowMixedSegments + ? segment?.payload.channel + : ctx.salesChannel), }, { body: { price }, diff --git a/vtex/actions/cart/updateItems.ts b/vtex/actions/cart/updateItems.ts index 1bace809f..4bcbd25b7 100644 --- a/vtex/actions/cart/updateItems.ts +++ b/vtex/actions/cart/updateItems.ts @@ -44,9 +44,10 @@ const action = async ( orderFormId, allowedOutdatedData, sc: - (sc ?? ctx.allowMixedSegments) + sc ? sc : + (ctx.allowMixedSegments ? segment?.payload.channel - : ctx.salesChannel, + : ctx.salesChannel), }, { body: { orderItems, noSplitItem: Boolean(noSplitItem) }, diff --git a/vtex/actions/cart/updateProfile.ts b/vtex/actions/cart/updateProfile.ts index 8284ddddf..c3c551119 100644 --- a/vtex/actions/cart/updateProfile.ts +++ b/vtex/actions/cart/updateProfile.ts @@ -31,8 +31,10 @@ const action = async ( { orderFormId, sc: - sc ?? - (ctx.allowMixedSegments ? segment?.payload.channel : ctx.salesChannel), + sc ? sc : + (ctx.allowMixedSegments + ? segment?.payload.channel + : ctx.salesChannel), }, { body: { ignoreProfileData }, diff --git a/vtex/actions/cart/updateUser.ts b/vtex/actions/cart/updateUser.ts index 453530c91..713c95d64 100644 --- a/vtex/actions/cart/updateUser.ts +++ b/vtex/actions/cart/updateUser.ts @@ -30,8 +30,10 @@ const action = async ( { orderFormId, sc: - sc ?? - (ctx.allowMixedSegments ? segment?.payload.channel : ctx.salesChannel), + sc ? sc : + (ctx.allowMixedSegments + ? segment?.payload.channel + : ctx.salesChannel), }, { headers: {