Why can I not get the Cart lines and set the `show...
# suitecommerce
k
Why can I not get the Cart lines and set the
showOutOfStockMessage
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.
Copy code
var cart = container.getComponent('Cart');
			
			if(cart)
			{
				cart.addToViewContextDefinition(
					'Cart.Lines.View',
					'showoutofstockmessage',
					'boolean',
					function (context) {
						console.log("Context", context);
Doesnt return anything..
However the below works for the PDP:
var 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; } }); }
If possible, I would like to do the same sorta of logic as the above extension, just within the Cart. Is it possible to do this all within one extension? I kept running into issue where the Cart and PDP component would be true and available at the same time...