Diversey. issue
3.2. MANAGER SHOP ACCOUNT ASSIGNED TO MULTIPLE CHILD CUSTOMER ACCOUNTS
ShopAccountController
public JsonResult IsShopAccountParent(string customerId)
{
var extCustomer = ObjectFactory.Create<CustomerProfile>();
if (customerId != null)
{
var customerLoadOptions = ObjectFactory.Create<ICustomerLoadOptions>();
customerLoadOptions.LoadShippingAddresses = false;
customerLoadOptions.ValidOnly = false;
var customer = CommerceFrameworkBase.Customers.GetCustomer(customerId, customerLoadOptions);
// if customer is null (not available/ invalid customer id)
if (customer == null)
{
return Json(extCustomer);
}
extCustomer = (Sana.Commerce.Customer.CustomerProfile)customer;
}
return Json(extCustomer, JsonRequestBehavior.AllowGet);
}
-----------------------------------------------------------------------------------------------------------------
// This method used to check,is selected item parent customer or Child var checkIsParent = function (item) { var refid = $("#ReferenceId").val(); var role = $('[name="ShopAccountRole"]:checked', shopAccountRoleControl).val(); if (item != "") { var isParentUrl = "/admin/shopaccounts/IsShopAccountParent"; $.ajax({ url: isParentUrl, type: "GET", data: { customerId: item }, //dataType: 'json', async: false, success: (function (result) { // If selected ID is not a Parent (Child) then show add item Button if (result != null) { var isParent = JSON.parse(result.toLowerCase()); if (role == "AccountManager" && isParent === false) { $("#searchboxBtnDiv").show(); $(".panel1").show(); } else { $("#searchboxBtnDiv").hide(); $(".panel1").hide(); } } }) }); } else { $("#searchboxBtnDiv").hide(); $(".panel1").hide(); } };
call this method on javascript button click or any action
checkIsParent(item.Value);
another way .....
//Ticket 100355: [Integria MVP] 3.10.Changes to product list pages(Design) //When user click add to cart button. page.addToWishlist = { selector: '#addToWishlist', init: function () { $(document).on('click', this.selector, function () { var $this = $(this); var url = $this.attr('data-url'); var productId = $this.attr('data-product'); var unitOfMeasureId = $this.attr('data-uom'); var divId = "addOrRemoveWishList_" + productId; var parentDivId = "wishList_" + productId; var data = { productId: productId, unitOfMeasureId: unitOfMeasureId, variantId: $('#product-form [name=variantId]').val(), __RequestVerificationToken: $('input[name="__RequestVerificationToken"]:first').val() }; Sana.UI.LoadingIndicator.show(); ----------- Way 2 ---------------------- $.post(url, data, function (result) { //alert(); Sana.UI.LoadingIndicator.hide(); debugger; if (result != null) { var element = document.getElementById(divId); element.innerHTML = ""; element.innerHTML = result; } }); }); } };
--------------------------- Way 1$.ajax({ url: url, method: "POST", data: data, }).done(function (result) { Sana.UI.LoadingIndicator.hide(); if (result != null) { var element = document.getElementById(parentDivId); element.innerHTML = ""; element.innerHTML = result; } })