// This variable is used to check if the related items feature is turned on or off. // In document.ready on catalogue_list, catalogue_detail, catalogue_latest, and catalogue_seach // this variable is set to 1 if the feature is turned on, else it stays at 0 var bRelatedItems = 0; // UPDATE BASKET COUNT // =================== // - function to update the counter shown on the web site of how many items are in the basket function fShopBasketUpdateCounter() { // define the url to call sAjaxURL = "ajax/shop_basket_item-count.php"; // open URL using AJAX $.get(sAjaxURL, function(data) { // get the result $('.result').html(data); // save the results var nShopBasketItemCount = parseInt(data); // update the div document.getElementById('nShopBasketItemCount').innerHTML=nShopBasketItemCount; $(".nShopBasketItemCount").html(nShopBasketItemCount); }); } // ADD TO BASKET // ============== // - used on catalogue_list.php and catalogue_detail.php // - needs dialogAddToBasket_Inner to be on the page // - is reliant on various fields being in place on the page (bShopLimitOrderByStockLevels) // show buy modal // =============== function fBuy_ShowModal(nShopProd_ID) { // load the add to basket modal $nVariation_ID = 0; nNewShopProd_ID = 0; if($("#nShopProdOption_ID").length!=0&&$("#productsList").length==0) { $nVariation_ID = $("#nShopProdOption_ID").val(); if($nVariation_ID==0) return; } else $nVariation_ID=0; $( "#dialogAddToBasket" ).dialog(); $( "#dialogAddToBasket" ).dialog( "option", "height", 550 ); $( "#dialogAddToBasket" ).dialog( "option", "width", 500 ); // get the add form page $.get('ajax/shop_basket_add_form.php?nShopProd_ID='+nShopProd_ID+'&nVariation_ID='+$nVariation_ID, function(data) { // get the result $('.result').html(data); // save to the empty div in the modal box we have just loaded $('#dialogAddToBasket_Inner').html(data); }); } // add to basket validate function (called by the add to basket button) // ===================================================================== function fBuy_AddToBasket_Validate(nShopProd_ID, nParentShopProd_ID, bShopLimitOrderByStockLevels, bCalledFromModal) { // Store this pages nShopProd_ID nCurrentShopProd_ID = nParentShopProd_ID; // If a variation nShopProd_ID has been selected from drop downs, use that if(nNewShopProd_ID!=0) { nShopProd_ID = nNewShopProd_ID; } // If we have multiple nQty boxes, they're displaying a variation table var bMultipleVariationsInTable = 0; if($("input[name$='_nQty']").length) { bMultipleVariationsInTable = 1; var bError = 0; $("input[name$='_nQty']").each(function(){ if(bError) return; if($(this).val()==="") $(this).val("0"); if(!$.isNumeric($(this).val())) { bError = 1; alert("Please check the quantity you're trying to add to the basket"); $(this).focus(); return; } }); if(bError) return; } else { // validate qty // ============= var nQty = document.getElementById('nQty').value; // get the value form the qty box if ( (nQty=="") || (!$.isNumeric(nQty)) ) { // check that it has a valid value // if not, display an error and exit alert("Please check the quantity you're trying to add to the basket"); return; } } // check if they have agreed to the delivery lead times // ===================================================== // we gonna check if an id exists if ($('#bDelivery_LeadTimes_VisitorMustAgreeToLeadTimeWhenAddingToBasket').length > 0) { // the id exists! so lets check if the checkbox is checked if (!$('#bDelivery_LeadTimes_VisitorMustAgreeToLeadTimeWhenAddingToBasket').is(':checked')) { // it isnt checked so tell them to sort it out and tick the box to agree and return false so that they cant buy it alert("Please tick the checkbox to confirm you are happy with the delivery information quoted on the page"); return false; } } // validate option (if applicable) // ================================ var bVariationCheck = 1; $("select[name$='nShopProdVariationOption_ID']").each(function(){ if($(this).val()=="0") { bVariationCheck = 0; } }); if (bVariationCheck == 0) { alert("Please choose an option from the drop down menu of which version of this item you would like"); return; } // validate required fields // ================================ // Set a flag depending on whether or not it fails var bValidationCheck = 1; // Loop through all required inputs $(":input").filter("[required]").each(function(){ // Check if it has no value if($(this).val()=="" && bValidationCheck) { // If the value is empty/blank, they haven't filled in a required field, tell them so! alert("Please fill in all of the required fields!"); bValidationCheck = 0; $(this).focus(); return; } }); if(!bValidationCheck) return; // check that they aren't already ordering more than available // ============================================================ if (bShopLimitOrderByStockLevels==1) { // check bShopLimitOrderByStockLevels which defines whether to limit by stock levels (this comes from the Settings managed in the WSM) if(!bMultipleVariationsInTable) fStockCheck([nShopProd_ID], [nQty], nShopProd_ID, bCalledFromModal); else { var aShopProd_IDs = []; var aQtys = []; $("input[name$='_nQty']").each(function(){ aShopProd_IDs.push($(this).attr("name").replace("_nQty", "")); aQtys.push($(this).val()); }); fStockCheck(aShopProd_IDs, aQtys, nShopProd_ID, bCalledFromModal); } } else { // log this in goal tracking $.get("ajax/shop_basket_goal-track.php?nShopProd_ID="+nShopProd_ID, function(GoalScript) { $("head").append(GoalScript); }); // call add to basket go function if(!bMultipleVariationsInTable) fBuy_AddToBasket_Go([nShopProd_ID], [nQty], nParentShopProd_ID, bCalledFromModal); else { var aShopProd_IDs = []; var aQtys = []; $("input[name$='_nQty']").each(function(){ if(parseInt($(this).val())) { aShopProd_IDs.push($(this).attr("name").replace("_nQty", "")); aQtys.push($(this).val()); } }); fBuy_AddToBasket_Go(aShopProd_IDs, aQtys, nParentShopProd_ID, bCalledFromModal); } } } // function to check stock // ======================== function fStockCheck(aShopProd_IDs, aQtys, nParentShopProd_ID, bCalledFromModal) { // Check to see if all the stock is valid var bStockAllValid = 1; // For each product for(var i=0; i nStockAvailable) { // Mark this stock check as invalid bStockAllValid = 0; // log this in the goal tracking $.ajax({ url:"ajax/shop_basket_goal-track_out-of-stock.php?nShopProd_ID="+nShopProd_ID, async:false }).done(function(GoalScript) { $("head").append(GoalScript); }); // display an error message // work out how many are in the basket so this can be reflected in the error message (if applicable) $.ajax({ url:sAjaxURL_ForStockInBasket, async:false }).done(function(data) { // get the result $('.result').html(data); // save the results var nStockInBasket = parseInt(data); // populate the start of the error message var sError = "I'm sorry but we can't add the required quantity of this item into your basket because we don't have enough available.\n\nPlease find information below\n\n=================================="; // add information // qty user is trying to add sError += "\n\nNumber you're trying to add to the basket: " + nQty; // qty available sError += "\n\nNumber we have available: " + nStockAvailable; // qty in basket if (nStockInBasket>0) { sError += "\n\nNumber already in your basket: " + nStockInBasket; } // output the error alert(sError + "\n"); }); } }); } // If all the stock checks are valid, send them through to the add to basket function if(bStockAllValid) fBuy_AddToBasket_Go(aShopProd_IDs, aQtys, nParentShopProd_ID, bCalledFromModal); } // add to basket go function // ========================= var aMessages = []; function fBuy_AddToBasket_Go(aShopProd_IDs, aQtys, nParentShopProd_ID, bCalledFromModal) { var oData = null; var nShopProd_ID = null; var nQty = null; var bRelatedItemsTrigger = 0; var sMessage = ""; // For each product, add it to the basket! for(var i=0; i= 0) bRelatedItemsTrigger = 1; // close the modal window (if this has been called from the modal) sMessage+= sData+"
"; }); } if (bCalledFromModal==1) { $( "#dialogAddToBasket" ).dialog( "close" ); } // update the basket counter fShopBasketUpdateCounter(); // alert the results //alert(sData); fShowPageMessage(sMessage); // RELATED ITEMS SYSTEM // ==================== if(bRelatedItems) { // Check if item was successfully added to the basket, if so then show the related items modal, if not then don't if(bRelatedItemsTrigger) { $("#page-message-modal").on("hidden.bs.modal", function(){ if(aMessages.count > 0) return; // Check for related items for the product that has been added to basket // ===================================================================== // Create FormData() variable to pass information to AJAX file var oData = new FormData(); // Create string to store what's going into the modal var sModalData = ""; // Create array to store all related items so we can check if an item already exists before we store it in the modal data var aRelatedItems = new Array(); // Append trigger nShopProd_ID to related items array so the same item doesn't get shown as a related item that has just been bought aRelatedItems.push(parseInt(nShopProd_ID)); // Append nShopProd_ID to be passed through AJAX oData.append("nShopProd_ID", nShopProd_ID); // AJAX function to return all rules triggered by product added to basket $.ajax({ url: 'ajax/shop_basket_add_exec_related-item-rules_get-rules-for-trigger-product.php', method: 'POST', data: oData, processData: false, contentType: false }).success(function(sData){ // GET ALL RULES TRIGGERED BY THIS PRODUCT // ======================================= // Parse JSON Data to get rules var oRuleResult = JSON.parse(sData); // If the parsed data isn't empty, there are rules triggered by this product if(oRuleResult.length > 0) { // Set flag to 0 so we can check if new items exist for this rule that haven't already // been shown. If there aren't any new items then we won't store the rule explanation // as we won't want to show an empty rule with no related items, or a rule with duplicate // related items //var bNewItemsFlag = 0; // FOR EACH RULE // ============= // A callback function to parse the rule results and get related items for each rule function ajaxLoop(nCurrentIndex, nMaxIndex, oRuleResult) { // Create a string for HTML for each item for this rule to be shown in modal var sItemData = ""; // Get the rule id and store it to pass through with AJAX var nRule_ID = oRuleResult[nCurrentIndex].nShopRelatedItemsRule_ID; oData.append("nRule_ID", nRule_ID); // Get the rule explanation to store in the modal data later if there are related items for that rule var sExplanation = "
"+oRuleResult[nCurrentIndex].sExplanation+"
"; // GET RELATED ITEMS // ================= // Find all the related items for this rule $.ajax({ url: 'ajax/shop_basket_add_exec_related-item-rules_get-related-prods-for-a-rule.php', method: 'POST', data: oData, processData: false, contentType: false }).success(function(sData){ // Parse JSON Data to get related items var oResult = JSON.parse(sData); // Make sure new items flag is 0 before we start checking all the related items bNewItemsFlag = 0; // If there are related items... if(oResult.length > 0) { // For each related item, check if nShopProd_ID already exists in related items for(var i = 0; i < oResult.length; i++) { // Get nShopProd_ID and HTML for related item var nShopProd_ID = oResult[i]; var sHTML = oResult[i+1]; // Does nShopProd_ID already exist in related items array? if(aRelatedItems.indexOf(parseInt(nShopProd_ID)) < 0) { // If nShopProd_ID doesn't exist in array, store related item id in array to check for duplicates later aRelatedItems.push(parseInt(nShopProd_ID)); // Store the HTML for the new item in sItemData to be shown later in modal sItemData += sHTML; // Change flag to 1 as there are new things to show in modal bNewItemsFlag = 1; } // Increment counter so the for loop goes to the next shop prod in the array i++; } } // end if there are related items // If there are new items, put explanation and related items into a ModalData to append to modal-body for this rule later if(bNewItemsFlag == 1) { // div to surround rule and related items sModalData += '
'; // rule explanation sModalData += sExplanation; // related items, with the same article, section, and div surrounding them that they have on catalogue list sModalData += '
'+sItemData+'
'; // end of surrounding div sModalData += '
'; } // If we've looked at the last rule, we're done and can append the data and show the modal if(nCurrentIndex == nMaxIndex) { if(sModalData != "") { $('#relatedItemsModal .modal-body').html(sModalData); $('#relatedItemsModal').modal('show'); } } // If there are more rules to look at, run this callback function again but increase the current index else { ajaxLoop(nCurrentIndex+1, nMaxIndex, oRuleResult); } }); // end ajax function } // End of callback function // Call the AJAX function to loop through the rules ajaxLoop(0, oRuleResult.length-1, oRuleResult); } // end if parsed data isn't empty }); // end ajax function for checking for rule }); } // end if item successfully added to basket, check for related items } // end feature check } var bMessagesEventApplied = 0; function fShowPageMessages() { if(aMessages.length > 0) { var sMessage = aMessages.shift(); fShowPageMessage(sMessage); if(!bMessagesEventApplied) { bMessagesEventApplied = 1; $('#page-message-modal').on('hidden.bs.modal', function () { fShowPageMessages(); }); } } } function fShopProdOptions_LoadTradePriceBands (sCSSClassNaming, nShopProd_ID) { var bFilledIn = 0; var sVariationOptions = ""; if($(".ShopProd_"+sCSSClassNaming+"_OptionsDropDown").length) { $(".ShopProd_"+sCSSClassNaming+"_OptionsDropDown").each(function(){ if($(this).val()!="0") { bFilledIn++; sVariationOptions += $(this).val()+","; } }); if(bFilledIn<$(".ShopProd_"+sCSSClassNaming+"_OptionsDropDown").length || bFilledIn == 0) { sVariationOptions = ""; } } if (sVariationOptions!="") { // nShopProdOption_ID is specified - so go get the data $.ajax({ method: "POST", url: "ajax/catalogue_detail_trade-price-band-table-for-variations.php", data: {sCSSClassNaming:sCSSClassNaming, nShopProd_ID:nShopProd_ID, nShopProdVariationOption_IDs:sVariationOptions} }).done(function(msg){ $("#ShopProd_TradePriceBands").html(msg); }); } else { // no nShopProdOption_ID specified so empty the div $("#ShopProd_TradePriceBands").html(""); } } // close buy modal // ===================== function fBuy_Close() { // close the modal window $( "#dialogAddToBasket" ).dialog( "close" ); } // page numbers // ============= function fPageChange(nPageNo, reload) { if(typeof(reload) === 'undefined') { reload = true; } $.ajax({ data: 'nPageNumber=' + escape(nPageNo), url: 'ajax/pagination.php', type: 'POST', success: function(response) { if(reload) { $('html, body').animate({ scrollTop: 0 }, 0); window.location.reload(); } }, error: function(response) { console.log(response); } }); } // ITEMS PER PAGE // =============== function fItemsPerPage(nItemsPerPage) { $.cookie('nItemsPerPage', nItemsPerPage); fPageChange(1,true); } // EMAIL TO A FRIEND // ================== // show modal box // =============== function fEmailToAFriend_Show() { // load the add to basket modal $( "#dialogEmailToAFriend" ).dialog(); $( "#dialogEmailToAFriend" ).dialog( "option", "height", 650 ); $( "#dialogEmailToAFriend" ).dialog( "option", "width", 460 ); } // close modal box // =============== function fEmailToAFriend_Close() { // load the add to basket modal $( "#dialogEmailToAFriend" ).dialog( "close" ); } // submit form (form verification) // ================================ function fEmailToAFriend_Submit(nShopProd_ID) { // form fields var sYourName = document.getElementById('sEmailToAFriend_YourName').value; var sYourEmail = document.getElementById('sEmailToAFriend_YourEmail').value; var sTheirName = document.getElementById('sEmailToAFriend_TheirName').value; var sTheirEmail = document.getElementById('sEmailToAFriend_TheirEmail').value; // form verification var sErr = ""; if (sYourName=="") { sErr+="\n - Please enter your name"; } if (fCheckEmail(sYourEmail)=="invalid") { sErr+="\n - Your email address isn't valid"; } if (sTheirName=="") { sErr+="\n - Please enter your friend's name"; } if (fCheckEmail(sTheirEmail)=="invalid") { sErr+="\n - Your friend's email address isn't valid"; } if(!$("#bEmailToAFriend_PrivacyPolicy").is(":checked")) { sErr+="\n - Please tick the Privacy Policy box to confirm you've read our Privacy Policy before continuing."; } if (sErr!="") { alert("There were some problems submitting the form. Please see below:\n"+sErr); } else { // before we continue, check the google recaptcha var response = grecaptcha.getResponse(oRecaptcha1); if (response.length > 0) { fEmailToAFriend_Process(nShopProd_ID); } else { alert("Please tick the checkbox in the anti-spam box"); } } // submit form via ajax } // submit form (process) // ================================ function fEmailToAFriend_Process(nShopProd_ID) { // form fields var sYourName = escape(document.getElementById('sEmailToAFriend_YourName').value); var sYourEmail = escape(document.getElementById('sEmailToAFriend_YourEmail').value); var sTheirName = escape(document.getElementById('sEmailToAFriend_TheirName').value); var sTheirEmail = escape(document.getElementById('sEmailToAFriend_TheirEmail').value); var bSubscribe = document.getElementById('bEmailToAFriend_Subscribe').checked; var response = grecaptcha.getResponse(oRecaptcha1); var sRecaptchaResponse = response; // define AJAX url var sAjaxURL = "ajax/catalogue_detail_email-to-a-friend_exec.php?sYourName=" + sYourName + "&sYourEmail=" + sYourEmail + "&sTheirName=" + sTheirName + "&sTheirEmail=" + sTheirEmail + "&nShopProd_ID=" + nShopProd_ID + "&bSubscribe=" + bSubscribe + '&g-recaptcha-response=' + sRecaptchaResponse; // call ajax URL $.get(sAjaxURL, function(data) { // get the result $('.result').html(data); // close the modal window $( "#dialogEmailToAFriend" ).dialog( "close" ); // alert the results $("head").append(data); grecaptcha.reset(oRecaptcha1); grecaptcha.reset(oRecaptcha2); }); } // EMAIL ENQUIRY // ============== // show modal box // =============== function fEmailEnquiry_Show() { // load the add to basket modal $( "#dialogEmailEnquiry" ).dialog(); $( "#dialogEmailEnquiry" ).dialog( "option", "height", 590 ); $( "#dialogEmailEnquiry" ).dialog( "option", "width", 460 ); } // close modal box // =============== function fEmailEnquiry_Close() { // load the add to basket modal $( "#dialogEmailEnquiry" ).dialog( "close" ); } // submit form (form verification) // ================================ function fEmailEnquiry_Submit(nShopProd_ID) { // form fields var sYourName = document.getElementById('sEmailEnquiry_YourName').value; var sYourEmail = document.getElementById('sEmailEnquiry_YourEmail').value; var sYourTel = document.getElementById('sEmailEnquiry_YourTel').value; var sEnquiry = document.getElementById('sEmailEnquiry_Enquiry').value; // form verification var sErr = ""; if (sYourName=="") { sErr+="\n - Please enter your name"; } if (fCheckEmail(sYourEmail)=="invalid") { sErr+="\n - Your email address isn't valid"; } if (sYourTel=="") { sErr+="\n - Please enter a contact number"; } if (sEnquiry=="") { sErr+="\n - Please enter your enquiry / message"; } if(!$("#bEmailEnquiry_PrivacyPolicy").is(":checked")) { sErr+="\n - Please tick the Privacy Policy box to confirm you've read our Privacy Policy before continuing."; } if (sErr!="") { alert("There were some problems submitting the form. Please see below:\n"+sErr); } else { // before we continue, check the google recaptcha var response = grecaptcha.getResponse(oRecaptcha2); if (response.length > 0) { fEmailEnquiry_Process(nShopProd_ID); } else { alert("Please tick the checkbox in the anti-spam box"); } } // submit form via ajax } // submit form (process) // ================================ function fEmailEnquiry_Process(nShopProd_ID) { // form fields var sYourName = escape(document.getElementById('sEmailEnquiry_YourName').value); var sYourEmail = escape(document.getElementById('sEmailEnquiry_YourEmail').value); var sYourTel = escape(document.getElementById('sEmailEnquiry_YourTel').value); var sEnquiry = escape(document.getElementById('sEmailEnquiry_Enquiry').value); var bSubscribe = document.getElementById('bEmailEnquiry_Subscribe').checked; var response = grecaptcha.getResponse(oRecaptcha2); var sRecaptchaResponse = response; // define AJAX url var sAjaxURL = "ajax/catalogue_detail_enquiry_exec.php?sYourName=" + sYourName + "&sYourEmail=" + sYourEmail + "&sYourTel=" + sYourTel + "&sEnquiry=" + sEnquiry + "&nShopProd_ID=" + nShopProd_ID + '&bSubscribe=' + bSubscribe + '&g-recaptcha-response=' + sRecaptchaResponse; // call ajax URL $.get(sAjaxURL, function(data) { // get the result $('.result').html(data); // close the modal window $( "#dialogEmailEnquiry" ).dialog( "close" ); // alert the results $("head").append(data); grecaptcha.reset(oRecaptcha1); grecaptcha.reset(oRecaptcha2); }); } // MADE TO ORDER // ============== // show modal box // =============== function fMadeToOrder_Show(nShopProd_ID) { // load the made to order modal $( "#dialogMadeToOrder" ).dialog(); $( "#dialogMadeToOrder" ).dialog( "option", "height", 650 ); $( "#dialogMadeToOrder" ).dialog( "option", "width", 460 ); // get the add form page $.get('ajax/shop_basket_made-to-order_form.php?nShopProd_ID='+nShopProd_ID, function(data) { // get the result $('.result').html(data); // save to the empty div in the modal box we have just loaded $('#dialogMadeToOrder_Inner').append(data); }); } // close modal box // =============== function fMadeToOrder_Close() { // load the add to basket modal $( "#dialogMadeToOrder" ).dialog( "close" ); } // submit form (form verification) // ================================ function fMadeToOrder_Submit(nShopProd_ID) { // form fields var sYourName = document.getElementById('sMadeToOrder_Name').value; var sYourEmail = document.getElementById('sMadeToOrder_Email').value; var sYourTel = document.getElementById('sMadeToOrder_Tel').value; var sRequirements = document.getElementById('sMadeToOrder_Requirements').value; // form verification var sErr = ""; if (sYourName=="") { sErr+="\n - Please enter your name"; } if (fCheckEmail(sYourEmail)=="invalid") { sErr+="\n - Your email address isn't valid"; } if (sYourTel=="") { sErr+="\n - Please enter a contact number"; } if (sRequirements=="") { sErr+="\n - Please enter your requirements"; } if (sErr!="") { alert("There were some problems submitting the form. Please see below:\n"+sErr); } else { fMadeToOrder_Process(nShopProd_ID); } // submit form via ajax } // submit form (process) // ================================ function fMadeToOrder_Process(nShopProd_ID) { // form fields var sYourName = escape(document.getElementById('sMadeToOrder_Name').value); var sYourEmail = escape(document.getElementById('sMadeToOrder_Email').value); var sYourTel = escape(document.getElementById('sMadeToOrder_Tel').value); var sRequirements = escape(document.getElementById('sMadeToOrder_Requirements').value); // define AJAX url var sAjaxURL = "ajax/catalogue_detail_made-to-order_exec.php?sYourName=" + sYourName + "&sYourTel=" + sYourTel + "&sYourEmail=" + sYourEmail + "&sRequirements=" + sRequirements + "&nShopProd_ID=" + nShopProd_ID; // call ajax URL $.get(sAjaxURL, function(data) { // get the result $('.result').html(data); // close the modal window $( "#dialogMadeToOrder" ).dialog( "close" ); // alert the results fShowPageMessage(data); }); } function fUpdateCountdown(oElement, nMaxLength) { var ID = oElement.id.replace("inputfield",""); nMaxLength = nMaxLength - oElement.value.length; $('.sCountdown'+ID).text(nMaxLength); if(nMaxLength!=1) { $('.sCountdownPlural'+ID).text("s"); } else { $('.sCountdownPlural'+ID).text(""); } } /* * VARIATION SYSTEM * */ var sOriginalPriceRange = ''; var nNewShopProd_ID = 0; var nCurrentShopProd_ID = 0; function fUpdateDropdowns() { // We do these in order that we find them. if (typeof aOptionsArray !== 'undefined') { var aTmpArray = aOptionsArray; var sCombination = ""; var bAllFound = 1; $("select[name$='nShopProdVariationOption_ID']").each(function(){ // First, get it's currently selected option var nCurrentVal = $(this).val(); // For each option it CAN have, check it exists in this context, if it doesn't, hide it $(this).children().each(function(){ if(!aTmpArray.hasOwnProperty($(this).attr("value")) && $(this).attr("value") != "0") { $(this).hide(); } else { $(this).show(); } }); // Check if it IS in the array, if it IS, set aTmpArray to it, if it isn't, set our value to 0 if(aTmpArray.hasOwnProperty(nCurrentVal)) { // Add it to the combination if(sCombination == "") { sCombination = nCurrentVal; } else { sCombination += "_" + nCurrentVal; } aTmpArray = aTmpArray[nCurrentVal]; } else { $(this).val('0'); bAllFound = 0; } }); // If all options were found, get the combination ID, price and stock count if(bAllFound == 1) { if(sOriginalPriceRange=="") { sOriginalPriceRange = $(".ShopProd_"+sCSSClassNaming+"_Price_MainPrice").html(); } nNewShopProd_ID = aCombinationsArray[sCombination]; var oShopProd = aShopProdArray[nNewShopProd_ID]; if(bTrade == 0) { $(".ShopProd_"+sCSSClassNaming+"_Price_MainPrice").html(oShopProd.nTotal); } $("#nStockTotal").val(oShopProd.nStockTotal); } // If not, reset price and stock else { if(sOriginalPriceRange!="") { $(".ShopProd_"+sCSSClassNaming+"_Price_MainPrice").html(sOriginalPriceRange); } $("#nStockTotal").val(0); } } }