Christopher Dembek
03/26/2021, 5:08 PMcart.addLine()
method. Using the cart.cancelableOn('afterAddLine', _function_ (_line_) {})
I am displaying a modal confirmation, once the item has been added to the cart.
The problem I am having is the modal will render twice quickly, once before the item is added to the cart and once after. If I am displaying the modal using afterAddLine and triggering only when the item has a match (because each line is processed), why is the modal displaying twice?
this.cart.cancelableOn('afterAddLine', function (line) {
var model = self.model,
internalid = model.get('internalid');
if (line.line.internalid === internalid) {
// THIS WILL TRIGGER TWICE
console.log('Item 123 is in the cart!');
}
});
SCS 2020.2Steve Goldberg
03/26/2021, 5:26 PMthis.cart.cancelableOn('afterAddLine', function (line) {
var model = self.model,
internalid = model.get('internalid');
hasShown = false;
if (!hasShown && line.line.internalid === internalid) {
// THIS WILL TRIGGER TWICE
console.log('Item 123 is in the cart!');
hasShown = true;
}
});
Christopher Dembek
03/26/2021, 5:29 PM'mouseup [data-action="add-to-cart"]': 'addToCart',
'click [data-action="add-to-cart"]': 'addToCart'
Christopher Dembek
03/29/2021, 3:20 AMDominic B
03/29/2021, 1:01 PMSteve Goldberg
03/29/2021, 1:19 PMSteve Goldberg
03/29/2021, 1:19 PMSteve Goldberg
03/29/2021, 1:19 PMSteve Goldberg
03/29/2021, 1:21 PMline.item.internalid = 8047
, you would need to do something like: line.result = 'item8047set1567'
Steve Goldberg
03/29/2021, 1:21 PMSteve Goldberg
03/29/2021, 1:23 PMafter:LiveOrder.addLines
Steve Goldberg
03/29/2021, 1:23 PMChristopher Dembek
03/30/2021, 11:38 AMtouchEnabled
set to true
. My custom extension displayed multiple items via a bxslider carousel and because touchEnabled
was set to true, the click
event would trigger twice. Solution is either to set touchEnabled
to false
or use mousedown
for the event.