By default we will be having “Out of Stock” as message and if we install stock notification bundle the the Out of stock message as “Out of Stock – Will ship when available” and if we want to replace for example “–” to item then :
// This view is extended to display in & out of stock messages.
_.extend(ProductLineStockView.prototype, {
getContext: _.wrap(ProductLineStockView.prototype.getContext, function (fn) {
try {
var original = fn.apply(this, _.toArray(arguments).slice(1));
var quantityavailable = this.stock_info.stock;
var showInStockMessage;
var showOutOfStockMessage;
var pdpOutOfStockMessage = original.stockInfo.outOfStockMessage;
var dataView = this.attributes["data-root-component-id"];
if (dataView === 'ProductDetails.Full.View') {
showInStockMessage = quantityavailable !== 0;
showOutOfStockMessage = !showInStockMessage;
original.quantityavailable = quantityavailable;
original.showInStockMessage = showInStockMessage;
original.showOutOfStockMessage = showOutOfStockMessage;
original.stockInfo.outOfStockMessage = pdpOutOfStockMessage.replace('–', 'item');
return original;
}
} catch (e) {
console.log('Error:', e);
}
}),
});