Kevin Carpenter
12/12/2022, 6:05 PMshowOutOfStockMessage
boolean like I can in the PDP.ProductLine.Stock.View
?
What am I doing wrong? Interestingly enough, I don't see the `product_line_stock`in the cart markup like I do on the PDP.
var cart = container.getComponent('Cart');
if(cart)
{
cart.addToViewContextDefinition(
'Cart.Lines.View',
'showoutofstockmessage',
'boolean',
function (context) {
console.log("Context", context);
Doesnt return anything..Kevin Carpenter
12/12/2022, 6:05 PMvar PDP = container.getComponent('PDP');
if (PDP) {
PDP.addToViewContextDefinition(
"ProductLine.Stock.View",
"showOutOfStockMessage",
"boolean",
function (context) {
var stockBoolean, iteminfo;
iteminfo = PDP.getSelectedMatrixChilds();
if (iteminfo) {
// console.log("Item Info: " , iteminfo[0]);
var autoBuild = iteminfo[0]?.custitem_auto_build || undefined;
if (autoBuild != undefined) {
console.log("Auto Build: " , autoBuild);
}
var buildableQuantity = iteminfo[0]?.custitem_buildable_quantity || undefined;
if (buildableQuantity != undefined) {
console.log("Buildable Quantity: " , buildableQuantity);
}
// if autoBuild is true
if (autoBuild) {
// if buildableQuantity is greater than 0
if (buildableQuantity > 0) {
// set the ctx boolean to false
stockBoolean = false;
}
else {
stockBoolean = true;
}
}
else {
stockBoolean = iteminfo[0]?.showoutofstockmessage || false;
}
return stockBoolean;
}
});
}Kevin Carpenter
12/12/2022, 6:07 PM