// 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-total.php";
// open URL using AJAX
$.get(sAjaxURL, function(data) {
// get the result
$('.result').html(data);
// save the results
var nShopBasketItemCount = data;
// update the div
document.getElementById('header-basket').innerHTML=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;
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", 500 );
$( "#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').append(data);
});
}
// add to basket validate function (called by the add to basket button)
// =====================================================================
function fBuy_AddToBasket_Validate(nShopProd_ID, nNumberOfProdOptions, bShopLimitOrderByStockLevels, bCalledFromModal) {
// Store this pages nShopProd_ID
nCurrentShopProd_ID = nShopProd_ID;
// If a variation nShopProd_ID has been selected from drop downs, use that
if(nNewShopProd_ID!=0)
{
nShopProd_ID = nNewShopProd_ID;
}
// 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;
}
// 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[required][name^='inputfield']").each(function(){
// Check if it has no value
if((typeof $(this).attr("disabled") === typeof undefined || $(this).attr("disabled") === false) && ($(this).val()==""||$(this).val()==null) && 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;
}
});
// Loop through all required inputs
$("select[required][class^='ShopProd']").each(function(){
// Check if it has no value
if((typeof $(this).attr("disabled") === typeof undefined || $(this).attr("disabled") === false) && ($(this).val()==""||$(this).val()==null) && 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)
// check whether there are options for this product
// Format the URL to call via ajax to check stock available (this INCLUDES stock in the basket)
var sAjaxURL_ForStockAvailable= "ajax/shop_basket_stock-amount-available.php?nShopProd_ID="+nShopProd_ID;
// also format a URL for stock in basket (used later)
var sAjaxURL_ForStockInBasket = "ajax/shop_basket_already-in-basket.php?nShopProd_ID="+nShopProd_ID;
// use ajax to find out how many are in stock (minus whats already in the basket, if applicable), using the URL worked out above
$.get(sAjaxURL_ForStockAvailable, function(data) {
// get the result
$('.result').html(data);
// save the results
var nStockAvailable = parseInt(data);
// check to see if the qty being ordered is greater than the amount in stock + amount already in basket
if (nQty > nStockAvailable) {
// log this in the goal tracking
$.get("ajax/shop_basket_goal-track_out-of-stock.php?nShopProd_ID="+nShopProd_ID+"&nQuantity=" + nQty, 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)
$.get(sAjaxURL_ForStockInBasket, 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");
});
} else {
// call add to basket go function
fBuy_AddToBasket_Go(nShopProd_ID, nNumberOfProdOptions, bCalledFromModal);
}
});
} else {
// log this in goal tracking
$.get("ajax/shop_basket_goal-track.php?nShopProd_ID="+nShopProd_ID+"&nQuantity=" + nQty, function(GoalScript) {
$("head").append(GoalScript);
});
// call add to basket go function
fBuy_AddToBasket_Go(nShopProd_ID, nNumberOfProdOptions, bCalledFromModal);
}
}
// add to basket go function
// =========================
function fBuy_AddToBasket_Go(nShopProd_ID, nNumberOfProdOptions, bCalledFromModal)
{
// Fade overlay in
$(".add-to-basket-overlay").fadeIn(300);
var oData = new FormData();
oData.append("nShopProd_ID", nShopProd_ID);
oData.append("nQty", document.getElementById('nQty').value);
var sAjaxURL = 'ajax/shop_basket_add_exec.php';
// If this is a variation
if(nShopProd_ID == nNewShopProd_ID)
{
// Let the ajax know
oData.append("eType", "variation-option");
oData.append("nParentShopProd_ID", nCurrentShopProd_ID);
}
// work out the URL to call based on whether there are options or personalisations for this product or not
// check for personalisation inputs and append them as well
$("input, select, textarea").filter("[data-personalisation-id][type!='file']").each(function(){
var sID = $(this).data('personalisation-id');
oData.append('inputfield'+sID, $(this).val());
});
$("input[type='file']").each(function(){
var oThisData = $(this)[0].files;
// attach the data to the AJAX post
for(var i = 0; i < oThisData.length; i++)
{
// work out the name for the field
// is this a CustomCoverImage image?
if ( ($(this)[0].name=="CustomCoverImage1") || ($(this)[0].name=="CustomCoverImage2") || ($(this)[0].name=="CustomCoverImage3") ) {
// name it after the field name
var sFieldName = $(this)[0].name;
} else {
// it's a personalisation... so attach the personalisation-id stored in the input HTML
var sFieldName = 'inputfield'+$(this).data('personalisation-id') + "-" + i;
}
// attach data
oData.append(sFieldName, oThisData[i]);
}
});
$("#nVehicleModel_ID").each(function(){
oData.append('nVehicleModel_ID', $(this).val());
});
// call the add basket exec page
$.ajax({
url: sAjaxURL,
method: 'POST',
data: oData,
processData: false,
contentType: false
}).success(function(sData){
// get the result
$('.result').html(sData);
// Fade overlay out
$(".add-to-basket-overlay").fadeOut(300);
// close the modal window (if this has been called from the modal)
if (bCalledFromModal==1) {
$( "#dialogAddToBasket" ).dialog( "close" );
}
// update the basket counter
fShopBasketUpdateCounter();
// alert the results
alert(sData);
// 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(sData.indexOf("was added to your basket!") >= 0)
{
// 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);
// Append the vehicle model ID to oData so that we can make any connected wind deflectors show up in the related items modal
if ($('#nVehicleModel_ID').length > 0) {
oData.append("nVehicleModel_ID", $('#nVehicleModel_ID').val());
}
// 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
else
{
fRedirectToBasket();
}
}); // end ajax function for checking for rule
} // end if item successfully added to basket, check for related items
} // end feature check
// END RELATED ITEMS SYSTEM
// ========================
}); // end ajax function
}
function fRedirectToBasket()
{
location.href="https://www.classicadditions.com/en-GB/basket/page_907";
}
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", 350 );
$( "#dialogEmailToAFriend" ).dialog( "option", "width", 350 );
}
// 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 (sErr!="") {
alert("There were some problems submitting the form. Please see below:\n"+sErr);
} else {
fEmailToAFriend_Process(nShopProd_ID);
}
// submit form via ajax
}
// submit form (process)
// ================================
function fEmailToAFriend_Process(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;
var bSubscribe = document.getElementById('bEmailToAFriend_Subscribe').checked;
// 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;
// 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);
});
}
// EMAIL ENQUIRY
// ==============
// show modal box
// ===============
function fEmailEnquiry_Show() {
// load the add to basket modal
$( "#dialogEmailEnquiry" ).dialog();
$( "#dialogEmailEnquiry" ).dialog( "option", "height", 420 );
$( "#dialogEmailEnquiry" ).dialog( "option", "width", 350 );
}
// 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 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 (sEnquiry=="") {
sErr+="\n - Please enter your enquiry / message";
}
if (sErr!="") {
alert("There were some problems submitting the form. Please see below:\n"+sErr);
} else {
fEmailEnquiry_Process(nShopProd_ID);
}
// submit form via ajax
}
// submit form (process)
// ================================
function fEmailEnquiry_Process(nShopProd_ID) {
// form fields
var sYourName = document.getElementById('sEmailEnquiry_YourName').value;
var sYourEmail = document.getElementById('sEmailEnquiry_YourEmail').value;
var sEnquiry = document.getElementById('sEmailEnquiry_Enquiry').value;
var bSubscribe = document.getElementById('bEmailEnquiry_Subscribe').checked;
// define AJAX url
var sAjaxURL = "ajax/catalogue_detail_enquiry_exec.php?sYourName=" + sYourName + "&sYourEmail=" + sYourEmail + "&sEnquiry=" + sEnquiry + "&nShopProd_ID=" + nShopProd_ID + '&bSubscribe=' + bSubscribe;
// 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);
});
}
// MADE TO ORDER
// ==============
// show modal box
// ===============
function fMadeToOrder_Show() {
// load the made to order modal
$( "#dialogMadeToOrder" ).dialog();
$( "#dialogMadeToOrder" ).dialog( "option", "height", 430 );
$( "#dialogMadeToOrder" ).dialog( "option", "width", 350 );
}
// 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 = 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;
// 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
alert(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')
{
return;
}
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);
$(".ShopProd_Detail_Top_Price_MainPrice").html(oShopProd.nTotal);
}
$("#nStockTotal").val(oShopProd.nStockTotal);
}
// If not, reset price and stock
else
{
if(sOriginalPriceRange!="")
{
$(".ShopProd_"+sCSSClassNaming+"_Price_MainPrice").html(sOriginalPriceRange);
$(".ShopProd_Detail_Top_Price_MainPrice").html(sOriginalPriceRange);
}
$("#nStockTotal").val(0);
}
// Classic Additions Colour Fix
if($("select[data-personalisation-id='147']").length && $("select[name='128nShopProdVariationOption_ID']"))
{
var oColourBox = $("select[name='128nShopProdVariationOption_ID']");
var oMirrorBox = $("select[data-personalisation-id='147']");
if(oMirrorBox.parent().is(":visible"))
{
if(oColourBox.val()=="399" || oColourBox.val()=="401" || oColourBox.val()=="3433" || oColourBox.val()=="3432" || oColourBox.val()=="3436")
{
oMirrorBox.hide();
oMirrorBox.val("");
oMirrorBox.attr("disabled","disabled");
oMirrorBox.parent().find(".mirror-pockets-unavailable").show();
}
else
{
oMirrorBox.show();
oMirrorBox.removeAttr("disabled");
oMirrorBox.parent().find(".mirror-pockets-unavailable").hide();
}
}
}
}