

$(document).ready(function () {
  if ($('body').hasClass("page-productdetails")) {
    //Add Inventory section/table to the page, hide for now
    $('<div class="inventory"><h3>Inventory:</h3><table class="table table-striped table-condensed inventory-table"><thead><th>Name</th><th>On Order</th><th>On Hand</th><th>Available</th></thead><tbody><tr><td class="cg-name"></td><td class="cg-onOrder"></td><td class="cg-onHand"></td><td class="cg-avail"></td></tr></tbody></table></div>').appendTo('.page-productdetails #upnlPreviews').hide();
  }
});
function dmLoad() {
  if ($('body').hasClass("page-productdetails")) {
    // Check for CG levels
    var avail = $('input[id$=hfCustomerGoodAvailable]').val();
    var onHand = $('input[id$=hfCustomerGoodOnHand]').val();
    var onOrder = $('input[id$=hfCustomerGoodOnOrder]').val();
    var cgname = $('#lblItemName').text();
    // If there's a match, display inventory table
    if (avail >= 0) {
      $(".inventory").show();
      //populate with levels
      $('.cg-name').text(cgname);
      $('.cg-onOrder').text(onOrder);
      $('.cg-onHand').text(onHand);
      $('.cg-avail').text(avail);
    }
  }
}
.disabled2 {
    pointer-events: none !important;
    cursor: not-allowed !important;
    filter: alpha(opacity=65);
    -webkit-box-shadow: none;
    box-shadow: none;
    opacity: .65;
}
.inventory-table th:nth-child(2),
.inventory-table th:nth-child(3),
.inventory-table td:nth-child(2),
.inventory-table td:nth-child(3) {
    display: none;
}
$(document).ready(function () {
  if ($('body').hasClass("page-productdetails")) {
    //Add Inventory section/table to the page, hide for now
    $('<div class="inventory"><h3>Inventory:</h3><table class="table table-striped table-condensed inventory-table"><thead><th>Name</th><th>On Order</th><th>On Hand</th><th>Available</th></thead><tbody><tr><td class="cg-name"></td><td class="cg-onOrder"></td><td class="cg-onHand"></td><td class="cg-avail"></td></tr></tbody></table></div>').appendTo('.page-productdetails #upnlPreviews').hide();
  }
});
function dmLoad() {
  if ($('body').hasClass("page-productdetails")) {
    // Check for CG levels
    var avail = $('input[id$=hfCustomerGoodAvailable]').val();
    var onHand = $('input[id$=hfCustomerGoodOnHand]').val();
    var onOrder = $('input[id$=hfCustomerGoodOnOrder]').val();
    var cgname = $('#lblItemName').text();
    // If there's a match, display inventory table
    if (avail >= 0) {
      $(".inventory").show();
      //populate with levels
      $('.cg-name').text(cgname);
      $('.cg-onOrder').text(onOrder);
      $('.cg-onHand').text(onHand);
      $('.cg-avail').text(avail);
      //Set variable "selectedQuantity" to either the selected quantity in table OR value of quantity field
      var selectedQuantity;
      if ($(".product-quantity-table")[0]) {
        selectedQuantity = parseInt($('.product-quantity-table input:checked').closest("td").next('td').find('span').text());
      } else {
        selectedQuantity = parseInt($('#txtQuantity').val());
      }
      // If the requested quantity is more than the available quantity, insert warning after disabled button
      if (selectedQuantity > avail) {
        $("#btnAddToCart").addClass("disabled2");
        $("<div class='warning text-right'>The quantity selected is more than what we currently have available.</div>").insertAfter('#upnlPricing');
        $("#btnAddToCart").val("Out of Stock");
        // If not, enable the button and remove the warning
      } else {
        $("#btnAddToCart").removeClass("disabled2");
        $(".warning").hide();
      }
    }
  }
}
.disabled2 {
    pointer-events: none !important;
    cursor: not-allowed !important;
    filter: alpha(opacity=65);
    -webkit-box-shadow: none;
    box-shadow: none;
    opacity: .65;
}
.page-productlist .product-quantities-container,
.page-search .product-quantities-container,
.page-favorites .product-quantities-container {
    display: none;
}
If you have any ideas for portal customizations you'd like to see us tackle or need help implementing any of this code, email our support team at support@docketmanager.ca