Hi, I am facing issues in adding multiple line in ...
# suitecommerce
s
Hi, I am facing issues in adding multiple line in cart using extensions, I followed the blog written by @Steve Goldberg https://developers.suitecommerce.com/add-items-to-the-cart-with-csv-files. Can any one help what I am doing wrong? I am able to use method addLine which worked correctly.
cart.addLine({
line: {
quantity: accessory.qty,
item: {
internalid: accessory.item
}
}
})
Thi following code failed to add lines to the cart
var lines = [];
accessories.forEach(function(accessory) {
lines.push({
line: {
internalid: accessory.item,
quantity: accessory.qty,
item: {
internalid: accessory.item
}
}
});
});
cart.addLines(lines).then(function() {
console.log("Item added!");
});
s
what i can see is, the issue is coming from the first argument (accessory. item) in the lines.push method.
it should be something like lines.push({item{internalid accessory. itemid},quantity: quantity})
s
addLines()
accepts an array of items passed _as an object in the form of
Cart.addLines({lines: lines})
. You just seem to be passing an array.