
nextQuery("#fsFulfillmentMethod input[type=radio]").click(function ()
{
var radioButton = nextQuery(this);
switch (radioButton.val())
{
case "ShipTo":
nextQuery(".nextShipTo").show();
nextQuery(".nextPickup").hide();
break;
case "PickUp":
nextQuery(".nextShipTo").hide();
nextQuery(".nextPickup").show();
break;
}
});
nextQuery(document).ready(function ()
{
var rbCheckedFulfillmentUiRadio = nextQuery("div[class='ui-radio'] input[data-key='FulfillmentMethod']:checked");
var hfIsAllInventoryInLocationDepleted = nextQuery("input[id*='hfIsAllInventoryInLocationDepleted']");
var inventoryLevel = "None";
if (isAllAttributesSelected(nextQuery("select[id*='sltAttribute']")))
{
// In Stock for this location
if (hfIsAllInventoryInLocationDepleted.val() === "False")
{
// check for shipto/pickup onlys
if (isShipToOnly(rbCheckedFulfillmentUiRadio) || isPickupOnly(rbCheckedFulfillmentUiRadio))
{
if (inventoryLevel === "Product" || inventoryLevel === "Kit" || inventoryLevel === "None")
{
nextQuery("span[id*='lblStatus']").show(); // product level
nextQuery("a[id*='aNotifyInStockProductButton']").show();
nextQuery("span[id*='spnSKUShipText']").hide(); // sku level
nextQuery("a[id*='aNotifyInStockButton']").hide();
}
else if (inventoryLevel === "SKU" || inventoryLevel === "SKU Kit")
{
nextQuery("span[id*='lblStatus']").hide(); // product level
nextQuery("a[id*='aNotifyInStockProductButton']").hide();
nextQuery("span[id*='spnSKUShipText']").show(); // sku level
nextQuery("a[id*='aNotifyInStockButton']").show(); // changing to show() because SKU single doesn't show NotifyInStock link
}
else
{
nextQuery("span[id*='lblStatus']").hide(); // product level
nextQuery("a[id*='aNotifyInStockProductButton']").hide();
nextQuery("span[id*='spnSKUShipText']").hide(); // sku level
nextQuery("a[id*='aNotifyInStockButton']").hide();
}
}
// both shipto and pickup
else
{
if (inventoryLevel === "Product" || inventoryLevel === "Kit" || inventoryLevel === "None")
{
nextQuery("span[id*='lblStatus']").show(); // product level
nextQuery("a[id*='aNotifyInStockProductButton']").show();
nextQuery("span[id*='spnSKUShipText']").hide(); // sku level
nextQuery("a[id*='aNotifyInStockButton']").hide();
}
else if (inventoryLevel === "SKU" || inventoryLevel === "SKU Kit")
{
nextQuery("span[id*='lblStatus']").hide(); // product level
nextQuery("a[id*='aNotifyInStockProductButton']").hide();
nextQuery("span[id*='spnSKUShipText']").show(); // sku level
nextQuery("a[id*='aNotifyInStockButton']").show();
}
else
{
nextQuery("span[id*='lblStatus']").hide(); // product level
nextQuery("a[id*='aNotifyInStockProductButton']").hide();
nextQuery("span[id*='spnSKUShipText']").hide(); // sku level
nextQuery("a[id*='aNotifyInStockButton']").hide();
}
}
}
// Inventory is depleted for this location
else
{
nextQuery("span[id*='lblStatus']").show(); // product level
nextQuery("a[id*='aNotifyInStockProductButton']").show();
nextQuery("span[id*='spnSKUShipText']").hide(); // sku level
nextQuery("a[id*='aNotifyInStockButton']").hide();
}
var values = [];
nextQuery("select.nextAttributeSelect").each(function (index, element)
{
values[index] = nextQuery(element).val();
if (values[index] != "")
values[index] = parseInt(values[index]);
});
var request = {
'ProductID': "3861",
'AttributeIndexChanged': 0,
'Values': values,
'LocationType': getLocationType(rbCheckedFulfillmentUiRadio),
'LocationID': getLocationID(rbCheckedFulfillmentUiRadio)
}
nextQuery("a[id*='aNotifyInStockProductButton']").hide();
nextQuery("a[id*='aNotifyInStockButton']").hide();
mobileWebServices.catalog.post("ResetAttributes", request, function (response)
{
toggleDisplayInStockMessage(response);
// determine which notify me page to display
if (response.AvailableProductRecordsFromOtherLocation.length === 0 || (response.IsSingleInventory && !response.IsKitProduct))
{
nextQuery("div[id*='unavailableEverywhere']").show();
nextQuery("div[id*='availableElsewhere']").hide();
setNotifyMeLinkText(response.NotifyInstock);
}
else
{
nextQuery("div[id*='unavailableEverywhere']").hide();
nextQuery("div[id*='availableElsewhere']").show();
setAvailableElsewhereNotifyMeLinkText();
populateTableOfAvailableElsewhere(response);
}
});
}
// Not all attributes are selected
else
{
nextQuery("span[id*='lblStatus']").hide(); // product level
nextQuery("a[id*='aNotifyInStockProductButton']").hide();
nextQuery("span[id*='spnSKUShipText']").hide(); // sku level
nextQuery("a[id*='aNotifyInStockButton']").hide();
}
// wiring up fulfillment radio button to update the status and Notify Me link display
var rbFulfillmentUiRadio = nextQuery("div[class='ui-radio'] input[data-key='FulfillmentMethod']");
rbFulfillmentUiRadio.each(function (index, element)
{
nextQuery(this).change(function ()
{
mobileAttributes.reset("3861", 0);
});
});
// wiring up Pickup drop downs to update the status and Notify Me link display
var ddlFulfillment = nextQuery("select[id*='ddlShipTo'], select[id*='ddlPickUp']");
ddlFulfillment.each(function (index, element)
{
nextQuery(this).change(function ()
{
mobileAttributes.reset("3861", 0);
});
});
});
function updateHfIsAllInventoryInLocationDepleted(value)
{
nextQuery("input[id*='hfIsAllInventoryInLocationDepleted']").val(value);
}