File tree Expand file tree Collapse file tree 2 files changed +19
-14
lines changed Expand file tree Collapse file tree 2 files changed +19
-14
lines changed Original file line number Diff line number Diff line change @@ -202,14 +202,26 @@ class CartEndpoint extends BaseExtend {
202202 } )
203203 }
204204
205- AddPromotion ( code , token = null ) {
206- const body = buildCartItemData ( code , null , 'promotion_item' )
205+ AddPromotion ( code , token = null , currency = null ) {
206+
207+ const additionalHeaders = currency
208+ ? { 'X-MOLTIN-CURRENCY' : currency }
209+ : { }
207210
208211 return this . request . send (
209212 `${ this . endpoint } /${ this . cartId } /items` ,
210213 'POST' ,
211- body ,
212- token
214+ {
215+ data : {
216+ type : 'promotion_item' ,
217+ code
218+ }
219+ } ,
220+ token ,
221+ null ,
222+ null ,
223+ null ,
224+ additionalHeaders
213225 )
214226 }
215227
Original file line number Diff line number Diff line change @@ -350,15 +350,6 @@ export interface CartEndpoint
350350 ShippingGroup : CartShippingGroupBase
351351 ) : Promise < ShippingGroupResponse >
352352
353- /**
354- * Add Promotion to Cart
355- * Description: You can use the Promotions API to apply discounts to your cart as a special cart item type.
356- * DOCS: https://documentation.elasticpath.com/commerce-cloud/docs/api/carts-and-orders/carts/add-promotion-to-cart.html
357- * @param code the promotion code.
358- * @param token a customer token to apply customer specific promotions.
359- */
360- AddPromotion ( code : string , token ?: string ) : Promise < CartItemsResponse >
361-
362353 /**
363354 * Get a Cart by reference
364355 * DOCS: https://documentation.elasticpath.com/commerce-cloud/docs/api/carts-and-checkout/carts/get-a-cart.html
@@ -438,8 +429,10 @@ export interface CartEndpoint
438429 * Description: You can use the Promotions API to apply discounts to your cart as a special cart item type.
439430 * DOCS: https://documentation.elasticpath.com/commerce-cloud/docs/api/carts-and-orders/carts/add-promotion-to-cart.html
440431 * @param code the promotion code.
432+ * @param token a customer token to apply customer specific promotions.
433+ * @param currency the currency to apply the promotion in.
441434 */
442- AddPromotion ( code : string ) : Promise < CartItemsResponse >
435+ AddPromotion ( code : string , token ?: string , currency ?: string ) : Promise < CartItemsResponse >
443436
444437 /**
445438 * Remove promotion from Cart
You can’t perform that action at this time.
0 commit comments