Skip to content

Commit

Permalink
feat: add support for cart removeDiscountCode action
Browse files Browse the repository at this point in the history
  • Loading branch information
tleguijt committed Sep 21, 2023
1 parent f92c410 commit 6bf7774
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/repositories/cart.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import type {
Price,
Product,
ProductPagedQueryResponse,
CartRemoveDiscountCodeAction,
ProductVariant,
} from '@commercetools/platform-sdk'
import { v4 as uuidv4 } from 'uuid'
Expand Down Expand Up @@ -415,6 +416,13 @@ export class CartRepository extends AbstractResourceRepository<'cart'> {
custom: custom,
}
},
removeDiscountCode: (
context: RepositoryContext,
resource: Writable<Cart>,
{ discountCode }: CartRemoveDiscountCodeAction
) => {
resource.discountCodes = resource.discountCodes.filter(code => code.discountCode.id !== discountCode.id)
}
}
draftLineItemtoLineItem = (
projectKey: string,
Expand Down

0 comments on commit 6bf7774

Please sign in to comment.