Created
December 31, 2015 21:31
-
-
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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