From 6bf7774795e50de566089ef63b7bb82ad31b3c2d Mon Sep 17 00:00:00 2001 From: Tim Leguijt Date: Thu, 21 Sep 2023 16:48:13 +0200 Subject: [PATCH] feat: add support for cart removeDiscountCode action --- src/repositories/cart.ts | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/repositories/cart.ts b/src/repositories/cart.ts index e33e85b7..d7e4ae93 100644 --- a/src/repositories/cart.ts +++ b/src/repositories/cart.ts @@ -21,6 +21,7 @@ import type { Price, Product, ProductPagedQueryResponse, + CartRemoveDiscountCodeAction, ProductVariant, } from '@commercetools/platform-sdk' import { v4 as uuidv4 } from 'uuid' @@ -415,6 +416,13 @@ export class CartRepository extends AbstractResourceRepository<'cart'> { custom: custom, } }, + removeDiscountCode: ( + context: RepositoryContext, + resource: Writable, + { discountCode }: CartRemoveDiscountCodeAction + ) => { + resource.discountCodes = resource.discountCodes.filter(code => code.discountCode.id !== discountCode.id) + } } draftLineItemtoLineItem = ( projectKey: string,