Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions src/endpoints/cart.js
Original file line number Diff line number Diff line change
Expand Up @@ -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`,
Expand Down
4 changes: 3 additions & 1 deletion src/types/cart.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<CartItemsResponse>
AddPromotion(code: string, token?: string, currency?: string, channel?: string, contextTag?: string): Promise<CartItemsResponse>

/**
* Remove promotion from Cart
Expand Down