Skip to content

Commit c701a59

Browse files
authored
feat(carts): add support for cart removeDiscountCode action (#112)
* feat: add support for cart removeDiscountCode action * chore: run format
1 parent 127cee2 commit c701a59

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

src/repositories/cart.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import type {
2121
Price,
2222
Product,
2323
ProductPagedQueryResponse,
24+
CartRemoveDiscountCodeAction,
2425
ProductVariant,
2526
} from '@commercetools/platform-sdk'
2627
import { v4 as uuidv4 } from 'uuid'
@@ -415,6 +416,15 @@ export class CartRepository extends AbstractResourceRepository<'cart'> {
415416
custom: custom,
416417
}
417418
},
419+
removeDiscountCode: (
420+
context: RepositoryContext,
421+
resource: Writable<Cart>,
422+
{ discountCode }: CartRemoveDiscountCodeAction
423+
) => {
424+
resource.discountCodes = resource.discountCodes.filter(
425+
(code) => code.discountCode.id !== discountCode.id
426+
)
427+
},
418428
}
419429
draftLineItemtoLineItem = (
420430
projectKey: string,

0 commit comments

Comments
 (0)