Kevin Carpenter
12/14/2022, 11:43 AMreturn {
mountToApp: function mountToApp (container)
{
// using the 'Layout' component we add a new child view inside the 'Header' existing view
// (there will be a DOM element with the HTML attribute data-view="Header.Logo")
// more documentation of the Extensibility API in
// <https://system.netsuite.com/help/helpcenter/en_US/APIs/SuiteCommerce/Extensibility/Frontend/index.html>
/** @type {LayoutComponent} */
var layout = container.getComponent('Layout');
var Cart = container.getComponent('Cart');
var ctx;
// create a new map for the cart lines with the internalid as the key
var cartLines = new Map();
ctx = {
isCart: false,
};
if(layout)
{
layout.addToViewContextDefinition(
"ProductLine.Stock.View",
"FWCExtras",
"object",
function (context) {
console.log("Is Cart?", SC.Application.getLayout().getCurrentView() instanceof require('Cart.Detailed.View'))
ctx.isCart = SC.Application.getLayout().getCurrentView() instanceof require('Cart.Detailed.View');
if (Cart && SC.Application.getLayout().getCurrentView() instanceof require('Cart.Detailed.View')) {
ctx.isCart = true;
// Get the quantity of the item
var quantityInCart = context.model.quantity;
var isAutoBuild = context.model.item.custitem_auto_build;
var buildableQuantity = context.model.item.custitem_buildable_quantity;
// Cart.getLines().then(function(lines) {
// // cartLines.set(line.internalid, line);
// console.log("Line", lines);
// });
console.log("Context", context);
if (isAutoBuild) {
if (quantityInCart > buildableQuantity) {
ctx.showCartQuantityMessage = true;
ctx.buildableQuantity = buildableQuantity;
}
else {
ctx.showCartQuantityMessage = false;
}
}
return ctx;
}
}
);
}
}
};