We can show a static ETA day as an ETA date in MM/DD/YYYY format, and that day is n days from today, and n days are dynamically gotten from the website configuration by using the below solution.
JSON
{
"type": "object",
"subtab":
{
"id": "pdp_products_eta_time",
"title": "Products ETA",
"description": "The data table for SKU, Date and Quantity",
"group": "shoppingApplication"
},
"properties":
{
"pdpETA.etaDays":
{
"group": "shoppingApplication",
"subtab": "pdp_products_eta_time",
"title": "Products ETA",
"type": "string",
"description": "The number of days for ETA which is not availale in the Purchase Order."
}
}
}{
"type": "object",
"subtab":
{
"id": "pdp_products_eta_time",
"title": "Products ETA",
"description": "The data table for SKU, Date and Quantity",
"group": "shoppingApplication"
},
"properties":
{
"pdpETA.skuInfo":
{
"group": "shoppingApplication",
"subtab": "pdp_products_eta_time",
"type": "array",
"title": "Products ETA",
"description": "The data table for ETA which is not availale in the Purchase Order.",
"items":
{
"type": "object",
"properties":
{
"itemsku":
{
"type": "string",
"title": "Item # (SKU)",
"description": "Enter the SKU value",
"mandatory": true
},
"etadate":
{
"type": "string",
"title": "ETA Date",
"description": "Enter the ETA value",
"mandatory": true
},
"etaquantity":
{
"type": "string",
"title": "Quantity",
"description": "Enter the Quantity value",
"mandatory": true
}
}
},
"default": [
{
"sku": "",
"date": "",
"quantity": ""
}]
}
}
}{
"type": "object",
"subtab":
{
"id": "pdp_products_eta_time",
"title": "Products ETA",
"description": "The data table for SKU, Date and Quantity",
"group": "shoppingApplication"
},
"properties":
{
"pdpETA.etaDays":
{
"group": "shoppingApplication",
"subtab": "pdp_products_eta_time",
"title": "Products ETA",
"type": "string",
"description": "The number of days for ETA which is not availale in the Purchase Order."
}
}
}
JavaScript:
let today = new Date();
let currentDate = '' + (today.getUTCMonth() + 1) + '-' + today.getUTCDate() + '-' + today.getUTCFullYear();
let updatedCurrentDate = new Date(currentDate.replace(/-/g,'/'));
let itemid = this.model.get('itemid');
let staticETA = _.filter(SC.CONFIGURATION.pdpETA.skuInfo, function (data) {
var updatedEtaDate = new Date(data.etadate.replace(/-/g,'/'));
return data.itemsku == itemid && updatedCurrentDate < updatedEtaDate;
})
if (quntityavail == 0) {
if (!etaduedate && staticETA[0]) {
let staticETADate = staticETA[0].etadate;
var updatedEtaDate = new Date(staticETADate.replace(/-/g,'/'));
if ( updatedCurrentDate < updatedEtaDate) {
etaduedate = staticETA[0].etadate.replace(/-/g, '/');
quanitityonOrder = staticETA[0].etaquantity;
}
}