Dominic B
03/23/2021, 4:39 PMChristopher Dembek
03/23/2021, 4:41 PMDominic B
03/23/2021, 4:52 PMSteve Goldberg
03/23/2021, 5:47 PMcontainer.getComponent('Cart').cancelableOn('afterUpdateLine', function (line) {
if (line.internalid === '123') {console.log('Item 123 is in the cart!')}
})
Steve Goldberg
03/23/2021, 5:48 PMgetLatestAddition()
method to specifically return the line item that was last added.Christopher Dembek
03/24/2021, 5:56 PMSteve Goldberg
03/24/2021, 6:08 PMDominic B
03/25/2021, 1:24 PMSteve Goldberg
03/25/2021, 1:32 PMChristopher Dembek
03/25/2021, 1:40 PMvar self = this;
this.cart.addLine({
line: {
quantity: 1,
item: {
internalid: self.model.get('internalid'),
}
}
}).then(
function onSuccess(line) {
// get data of recently item added to the cart
var cartLines = self.cart.getLines().then(function (cartLines) {
var currentLine;
// get item data of added item
_.each(cartLines, function (cartLine) {
if(line === cartLine.internalid){
// do something
};
});
});
},
function onError() {
// error code
}
);