Skip to content

Instantly share code, notes, and snippets.

@Mozu-CS
Created December 31, 2015 21:31
Show Gist options
  • Save Mozu-CS/ce5ec644b6fb84882c5e to your computer and use it in GitHub Desktop.
Save Mozu-CS/ce5ec644b6fb84882c5e to your computer and use it in GitHub Desktop.
Arc action to increase quantity of an item when added to a cart -- 4 is arbitrary selected here, but you could substitute this with some other logic or configured variable.
var CartItemFactory = require('mozu-node-sdk/clients/commerce/carts/cartItem');
var CartFactory = require('mozu-node-sdk/clients/commerce/cart');
function itemUpdated(item) {
console.info(item);
callback();
}
module.exports = function (context, callback) {
var cartItemResource = CartItemFactory(context);
var cartResource = CartFactory(context);
var cart = context.get.cart();
var cartItem = context.get.cartItem();
cartItemResource.updateCartItemQuantity({ cartItemId: cartItem.id, quantity: 4 })
.then(itemUpdated)
.catch(function (err) {
console.error(err);
callback();
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment