From e30b12e56bf405689d4712a535f1245b1a7b848f Mon Sep 17 00:00:00 2001 From: Ella Nan <38847123+ellanan@users.noreply.github.com> Date: Mon, 10 Nov 2025 11:43:20 -0500 Subject: [PATCH] fix: add channel and context tag in AddPromotion request --- src/endpoints/cart.js | 10 ++++++---- src/types/cart.d.ts | 4 +++- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/src/endpoints/cart.js b/src/endpoints/cart.js index 01559d3..32b45d6 100644 --- a/src/endpoints/cart.js +++ b/src/endpoints/cart.js @@ -202,11 +202,13 @@ class CartEndpoint extends BaseExtend { }) } - AddPromotion(code, token=null, currency = null) { + AddPromotion(code, token=null, currency = null, channel = null, contextTag = null) { - const additionalHeaders = currency - ? { 'X-MOLTIN-CURRENCY': currency } - : {} + const additionalHeaders = { + ...(currency && { 'X-MOLTIN-CURRENCY': currency }), + ...(channel && { 'EP-Channel': channel }), + ...(contextTag && { 'EP-Context-Tag': contextTag }) + } return this.request.send( `${this.endpoint}/${this.cartId}/items`, diff --git a/src/types/cart.d.ts b/src/types/cart.d.ts index b07de4a..14f22a5 100644 --- a/src/types/cart.d.ts +++ b/src/types/cart.d.ts @@ -431,8 +431,10 @@ export interface CartEndpoint * @param code the promotion code. * @param token a customer token to apply customer specific promotions. * @param currency the currency to apply the promotion in. + * @param channel the channel to apply the promotion in. + * @param contextTag the context tag to apply the promotion in. */ - AddPromotion(code: string, token?: string, currency?: string): Promise + AddPromotion(code: string, token?: string, currency?: string, channel?: string, contextTag?: string): Promise /** * Remove promotion from Cart