Add promotion using extensibility API

Applies a promotion to the cart. If the promotion code is valid and successfully applied to the order, the promotion appears in the cart automatically and the order total is updated.

var cart = container.getComponent("Cart");

if (cart) {
	cart.addPromotion({
		promocode: "5OFF"
	}).then(function(promotion) {
		alert("Promotion added.");
		console.log(promotion);
	}, function() {
		console.log("Could not add promotion.");
	});
}

Returns a Deferred object. If the promise resolved, it returns a Promise object. If the promise is rejected (because the promotion could not be applied), it returns an error message object in JSON format.

Leave a comment

Your email address will not be published. Required fields are marked *