//NEW Cart Start******************
// ProductList plus button click
function qtyplusClick1(sender) {
var selectedValue = "";
if (sender.parentNode != null)
selectedValue = $("#ddlActualVolumePrice option:selected", sender.parentNode).val();
else
selectedValue = sender;
var count=CheckIsCountOne(selectedValue.split('|')[0]);
if (count < 20)
{
if (selectedValue.split("|")[1] == 1) //Restricted Product Check
{
$("#hdnSPStockid").val(selectedValue.split("|")[0]);
CheckIsRestrictedDelivery(selectedValue.split("|")[0]);
}
else {
UpdateProductList1('add', (selectedValue).split('|')[0]);
Materialize.toast('Added to cart', 300);
}
}
}
function ShowPicodePopup() {
if ($("#hdnPincode").val().length == 0) {
$("#PopUpPincodeCheck").css("display", "block");
return; // It will not add product to cart and open popup
}
else {
$("#PopUpPincodeCheck").css("display", "block");
document.getElementById("txtPincode").value = $("#hdnPincode").val();
$("#txtPincode").focus();
return;
}
//if (($("#hdnPincode").val() == "" && document.getElementById("txtPincode").value == "") || ($("#hdnPincode").val() == "" && document.getElementById("txtPincode").value != "")
// || ($("#hdnPincode").val() != document.getElementById("txtPincode").value && document.getElementById("txtPincode").value == ""))
//{
// if ($("#hdnPincode").val().length == 0) {
// $("#PopUpPincodeCheck").css("display", "block");
// return; // It will not add product to cart and open popup
// }
// else {
// $("#PopUpPincodeCheck").css("display", "block");
// document.getElementById("txtPincode").value = $("#hdnPincode").val();
// $("#txtPincode").focus();
// return;
// }
//}
}
// Check IsRestricted Delivery
function CheckIsRestrictedDelivery(selectedSPStockID) {
if (($("#hdnRestrictedSPStockid").val()).toLowerCase().indexOf(selectedSPStockID) >= 0) {
//Materialize.toast('The selected product is Restricted with your pincode.', 800);
Materialize.toast('The selected product is not available in your pincode.Change Pincode', 2000)
UpdateProductList1('remove', selectedSPStockID)
return;
}
else {
if ($("#hdnPincode").val().length == 0) {
$("#PopUpPincodeCheck").css("display", "block");
return; // It will not add product to cart and open popup
}
else {
$("#PopUpPincodeCheck").css("display", "block");
document.getElementById("txtPincode").value = $("#hdnPincode").val();
$("#txtPincode").focus();
return;
}
}
}
// ProductList minus button click
function qtyminusClick1(sender) {
var selectedValue = "";
if (sender.parentNode != null)
selectedValue = $("#ddlActualVolumePrice option:selected", sender.parentNode).val();
else
selectedValue = sender;
var count=CheckIsCountOne(selectedValue.split('|')[0]);
if (count > 1) {
UpdateProductList1('subtract', (selectedValue.split('|')[0]));
Materialize.toast('Reduced from cart', 300);
}
}
function CheckIsCountOne(sellerStockId) {
var count;
$.ajax({
type: "POST",
url: "/ProductList.aspx/CheckProductCount",
dataType: "json",
async: false,
data: JSON.stringify({ sellerStockId: sellerStockId }),
contentType: "application/json; charset=utf-8",
success: function (resp) {
count= resp.d;
},
error: function (xhr, status, error) {
//var err = eval("(" + xhr.responseText + ")");
//Materialize.toast(err.Message, 4000);
}
});
return count;
}
// Product remove
function removeProduct(sender, ctrl) {
UpdateProductList1('remove', sender);
ctrl.parentNode.parentNode.remove();
}
function qtyCartPlusClick1(value, txtCartCount) {
var count = parseInt($("#txtCartCount", txtCartCount.parentNode).val());
var price = parseInt($("#spnPrice", txtCartCount.parentNode).html().split('/')[0]);
if (count < 20) {
count = count + 1;
$("#txtCartCount", txtCartCount.parentNode).val(count);
$("#spnTotal", txtCartCount.parentNode).html(count * price);
qtyplusClick1(value);
} else {
Materialize.toast( "Sorry, the Maximum no.of product for single purchase reached.", 4000);
}
}
function qtyCartMinusClick1(value, txtCartCount) {
var count = parseInt($("#txtCartCount", txtCartCount.parentNode).val());
var price = parseInt($("#spnPrice", txtCartCount.parentNode).html().split('/')[0]);
if (count > 1) {
count = count - 1;
$("#txtCartCount", txtCartCount.parentNode).val(count);
$("#spnTotal", txtCartCount.parentNode).html(count * price);
qtyminusClick1(value);
}
}
// UpdateProductList Click //
function UpdateProductList1(type, value) {
var quantity = 0;
if (type == 'add') quantity = 1;
else if (type == 'subtract') quantity = -1;
else if (type == 'remove') quantity = 0;
$.ajax({
type: "POST",
url: "/ProductList.aspx/ManageCart",
dataType: "json",
async: false,
data: JSON.stringify({ SellerStockId: value, Quantity: quantity }),
contentType: "application/json; charset=utf-8",
success: function (resp) {
if (resp.d.indexOf("Sorry") < 0) {
$("#spanNetTotal").html(parseFloat(JSON.parse(resp.d).NetTotal).toFixed(2));
$("#spanCartCount").html(JSON.parse(resp.d).TotalCount);
if ($("#lblSumOfCart") != null) // Cart Total - Right Slide
$("#lblSumOfCart").html(parseFloat(JSON.parse(resp.d).NetTotal).toFixed(2));
if (parseInt(JSON.parse(resp.d).TotalCount) == 0) {
$("#lblEmpty").css("display", "block");
$("#CartTotal").css("display", "none");
$("#aBuyNow").css("display", "none");
} else {
$("#lblEmpty").css("display", "none");
$("#CartTotal").css("display", "block");
$("#aBuyNow").css("display", "block");
$("#lblSumOfCart").val(parseFloat(JSON.parse(resp.d).NetTotal).toFixed(2));
}
if (parseInt(JSON.parse(resp.d).Discount) != 0) {
document.getElementById("lblDiscount").innerHTML = " ₹ " + parseFloat(JSON.parse(resp.d).Discount).toFixed(2);
document.getElementById("lblDiscount").style.color = "rgb(0, 150, 136)";
document.getElementById("divcardiscount").style.display = "block";
} else {
document.getElementById("divcardiscount").style.display = "none";
document.getElementById("lblDiscount").innerHTML = "";
}
// if (resp.d.ProductRestrictions != null) {
// if (resp.d.ProductRestrictions == "Un-Minus") {
// alert("unable to minus the count");
// } else {
// displayRestrictionMessage(resp.d.ProductRestrictions);
// }
// }
// else
// bindCartDetails(resp);
} else {
Materialize.toast(resp.d, 4000);
return false;
}
},
error: function (xhr, status, error) {
var err = eval("(" + xhr.responseText + ")");
Materialize.toast(err.Message, 4000);
}
});
}
function GetCartDetails1() {
$.ajax({
type: "POST",
url: "/ProductList.aspx/GetCartDetails",
dataType: "json",
data: JSON.stringify({ visitorId: '' }),
contentType: "application/json; charset=utf-8",
success: function (resp) {
// alert(resp);
bindCartDetails1(resp);
},
error: function (err, errtext, fn) {
//errorResponse(err, errtext);
//alert(errtext);
}
});
}
function bindCartDetails1(resp) {
var imgUrl = 'http://cdn1.Myrightbuy.com/images/';
var len = resp.d.ProductList.length;
$("#tblCart").html('');
if (len != '0') {
for (var i = 0; i < len; i++) {
var div = $("#divCartProductListDesign").eq(0).clone(true);
$("#divCartProductList", div).css("display", "block");
$("#divCartProductList", div).attr("ID", "divCartProductList1");
$("#hrfRemove", div).attr('onclick', 'removeProduct(\'' + resp.d.ProductList[i]["SellerProductStockId"] + '\',this)');
$("#btnCartPlus", div).attr('onclick', 'qtyCartPlusClick1(\'' + resp.d.ProductList[i]["SellerProductStockId"] + '\' ,this )');
$("#btnCartMinus", div).attr('onclick', 'qtyCartMinusClick1(\'' + resp.d.ProductList[i]["SellerProductStockId"] + '\' ,this )');
$("#imgProduct", div).attr("src", imgUrl + resp.d.ProductList[i]["ImageName"].replace('_Thumb', '_m').replace('_Thump', '_m'));
$("#spnProductName", div).html(resp.d.ProductList[i]["ProductName"]);
$("#spnPrice", div).html(resp.d.ProductList[i]["Price"] + " / " + resp.d.ProductList[i]["Volume"]);
if (parseInt(resp.d.ProductList[i]["Quantity"]) != 0)
$("#spnTotal", div).html(parseInt(resp.d.ProductList[i]["Price"]) * parseInt(resp.d.ProductList[i]["Quantity"]));
else
$("#spnTotal", div).html(parseInt(resp.d.ProductList[i]["Price"]) * parseInt(1));
if (parseInt(resp.d.ProductList[i]["Quantity"]) != 0)
$(".txtqty", div).val(resp.d.ProductList[i]["Quantity"]);
else
$(".txtqty", div).val(1);
$("#tblCart").append(div);
}
$("#tblCart").css('max-height', (parseInt(screen.height) - parseInt(340)) + "px");
//$("#tblCart").innerHTML = $("#tblCart").innerHTML.replace('divCartProductList', 'divCartProductList1');
document.getElementById("CartTotal").style.display = "block";
document.getElementById("lblSumOfCart").innerHTML = parseFloat(resp.d.NetTotal).toFixed(2);
document.getElementById("spanCartCount").innerHTML = parseInt(resp.d.TotalCount);
if (document.getElementById("spanNetTotal") != null)
document.getElementById("spanNetTotal").innerHTML = parseFloat(resp.d.NetTotal).toFixed(2);
if (parseInt(resp.d.Discount) != 0) {
document.getElementById("lblDiscount").innerHTML = " ₹ " + parseFloat(resp.d.Discount).toFixed(2);
document.getElementById("lblDiscount").style.color = "rgb(0, 150, 136)";
document.getElementById("divcardiscount").style.display = "block";
} else {
document.getElementById("divcardiscount").style.display = "none";
document.getElementById("lblDiscount").innerHTML = "";
}
document.getElementById("tblCart").style.borderTop = "1px solid #FFB400";
document.getElementById("aBuyNow").style.display = "block";
} else {
document.getElementById("lblEmpty").style.display = "block";
document.getElementById("divcardiscount").style.display = "none";
}
}
// To Check Pincode entered by user for checking delivery availabilty.
function ValidatePincode() {
var pincode = document.getElementById("txtPincode").value;
$("#hdnPincode").val(pincode);
var spStockId = document.getElementById("hdnSPStockid").value;
if (pincode != "" && pincode.length == 6) {
$.ajax({
type: "POST",
url: "/ProductList.aspx/ValidatePincode",
dataType: "json",
data: JSON.stringify({ pincode: pincode, sellerProductStockId: spStockId }),
contentType: "application/json; charset=utf-8",
async: false,
success: function (response) {
if (JSON.parse(response.d).HomeDelivery == 0 && JSON.parse(response.d).Delivery == 0 && JSON.parse(response.d).RestrictedDelivery == 0 ) {
document.getElementById("PopUpPincodeCheck").style.display = "none";
Materialize.toast('The selected product is Restricted with your pincode.Change Pincode', 2000)
UpdateProductList1('remove', spStockId)
return;
}
else {
document.getElementById("PopUpPincodeCheck").style.display = "block";
document.getElementById("divPincodeResponse").style.display = "block";
document.getElementById("divPincodeFooter").style.display = "block";
if (JSON.parse(response.d).HomeDelivery != 1) {
document.getElementById("lblHomeDelivery").innerHTML = " " +
"Cash On Delivery : Not Availlable ";
} else {
document.getElementById("lblHomeDelivery").innerHTML = " " +
"Cash On Delivery : Availlable ";
}
if (JSON.parse(response.d).Delivery == 1) {
document.getElementById("lblDelivery").innerHTML = " " +
" Delivery : " +
"Available ";
}
else {
document.getElementById("lblDelivery").innerHTML = " " +
" Delivery : " +
"Not Available ";
}
if (JSON.parse(response.d).RestrictedDelivery == 0) {
SaveRestrictedSPStockId(spStockId);
document.getElementById("lblDeliveryMsg").innerHTML = 'Sorry! The product you added is restricted for the address(pincode) you entered. You may not able to add this product.' +
'Or You should have to change the delivery address(pincode) to get this product.';
document.getElementById("lblDelivery").innerHTML = " " +
" Delivery : " +
"Not Available ";
$('#hrfContinue').attr('onclick', 'pincodeContinue_Click(0)');
UpdateProductList1('remove', spStockId);
}
else {
$("#hdnRestrictedSPStockid").val("");
document.getElementById("lblDeliveryMsg").innerHTML = "";
$('#hrfContinue').attr('onclick', 'pincodeContinue_Click(1)');
}
}
if (JSON.parse(response.d).RestrictedDelivery == 0) {
SaveRestrictedSPStockId(spStockId);
document.getElementById("lblDeliveryMsg").innerHTML = 'Sorry! The product you added is restricted for the address(pincode) you entered. You may not able to add this product.' +
'Or You should have to change the delivery address(pincode) to get this product.';
document.getElementById("lblDelivery").innerHTML = " " +
" Delivery : " +
"Not Available ";
$('#hrfContinue', div).attr('onclick', 'pincodeContinue_Click(0)');
}
else {
document.getElementById("lblDeliveryMsg").innerHTML = "";
$('#hrfContinue').attr('onclick', 'pincodeContinue_Click(1)');
}
},
failure: function (response) {
//alert(rda);
},
error: function (xhr, status, error) {
var err = eval("(" + xhr.responseText + ")");
Materialize.toast(err.Message, 4000);
}
});
}
else {
Materialize.toast("Please enter valid 6 digit pincode.", 4000);
}
}
function SaveRestrictedSPStockId(spStockId) {
$.ajax({
type: "POST",
url: "/ProductList.aspx/SaveRestrictedSPStockId",
dataType: "json",
async: false,
data: JSON.stringify({ sellerProductStockId: spStockId }),
contentType: "application/json; charset=utf-8",
success: function (resp) {
if (resp.d != "") {
$("#hdnRestrictedSPStockid").val(resp.d);
}
},
error: function (xhr, status, error) {
//var err = eval("(" + xhr.responseText + ")");
//Materialize.toast(err.Message, 4000);
}
});
}
function pincodeContinue_Click(status) {
if (status == 1) {
UpdateProductList1('add', document.getElementById("hdnSPStockid").value);
}
document.getElementById("PopUpPincodeCheck").style.display = "none";
document.getElementById("divPincodeResponse").style.display = "none";
document.getElementById("divPincodeFooter").style.display = "none";
}
//NEW Cart End
// Filter Starts
// NEW****
function LoadFilters() {
if (document.getElementById("divCategoryFilter").innerHTML.trim() == '' || document.getElementById("divBrandFilter").innerHTML.trim() == '') {
if (window.location.href.indexOf("q") == -1) {
Url = "/ProductList.aspx/LoadFilterByCategory";
data1 = '{SelectedCategory: ' + JSON.stringify(document.getElementById("hdnSelectedCategory").value) + '}';
} else {
searchString = GetParameterValues("q");
Url = "/ProductList.aspx/LoadFilterByKeyword";
data1 = '{keyword: ' + JSON.stringify(searchString) + '}';
}
$.ajax({
type: "POST",
url: Url,
dataType: "json",
data: data1,
contentType: "application/json; charset=utf-8",
success: function (result) {
BindCheckBoxList(result);
},
error: function (xhr, status, error) {
var err = eval("(" + xhr.responseText + ")");
alert(err.Message);
}
});
}
}
function BindCheckBoxList(result) {
var items = JSON.parse(result.d);
CreateCheckBoxList(items);
}
function CreateCheckBoxList(checkboxlistItems) {
var tableItem = $('
');
var tableBrand = $('');
var counter = 0;
$(checkboxlistItems).each(function () {
if (this.Type == 1) {
tableItem.append($('
').append($(' | ').append($('').attr({
type: 'checkbox',
name: 'chkItem',
value: this.Value,
id: 'chklistitem' + counter
})).append(
$('