function n__shoppingCart(n__currencySymbol, n__currencyCodeString)
{
var n__shoppingCart = {
n__dropDownVisible : false,
n__itemCount : 0,
n__totalCost : 0,
n__subTotalCost : 0,
n__totalDiscount : 0,
n__currencyCode : "USD",
n__currencyConversionRate : 1,
n__shippingRateId : 0,
n__shippingCountryCode : "US",
n__billingState : "",
n__salesTaxDescription : "",
n__shippingCost : 0,
n__totalSalesTax : 0,
n__currentCoupon : false,
n__itemArray : new Array(), //assoc array of items: array['id' + 1'], each value is a normal array inside
n__shippingRateArray : new Array(), //array of shipping rates
//informs the page that a change has been made from within the shopping cart menu
n__onShoppingCartChange : function(){},
/**HTML ELEMENTS**/
n__menuCart : null,
n__menuCartHasItemsWrap : null,
n__menuCartNoItemsWrap : null,
n__cartItemListTitle : null,
n__cartItemList : null,
n__cartCouponListTitle : null,
n__cartCouponList : null,
n__cartShippingSection : null,
n__cartShippingTotal : null,
n__cartTotalSection : null,
n__cartTotalTotal : null,
n__init : function()
{
//reference to menu cart
this.n__menuCart = n__eById('dropdownMenuCart');
this.n__menuCartHasItemsWrap = n__eById('shopping_cart_dropdown_has_items');
this.n__menuCartNoItemsWrap = n__eById('shopping_cart_dropdown_no_items');
this.n__cartItemListTitle = n__eById('shopping_cart_item_list_title');
this.n__cartItemList = n__eById('shopping_cart_item_list');
this.n__cartCouponListTitle = n__eById('shopping_cart_coupon_list_title');
this.n__cartCouponList = n__eById('shopping_cart_coupon_list');
this.n__cartTotalSection = n__eById('shopping-cart-total-section');
this.n__cartTotalTotal = n__eById('shopping-cart-total');
this.n__refresh();
},
n__refresh : function()
{
//calculate the totals
this.n__calculateTotals();
//removes all items
n__removeAllChildren(this.n__cartItemList);
n__removeAllChildren(this.n__cartCouponList);
//add all items back into the list
for(n__property in this.n__itemArray)
{
for(var i = 0; i < this.n__itemArray[n__property].length; i++)
{
if(this.n__itemArray[n__property][i].n__itemQty > 0)
{
this.n__cartItemList.appendChild(this.n__itemArray[n__property][i].n__itemListItem);
}
}
}
//update item count
this.n__menuCart.innerHTML = ' '+this.n__itemCount+'';
//update cart total
if(this.n__totalCost > 0)
{
this.n__cartTotalTotal.innerHTML = "";
//show shipping price if we have it
if(this.n__shippingCost > 0)
{
this.n__cartTotalTotal.innerHTML += '
Shipping: '+n__currencySymbol+n__numberFormatWithCommas(this.n__shippingCost, 2)+n__currencyCodeString+'
';
}
else
{
this.n__cartTotalTotal.innerHTML += 'Shipping: FREE!
';
}
//show sales tax if we have it
if(this.n__totalSalesTax > 0)
{
if(this.n__salesTaxDescription != "")
{
this.n__cartTotalTotal.innerHTML += ''+this.n__salesTaxDescription+': '+n__currencySymbol+n__numberFormatWithCommas(this.n__totalSalesTax, 2)+n__currencyCodeString+'
';
}
else
{
this.n__cartTotalTotal.innerHTML += 'Sales Tax: '+n__currencySymbol+n__numberFormatWithCommas(this.n__totalSalesTax, 2)+n__currencyCodeString+'
';
}
}
this.n__cartTotalSection.style.display = '';
this.n__cartTotalTotal.innerHTML += n__currencySymbol + n__numberFormatWithCommas(this.n__totalCost, 2)+ n__currencyCodeString; //+ " USD";
}
else
{
this.n__cartTotalSection.style.display = 'none';
}
//handle empty shopping cart
if(this.n__itemCount > 0)
{
this.n__menuCartHasItemsWrap.style.display = '';
this.n__menuCartNoItemsWrap.style.display = 'none';
}
else
{
this.n__menuCartHasItemsWrap.style.display = 'none';
this.n__menuCartNoItemsWrap.style.display = '';
}
//if a coupon code has been applied, add it
if(this.n__currentCoupon)
{
this.n__cartCouponListTitle.style.display = '';
this.n__cartCouponList.style.display = '';
//update the coupon discount html value
this.n__currentCoupon.n__setActualDiscount();
this.n__cartCouponList.appendChild(this.n__currentCoupon.n__couponListItem);
// Disable coupon removal if active promo
try {
if (this.n__cartCouponListTitle.hasAttribute('data-disable-delete')) {
var removeEl = this.n__currentCoupon.n__couponListItem.getElementsByClassName("fa-close");
if (removeEl.length) removeEl[0].remove();
}
} catch (e) {
console.log('Error disabling coupon removal for promo: ', e);
}
}
else //hide the discount section
{
this.n__cartCouponListTitle.style.display = 'none';
this.n__cartCouponList.style.display = 'none';
}
},
//this function will set all of the total values
n__calculateTotals : function()
{
this.n__totalDiscount = 0;
this.n__subTotalCost = 0;
this.n__shippingCost = 0;
this.n__totalCost = 0;
this.n__itemCount = 0;
//clear out the discount for the currentCoupon
if(this.n__currentCoupon)
{ this.n__currentCoupon.n__actualDiscount = 0; }
var n__totalLineItems = 0;
var n__totalLimitedItems = 0;
for (n__property in this.n__itemArray) {
n__totalLineItems += this.n__itemArray[n__property].length;
for (var i = 0; i < this.n__itemArray[n__property].length; i++) {
if (this.n__itemArray[n__property][i].n__itemIsLimited) { n__totalLimitedItems++; }
}
}
//loop through all of the items
for(n__property in this.n__itemArray)
{
for(var i = 0; i < this.n__itemArray[n__property].length; i++)
{
this.n__itemCount += this.n__itemArray[n__property][i].n__itemQty;
//PRODUCT COUPON
if (this.n__currentCoupon &&
this.n__currentCoupon.n__couponType == 'product' &&
(this.n__currentCoupon.n__productId == this.n__itemArray[n__property][i].n__itemId ||
(this.n__currentCoupon.n__productId == this.n__itemArray[n__property][i].n__itemParentProductId && this.n__itemArray[n__property][i].n__itemIsLimited === false)
&& this.n__itemArray[n__property][i].n__itemParentProductId != 121)
) {
var n__currentQtyDiscounting = 0;
if(this.n__currentCoupon.n__productQtyAvailable == -1)
{
n__currentQtyDiscounting = this.n__itemArray[n__property][i].n__itemQty;
}
else if(this.n__currentCoupon.n__productQtyAvailable > 0 &&
this.n__currentCoupon.n__productQtyUsed < this.n__currentCoupon.n__productQtyAvailable)
{
var n__couponQuantityAvailable = this.n__currentCoupon.n__productQtyAvailable - this.n__currentCoupon.n__productQtyUsed;
if(n__couponQuantityAvailable >= this.n__itemArray[n__property][i].n__itemQty)
{
n__currentQtyDiscounting = this.n__itemArray[n__property][i].n__itemQty;
}
else
{
n__currentQtyDiscounting = Math.max(0, n__couponQuantityAvailable);
}
}
var n__discountForThisCoupon = 0;
if(this.n__currentCoupon.n__couponDiscountType == "percentage")
{
n__discountForThisCoupon = (n__currentQtyDiscounting*this.n__itemArray[n__property][i].n__itemPrice)*(this.n__currentCoupon.n__couponDiscount);
}
else if(this.n__currentCoupon.n__couponDiscountType == "flatItem")
{
n__discountForThisCoupon = n__currentQtyDiscounting*this.n__currentCoupon.n__couponDiscount;
// If cart is not in USD then we convert coupon discount value in converted rate
if (this.n__currencyCode != 'USD') {
n__discountForThisCoupon = n__currentQtyDiscounting*(this.n__currentCoupon.n__couponDiscount*this.n__currencyConversionRate);
}
}
n__discountForThisCoupon = Math.round(n__discountForThisCoupon*10000)/10000;
n__discountForThisCoupon = Math.round(n__discountForThisCoupon*100)/100;
// Store that discount to the product line item
this.n__itemArray[n__property][i].productTotalDiscount = n__discountForThisCoupon;
//store that discount to the actualDiscount value of the coupon
this.n__currentCoupon.n__actualDiscount += n__discountForThisCoupon;
//add to the total current shipping discount
this.n__totalDiscount += n__discountForThisCoupon;
}
else if (this.n__currentCoupon && this.n__currentCoupon.n__couponType == 'global' &&
this.n__itemArray[n__property][i].n__itemIsLimited === false && this.n__itemArray[n__property][i].n__itemParentProductId != 121) {
var n__currentQtyDiscounting = 0;
if(this.n__currentCoupon.n__globalQtyAvailable == -1)
{
n__currentQtyDiscounting = this.n__itemArray[n__property][i].n__itemQty;
}
else if(this.n__currentCoupon.n__globalQtyAvailable > 0 &&
this.n__currentCoupon.n__globalQtyUsed < this.n__currentCoupon.n__globalQtyAvailable
)
{
n__currentQtyDiscounting = this.n__itemArray[n__property][i].n__itemQty;
}
var n__discountForThisCoupon = 0;
if(this.n__currentCoupon.n__couponDiscountType == "percentage")
{
n__discountForThisCoupon = (n__currentQtyDiscounting*this.n__itemArray[n__property][i].n__itemPrice)*(this.n__currentCoupon.n__couponDiscount);
}
else if(this.n__currentCoupon.n__couponDiscountType == "flatItem")
{
n__discountForThisCoupon = n__currentQtyDiscounting*this.n__currentCoupon.n__couponDiscount;
// If cart is not in USD then we convert coupon discount value in converted rate
if (this.n__currencyCode != 'USD') {
n__discountForThisCoupon = n__currentQtyDiscounting*(this.n__currentCoupon.n__couponDiscount*this.n__currencyConversionRate);
}
}
n__discountForThisCoupon = Math.round(n__discountForThisCoupon*10000)/10000;
n__discountForThisCoupon = Math.round(n__discountForThisCoupon*100)/100;
//if this is a flatGlobal coupon, it means we get one discount for the whole cart
if(this.n__currentCoupon.n__couponDiscountType == "flatGlobal")
{
var n__flatGlobalDiscount = this.n__currentCoupon.n__couponDiscount;
// If cart is not in USD then we convert coupon discount value in converted rate
if (this.n__currencyCode != 'USD') {
n__flatGlobalDiscount = this.n__currentCoupon.n__couponDiscount*this.n__currencyConversionRate;
}
// Store that discount to the product line item
var n__discountForThisLineItem = n__flatGlobalDiscount / (n__totalLineItems - n__totalLimitedItems);
n__discountForThisLineItem = Math.round(n__discountForThisLineItem*10000)/10000;
n__discountForThisLineItem = Math.round(n__discountForThisLineItem*100)/100;
this.n__itemArray[n__property][i].productTotalDiscount = n__discountForThisLineItem;
this.n__currentCoupon.n__actualDiscount = n__flatGlobalDiscount;
this.n__totalDiscount = n__flatGlobalDiscount;
}
else
{
// Store that discount to the product line item
this.n__itemArray[n__property][i].productTotalDiscount = n__discountForThisCoupon;
//store that discount to the actualDiscount value of the coupon
this.n__currentCoupon.n__actualDiscount += n__discountForThisCoupon;
//add to the total current shipping discount
this.n__totalDiscount += n__discountForThisCoupon;
}
//NOTE: we dont adjust global qty used because it is one per order
}
this.n__subTotalCost += this.n__itemArray[n__property][i].n__itemQty * this.n__itemArray[n__property][i].n__itemPrice;
}
}
//shipping rate should not be applied with 0 items
if(this.n__itemCount == 0)
{ this.n__shippingCost = 0; }
else
{ this.n__shippingCost = this.n__getShippingRate(); }
this.n__totalSalesTax = this.n__getSalesTaxTotal();
this.n__totalCost = this.n__subTotalCost + this.n__shippingCost - this.n__totalDiscount + this.n__totalSalesTax;
//if any of the costs are less than 0, then set them to 0
this.n__totalCost < 0 ? this.n__totalCost = 0 : false;
this.n__shippingCost < 0 ? this.n__shippingCost = 0 : false;
this.n__subTotalCost < 0 ? this.n__subTotalCost = 0 : false;
this.n__itemCount < 0 ? this.n__itemCount = 0 : false;
this.n__totalDiscount < 0 ? this.n__totalDiscount = 0 : false;
},
//adds an item to our item array
n__addItemToDom : function( n__itemId, n__itemType, n__itemIsLimited, n__itemSlug, n__itemSlugChild, n__itemTitle,
n__itemQty, n__itemPrice, n__itemImageFull, n__itemImageThumb, n__parentProductId,
n__itemOnBackorder, n__itemCustomization, n__itemShippingRates)
{
//if we already have products of this type, see if there is a match
var n__productMatchFound = false;
try
{
if(this.n__itemArray['id' + n__itemId].length > 0)
{
//loop through existing products
for(var i = 0; i < this.n__itemArray['id' + n__itemId].length; i++)
{
//if a product exists that has the same customization settings then increment quantity
if(this.n__itemArray['id' + n__itemId][i].n__itemCustomization == n__itemCustomization)
{
this.n__itemArray['id' + n__itemId][i].productQuantity += n__itemQty;
this.n__itemArray['id' + n__itemId][i].n__itemQtyCell.innerHTML = this.n__itemArray['id' + n__itemId][i].n__itemQty;
n__productMatchFound = true;
}
}
}
}
catch (err){}
if(n__productMatchFound == false)
{
var n__newItem = new this.n__item();
n__newItem.n__itemId = n__itemId;
n__newItem.n__itemType = n__itemType;
n__newItem.n__itemIsLimited = n__itemIsLimited === true || n__itemIsLimited === '1';
n__newItem.n__itemSlug = n__itemSlug;
n__newItem.n__itemSlugChild = n__itemSlugChild;
n__newItem.n__itemTitle = n__itemTitle;
n__newItem.n__itemQty = parseInt(n__itemQty);
n__newItem.n__itemPrice = parseFloat(n__itemPrice);
n__newItem.n__itemImageFull = n__itemImageFull;
n__newItem.n__itemImageThumb = n__itemImageThumb;
n__newItem.n__itemParentProductId = n__parentProductId;
n__newItem.n__itemOnBackorder = n__itemOnBackorder;
n__newItem.n__itemCustomization = n__itemCustomization;
n__newItem.n__itemShippingRates = n__itemShippingRates;
try
{
//set customization assoc array, if not a blank value
if(n__itemCustomization != "")
{
n__newItem.n__itemCustomizationArray = eval("(" + n__itemCustomization + ")");
}
}
catch (err){}
try
{
//set shippnig rates assoc array, if not a blank value
if(n__itemShippingRates != "")
{
n__newItem.n__itemShippingRatesArray = eval("(" + n__itemShippingRates + ")");
}
}
catch (err){}
n__newItem.n__init();
//create array if doesnt exist
if(typeof this.n__itemArray['id' + n__itemId] == 'undefined')
{
this.n__itemArray['id' + n__itemId] = new Array();
}
//add to array
this.n__itemArray['id' + n__itemId].push(n__newItem);
}
},
//will remove an item from the shopping cart and do the request (hidden)
n__removeItem : function(n__itemId, n__itemCustomization)
{
var n__newArray = new Array();
//loop through and see which ones to remove
try
{
for(var i = 0; i < this.n__itemArray['id' + n__itemId].length; i++)
{
if(this.n__itemArray['id' + n__itemId][i].n__itemCustomization != n__itemCustomization)
{
n__newArray.push(this.n__itemArray['id' + n__itemId][i]);
}
}
}
catch (err){}
if(n__newArray.length == 0)
{
delete this.n__itemArray['id' + n__itemId];
}
else
{
this.n__itemArray['id' + n__itemId] = n__newArray;
}
this.n__refresh();
//fire the on shopping cart change action
this.n__onShoppingCartChange();
//send the ajax request to update the qty (hidden)
this.n__doItemQtyUpdateRequest(n__itemId, n__itemCustomization, 0, 0, false);
},
//Use this function will update an item in the shopping cart
n__addToItemQty : function(n__itemId, n__itemCustomization, n__itemQtyToAdd, n__showCompletionMessage, n__onSuccessFunction)
{
var n__foundItem = false;
var n__finalQty = 0;
try
{
//If the item already exists then add to the quantity
for(var i = 0; i < this.n__itemArray['id' + n__itemId].length; i++)
{
if(this.n__itemArray['id' + n__itemId][i].n__itemCustomization == n__itemCustomization)
{
this.n__itemArray['id' + n__itemId][i].n__itemQty += n__itemQtyToAdd;
n__finalQty = this.n__itemArray['id' + n__itemId][i].n__itemQty;
n__foundItem = true;
}
}
}
catch (err){}
//otherwise we are starting with 0
if(n__foundItem == false)
{
n__finalQty = n__itemQtyToAdd;
}
//do the SYNCHRONOUS request to add the item
this.n__doItemQtyUpdateRequest(n__itemId, n__itemCustomization, n__itemQtyToAdd, n__finalQty, n__showCompletionMessage, n__onSuccessFunction);
return true;
},
//will do the item update request to the server session
// n__showCompletionMessage = true will show the completion message, false will just not show anything and refresh the list
// n__itemQty = the final item quantity
// n__itemQtyToAdd = the amount we are adding to the quantity
n__doItemQtyUpdateRequest : function(n__itemId, n__itemCustomization, n__itemQtyToAdd, n__itemQty, n__showCompletionMessage, n__onSuccessFunction)
{
//show the loading screen only if we are adding
if(n__itemQty > 0 && n__showCompletionMessage)
{
n__showLoadingOverlay();
}
var n__param = "productId="+n__itemId+
"&productQtyFinal="+n__itemQty+
"&productQtyAdded="+n__itemQtyToAdd+
"&customization="+n__urlEncodeString(n__Base64.n__encode(n__itemCustomization));
var n__newAjaxRequest = new n__ajaxRequest("GET", "/requests/request.updateCartQty.php", n__param, true, true);
n__newAjaxRequest.n__onResponse = function(n__responseText)
{
//hide loading overlay
n__hideLoadingOverlay();
var n__json = n__parseJSON(n__responseText);
//only if we are showing a completion message (SYNCHRONOUS)
if(n__showCompletionMessage == true)
{
var n__successMessage = "";
//if we have an error message, print it
if(n__json.errorCode > 0)
{
n__showAlertModal("Error", n__json.errorText, "", function(){}, "OKAY", function(){}, function(){});
return;
}
//otherwise we have success and should parse the new data
else
{
//parse the new data and fire the on shopping cart change
n__shoppingCart.n__parseShoppingCartFeed(n__json, true);
//show the appropriate synchronous message
if(n__itemQtyToAdd > 0)
{
//find our item
var n__itemRef = null;
for(var i = 0; i < n__shoppingCart.n__itemArray['id' + n__itemId].length; i++)
{
if(n__shoppingCart.n__itemArray['id' + n__itemId][i].n__itemCustomization == n__itemCustomization)
{
n__itemRef = n__shoppingCart.n__itemArray['id' + n__itemId][i];
}
}
//COULD ADD BACKORDER HERE
var n__backorderString = "";
try
{
if(parseInt(n__itemRef.n__itemOnBackorder) == 1)
{
n__backorderString = " (PREORDER)";
}
}
catch (err){}
var n__itemTitle = n__itemRef.n__itemTitle;
n__successMessage = n__encodeHTMLSpecialChars(n__itemTitle, 0) +n__backorderString+" has been added to your shopping cart.";
if(n__itemQtyToAdd > 1)
{
n__successMessage = "("+n__itemQtyToAdd + ") "+ n__encodeHTMLSpecialChars(n__convertToPlural(n__itemTitle), 0) +n__backorderString+" have been added to your shopping cart.";
}
}
n__showAlertModal("Shopping Cart Updated",
n__successMessage,
"CONTINUE SHOPPING",
function(){},
"CHECKOUT",
function(){window.location.href = "/checkout"}, function(){});
}
}
//no completion message, custom funtion
else
{
try
{
n__onSuccessFunction(n__json);
}
catch (err){}
}
// ShopMessage Tracking
try {
var shopMessageItems = [];
for (n__property in n__shoppingCart.n__itemArray) {
for (var i = 0; i < n__shoppingCart.n__itemArray[n__property].length; i++) {
var productItem = n__shoppingCart.n__itemArray[n__property][i];
shopMessageItems.push({
title: productItem.n__itemTitle,
price: productItem.n__itemPrice,
currency: n__shoppingCart.n__currencyCode,
currencySymbol: n__currencySymbol,
product_id: productItem.n__itemId,
product_url: productItem.n__itemProductLink.href,
image: n__staticSource + productItem.n__itemImageFull,
quantity: productItem.n__itemQty
});
}
}
_shopmsg('trigger', 'UpdateCart', {
total_price: n__shoppingCart.n__totalCost,
cta_url: n__shoppingCartRestoreLink,
currency: n__shoppingCart.n__currencyCode,
currencySymbol: n__currencySymbol,
items: shopMessageItems
});
} catch (e) {
console.error('ShopMessage Tracking Error: ', e);
}
};
//if we hit an error, then tell the user
n__newAjaxRequest.n__onError = function(n__error)
{
n__hideLoadingOverlay();
n__showAlertModal("Error", "An unknown error has occurred while attempting to update your shopping cart. Please try again. If this problem persists, please contact our sales team.",
"", function(){}, "OKAY", function(){}, function(){});
}
n__newAjaxRequest.n__process();
},
//this function will empty the shopping cart
n__emptyShoppingCart : function(n__doRequest, n__clearCoupons, n__clearItems)
{
//if we dont have anything in the cart, then do nothing.
if(!this.n__currentCoupon && !(n__associativeArrayLength(this.n__itemArray) > 0))
{
return;
}
//first update the dom
var n__param = "";
if(n__clearCoupons)
{
n__param += "coupons=1";
this.n__currentCoupon = false;
}
if(n__clearItems)
{
n__param += "&products=1";
for(n__property in this.n__itemArray)
{
for(var i = 0; i < this.n__itemArray[n__property].length; i++)
{
this.n__itemArray[n__property][i].n__itemQty = 0;
}
}
}
//refresh the cart and fire on shopping cart change event
this.n__refresh();
this.n__onShoppingCartChange();
//now do the request to empty the cart
if(n__doRequest)
{
//now we perform the ajax request
var n__newAjaxRequest = new n__ajaxRequest("GET", "/requests/request.emptyCart.php", n__param, true, true);
n__newAjaxRequest.n__onResponse = function(n__responseText)
{
var n__json = n__parseJSON(n__responseText);
//if we have an error message, print it
if(n__json.errorCode > 0)
{
n__showAlertModal("Error", n__json.errorText, "", function(){}, "OKAY", function(){}, function(){});
return;
}
};
//if we hit an error, then tell the user
n__newAjaxRequest.n__onError = function(n__error)
{
//send them to an error page
n__showAlertModal("Error", "An unknown error has occurred while attempting to empty your shopping cart. Please try again. If this problem persists, please contact our sales team.", "", function(){}, "OKAY", function(){}, function(){});
return;
}
n__newAjaxRequest.n__process();
}
},
//will get the total product shipping rate add-on
n__getShippingRateProduct : function()
{
///determine if product specific costs
var n__productShippingPriceAdditionTotal = 0;
var n__hasWatchInOrder = false;
if(n__shoppingCart.n__shippingCountryCode == "US")
{
//loop through items
for(var n__property in n__shoppingCart.n__itemArray)
{
for(var i = 0; i < n__shoppingCart.n__itemArray[n__property].length; i++)
{
if(n__shoppingCart.n__itemArray[n__property][i].n__itemQty > 0)
{
//if has watch, then no shipping
if(n__shoppingCart.n__itemArray[n__property][i].n__itemType == "watch")
{
n__hasWatchInOrder = true;
}
if(typeof n__shoppingCart.n__itemArray[n__property][i].n__itemShippingRatesArray['US'] != "undefined")
{
n__productShippingPriceAdditionTotal += parseFloat(n__shoppingCart.n__itemArray[n__property][i].n__itemShippingRatesArray['US']['shippingPriceAddition']) *
n__shoppingCart.n__itemArray[n__property][i].n__itemQty;
}
}
}
}
}
//internnational
else
{
//loop through items
for(var n__property in n__shoppingCart.n__itemArray)
{
for(var i = 0; i < n__shoppingCart.n__itemArray[n__property].length; i++)
{
if(n__shoppingCart.n__itemArray[n__property][i].n__itemQty > 0)
{
//if has watch, then no shipping
if(n__shoppingCart.n__itemArray[n__property][i].n__itemType == "watch")
{
n__hasWatchInOrder = true;
}
//if we have this specific country, then use it
if(typeof n__shoppingCart.n__itemArray[n__property][i].n__itemShippingRatesArray[n__shoppingCart.n__shippingCountryCode] != "undefined")
{
n__productShippingPriceAdditionTotal += parseFloat(n__shoppingCart.n__itemArray[n__property][i].n__itemShippingRatesArray[n__shoppingCart.n__shippingCountryCode]['shippingPriceAddition']) *
n__shoppingCart.n__itemArray[n__property][i].n__itemQty;
}
//else if we have a global value set
else if(typeof n__shoppingCart.n__itemArray[n__property][i].n__itemShippingRatesArray["GLOBAL"] != "undefined")
{
n__productShippingPriceAdditionTotal += parseFloat(n__shoppingCart.n__itemArray[n__property][i].n__itemShippingRatesArray["GLOBAL"]['shippingPriceAddition']) *
n__shoppingCart.n__itemArray[n__property][i].n__itemQty;
}
}
}
}
}
n__maxShippingCharges = (n__productShippingMax *
n__shoppingCart.n__currencyConversionRate) *
(1 + (n__shoppingCart.n__currencyCode != "USD" ? n__productShippingNonUSDPadding : 0))
//max product add on globally
if(n__productShippingPriceAdditionTotal > n__maxShippingCharges)
{
n__productShippingPriceAdditionTotal = n__maxShippingCharges;
}
if(n__hasWatchInOrder == true)
{
n__productShippingPriceAdditionTotal = 0;
}
return n__productShippingPriceAdditionTotal;
},
//get shipping rate - will use the current shipping rate selected, to determine shipping flat rate
n__getShippingRate : function()
{
var n__returnedShippingPrice = 0;
if(this.n__shippingRateId > 0)
{
try
{
//if there is a current coupon with shipping free, then return 0
if(this.n__currentCoupon && this.n__currentCoupon.n__couponShippingFree == "YES")
{
return 0;
}
else if(typeof this.n__shippingRateArray['shippingRateId' + this.n__shippingRateId] != 'undefined')
{
n__returnedShippingPrice += this.n__shippingRateArray['shippingRateId' + this.n__shippingRateId].n__shippingRatePrice;
}
}
catch (err){}
}
return n__round(this.n__getShippingRateProduct()+n__returnedShippingPrice, 2);
},
//get sales tax
n__getSalesTaxTotal : function()
{
try
{
//if there is a current coupon with shipping free, then return 0
if(this.n__currentCoupon && this.n__currentCoupon.n__couponSalesTaxFree == "YES")
{
this.n__salesTaxDescription = "";
return 0;
}
else if(this.n__shippingCountryCode == "US" && (this.n__billingState == "MO" || this.n__billingState == "Missouri"))
{
//if we have a gift card in this shopping cart, dont charge sales tax at all
var n__substractFromSalesTaxGiftCard = 0;
try
{
for(n__property in this.n__itemArray)
{
for(var i = 0; i < this.n__itemArray[n__property].length; i++)
{
if(this.n__itemArray[n__property][i].n__itemQty > 0 && typeof this.n__itemArray[n__property][i].n__itemCustomizationArray['giftCard'] != "undefined")
{
n__substractFromSalesTaxGiftCard += this.n__itemArray[n__property][i].n__itemQty*this.n__itemArray[n__property][i].n__itemPrice;
}
}
}
}catch(err){}
this.n__salesTaxDescription = "Missouri Sale Tax";
// no sales tax on 0 value or less orders
if (this.n__subTotalCost-(n__substractFromSalesTaxGiftCard+this.n__totalDiscount) > 0) {
return (this.n__subTotalCost-(n__substractFromSalesTaxGiftCard+this.n__totalDiscount)) * n__moSalesTaxRate;
} else {
return 0;
}
}
}
catch (err){}
return 0;
},
//adds a shipping rate to the shipping rate array
n__addShippingRate : function(n__shippingRateId, n__shippingRateTitle, n__shippingRatePrice,
n__shippingRateLocation)
{
var n__newShippingRate = new this.n__shippingRate();
n__newShippingRate.n__shippingRateId = n__shippingRateId;
n__newShippingRate.n__shippingRateTitle = n__shippingRateTitle;
n__newShippingRate.n__shippingRatePrice = parseFloat(n__shippingRatePrice);
n__newShippingRate.n__shippingRateLocation = n__shippingRateLocation;
n__newShippingRate.n__init();
this.n__shippingRateArray['shippingRateId' + n__shippingRateId] = n__newShippingRate;
},
//this will add the coupon to the dom and set the current coupon as this one,
//if you dont want to refresh the list, pass FALSE as the first parameter
n__addCouponToDom : function(n__refreshList, n__couponId, n__couponType, n__couponDiscountType,
n__couponDiscount, n__couponShippingFree, n__couponSizingFree,
n__couponGiftWrapFree, n__couponBoxEngravingFree, n__couponWatchEngravingFree,
n__couponSalesTaxFree, n__couponCode, n__couponDescription, n__productId,
n__productQtyAvailable, n__productQtyUsed, n__globalQtyAvailable,
n__globalQtyUsed)
{
//free sizing things
var n__hadPriorCouponWithFreeSizing = false;
if(typeof this.n__currentCoupon.n__couponSizingFree != 'undefined' && this.n__currentCoupon.n__couponSizingFree == "YES")
{
n__hadPriorCouponWithFreeSizing = true;
}
var n__hadPriorCouponWithFreeGiftWrap = false;
if(typeof this.n__currentCoupon.n__couponGiftWrapFree != 'undefined' && this.n__currentCoupon.n__couponGiftWrapFree == "YES")
{
n__hadPriorCouponWithFreeGiftWrap = true;
}
var n__hadPriorCouponWithFreeBoxEngravingWrap = false;
if(typeof this.n__currentCoupon.n__couponBoxEngravingFree != 'undefined' && this.n__currentCoupon.n__couponBoxEngravingFree == "YES")
{
n__hadPriorCouponWithFreeBoxEngravingWrap = true;
}
var n__hadPriorCouponWithFreeWatchEngravingWrap = false;
if(typeof this.n__currentCoupon.n__couponWatchEngravingFree != 'undefined' && this.n__currentCoupon.n__couponWatchEngravingFree == "YES")
{
n__hadPriorCouponWithFreeWatchEngravingWrap = true;
}
var n__newCoupon = new this.n__coupon();
n__newCoupon.n__couponId = n__couponId;
n__newCoupon.n__couponType = n__couponType;
n__newCoupon.n__couponDiscountType = n__couponDiscountType;
n__newCoupon.n__couponDiscount = parseFloat(n__couponDiscount);
n__newCoupon.n__couponShippingFree = n__couponShippingFree;
n__newCoupon.n__couponSizingFree = n__couponSizingFree;
n__newCoupon.n__couponGiftWrapFree = n__couponGiftWrapFree;
n__newCoupon.n__couponBoxEngravingFree = n__couponBoxEngravingFree;
n__newCoupon.n__couponWatchEngravingFree = n__couponWatchEngravingFree;
n__newCoupon.n__couponSalesTaxFree = n__couponSalesTaxFree;
n__newCoupon.n__couponCode = n__couponCode;
n__newCoupon.n__couponDescription = n__couponDescription;
n__newCoupon.n__productId = n__productId;
n__newCoupon.n__productQtyAvailable = parseInt(n__productQtyAvailable);
n__newCoupon.n__productQtyUsed = parseInt(n__productQtyUsed);
n__newCoupon.n__globalQtyAvailable = parseInt(n__globalQtyAvailable);
n__newCoupon.n__globalQtyUsed = parseInt(n__globalQtyUsed);
n__newCoupon.n__init();
this.n__currentCoupon = n__newCoupon;
this.n__handleApplyFreeSizing(n__hadPriorCouponWithFreeSizing);
this.n__handleApplyFreeGiftWrap(n__hadPriorCouponWithFreeGiftWrap);
this.n__handleApplyFreeBoxEngraving(n__hadPriorCouponWithFreeBoxEngravingWrap);
this.n__handleApplyFreeWatchEngraving(n__hadPriorCouponWithFreeWatchEngravingWrap);
if(n__refreshList)
{
this.n__refresh();
}
return true;
},
//this will remove a coupon, pass TRUE if you want to do the actual request
//and FALSE if you do not
n__removeCoupon : function(n__doRequest)
{
//free sizing things
var n__hadPriorCouponWithFreeSizing = false;
if(typeof this.n__currentCoupon.n__couponSizingFree != 'undefined' && this.n__currentCoupon.n__couponSizingFree == "YES")
{
n__hadPriorCouponWithFreeSizing = true;
}
var n__hadPriorCouponWithFreeGiftWrap = false;
if(typeof this.n__currentCoupon.n__couponGiftWrapFree != 'undefined' && this.n__currentCoupon.n__couponGiftWrapFree == "YES")
{
n__hadPriorCouponWithFreeGiftWrap = true;
}
var n__hadPriorCouponWithFreeBoxEngravingWrap = false;
if(typeof this.n__currentCoupon.n__couponBoxEngravingFree != 'undefined' && this.n__currentCoupon.n__couponBoxEngravingFree == "YES")
{
n__hadPriorCouponWithFreeBoxEngravingWrap = true;
}
var n__hadPriorCouponWithFreeWatchEngravingWrap = false;
if(typeof this.n__currentCoupon.n__couponWatchEngravingFree != 'undefined' && this.n__currentCoupon.n__couponWatchEngravingFree == "YES")
{
n__hadPriorCouponWithFreeWatchEngravingWrap = true;
}
//set the current coupon to false
this.n__currentCoupon = false;
//apply free sizing reveral (if applicable)
this.n__handleApplyFreeSizing(n__hadPriorCouponWithFreeSizing);
this.n__handleApplyFreeGiftWrap(n__hadPriorCouponWithFreeGiftWrap);
this.n__handleApplyFreeBoxEngraving(n__hadPriorCouponWithFreeBoxEngravingWrap);
this.n__handleApplyFreeWatchEngraving(n__hadPriorCouponWithFreeWatchEngravingWrap);
//refresh the list
this.n__refresh();
//fire the shopping cart change
this.n__onShoppingCartChange();
//perform the request if we want to
if(n__doRequest)
{
//now we perform the ajax request
var n__param = "addRemove=0";
var n__newAjaxRequest = new n__ajaxRequest("GET", "/requests/request.addRemoveCoupon.php", n__param, true, true);
n__newAjaxRequest.n__onResponse = function(n__responseText)
{
var n__json = n__parseJSON(n__responseText);
//if we have an error message, print it
if(n__json.errorCode > 0)
{
n__showAlertModal("Error", n__json.errorText, "", function(){}, "OKAY", function(){}, function(){});
return;
}
};
//if we hit an error, then tell the user
n__newAjaxRequest.n__onError = function(n__error)
{
n__showAlertModal("Error", "An unknown error has occurred while attempting to remove the coupon from your shopping cart. Please try again. If this problem persists, please contact our sales team.", "", function(){}, "OKAY", function(){}, function(){});
return;
}
n__newAjaxRequest.n__process();
}
},
n__handleApplyFreeSizing : function(n__hadPriorCouponWithFreeSizing)
{
//loop through all of the items
for(n__property in this.n__itemArray)
{
for(var i = 0; i < this.n__itemArray[n__property].length; i++)
{
try
{
if(typeof this.n__itemArray[n__property][i].n__itemCustomizationArray['sized']['wristSizeFraction'] != "undefined")
{
if(typeof this.n__currentCoupon.n__couponSizingFree != 'undefined' && this.n__currentCoupon.n__couponSizingFree == "YES" && n__hadPriorCouponWithFreeSizing == false)
{
this.n__itemArray[n__property][i].n__itemPrice -= n__round(this.n__itemArray[n__property][i].n__itemCustomizationArray['sized']['additionalCharge'], 2);
//update dom
this.n__itemArray[n__property][i].n__itemPriceCell.innerHTML = n__currencySymbol + parseFloat(this.n__itemArray[n__property][i].n__itemPrice).toFixed(2) + n__currencyCodeString;
}
if(this.n__itemArray[n__property][i].n__itemPrice < 0)
{
this.n__itemArray[n__property][i].n__itemPrice = 0;
}
if(typeof this.n__currentCoupon.n__couponSizingFree == 'undefined' && n__hadPriorCouponWithFreeSizing == true)
{
this.n__itemArray[n__property][i].n__itemPrice += n__round(this.n__itemArray[n__property][i].n__itemCustomizationArray['sized']['additionalCharge'], 2);
//update dom
this.n__itemArray[n__property][i].n__itemPriceCell.innerHTML = n__currencySymbol + parseFloat(this.n__itemArray[n__property][i].n__itemPrice).toFixed(2) + n__currencyCodeString;
}
}
}
catch (err){}
}
}
},
n__handleApplyFreeGiftWrap : function(n__hadPriorCouponWithFreeGiftWrap)
{
//loop through all of the items
for(n__property in this.n__itemArray)
{
for(var i = 0; i < this.n__itemArray[n__property].length; i++)
{
try
{
if(typeof this.n__itemArray[n__property][i].n__itemCustomizationArray['giftWrap']['style'] != "undefined")
{
if(typeof this.n__currentCoupon.n__couponGiftWrapFree != 'undefined' && this.n__currentCoupon.n__couponGiftWrapFree == "YES" && n__hadPriorCouponWithFreeGiftWrap == false)
{
this.n__itemArray[n__property][i].n__itemPrice -= n__round(this.n__itemArray[n__property][i].n__itemCustomizationArray['giftWrap']['additionalCharge'], 2);
//update dom
this.n__itemArray[n__property][i].n__itemPriceCell.innerHTML = n__currencySymbol + parseFloat(this.n__itemArray[n__property][i].n__itemPrice).toFixed(2) + n__currencyCodeString;
}
if(this.n__itemArray[n__property][i].n__itemPrice < 0)
{
this.n__itemArray[n__property][i].n__itemPrice = 0;
}
if(typeof this.n__currentCoupon.n__couponGiftWrapFree == 'undefined' && n__hadPriorCouponWithFreeGiftWrap == true)
{
this.n__itemArray[n__property][i].n__itemPrice += n__round(this.n__itemArray[n__property][i].n__itemCustomizationArray['giftWrap']['additionalCharge'], 2);
//update dom
this.n__itemArray[n__property][i].n__itemPriceCell.innerHTML = n__currencySymbol + parseFloat(this.n__itemArray[n__property][i].n__itemPrice).toFixed(2) + n__currencyCodeString;
}
}
}
catch (err){}
}
}
},
n__handleApplyFreeBoxEngraving : function(n__hadPriorCouponWithFreeBoxEngravingWrap)
{
//loop through all of the items
for(n__property in this.n__itemArray)
{
for(var i = 0; i < this.n__itemArray[n__property].length; i++)
{
try
{
if(typeof this.n__itemArray[n__property][i].n__itemCustomizationArray['engravingBox'] != "undefined")
{
if(typeof this.n__currentCoupon.n__couponBoxEngravingFree != 'undefined' && this.n__currentCoupon.n__couponBoxEngravingFree == "YES" && n__hadPriorCouponWithFreeBoxEngravingWrap == false)
{
this.n__itemArray[n__property][i].n__itemPrice -= n__round(this.n__itemArray[n__property][i].n__itemCustomizationArray['engravingBox']['additionalCharge'], 2);
//update dom
this.n__itemArray[n__property][i].n__itemPriceCell.innerHTML = n__currencySymbol + parseFloat(this.n__itemArray[n__property][i].n__itemPrice).toFixed(2) + n__currencyCodeString;
}
if(this.n__itemArray[n__property][i].n__itemPrice < 0)
{
this.n__itemArray[n__property][i].n__itemPrice = 0;
}
if(typeof this.n__currentCoupon.n__couponBoxEngravingFree == 'undefined' && n__hadPriorCouponWithFreeBoxEngravingWrap == true)
{
this.n__itemArray[n__property][i].n__itemPrice += n__round(this.n__itemArray[n__property][i].n__itemCustomizationArray['engravingBox']['additionalCharge'], 2);
//update dom
this.n__itemArray[n__property][i].n__itemPriceCell.innerHTML = n__currencySymbol + parseFloat(this.n__itemArray[n__property][i].n__itemPrice).toFixed(2) + n__currencyCodeString;
}
}
}
catch (err){}
}
}
},
n__handleApplyFreeWatchEngraving : function(n__hadPriorCouponWithFreeWatchEngravingWrap)
{
//loop through all of the items
for(n__property in this.n__itemArray)
{
for(var i = 0; i < this.n__itemArray[n__property].length; i++)
{
try
{
if(typeof this.n__itemArray[n__property][i].n__itemCustomizationArray['engravingWatch'] != "undefined")
{
if(typeof this.n__currentCoupon.n__couponWatchEngravingFree != 'undefined' && this.n__currentCoupon.n__couponWatchEngravingFree == "YES" && n__hadPriorCouponWithFreeWatchEngravingWrap == false)
{
this.n__itemArray[n__property][i].n__itemPrice -= n__round(this.n__itemArray[n__property][i].n__itemCustomizationArray['engravingWatch']['additionalCharge'], 2);
//update dom
this.n__itemArray[n__property][i].n__itemPriceCell.innerHTML = n__currencySymbol + parseFloat(this.n__itemArray[n__property][i].n__itemPrice).toFixed(2) + n__currencyCodeString;
}
if(this.n__itemArray[n__property][i].n__itemPrice < 0)
{
this.n__itemArray[n__property][i].n__itemPrice = 0;
}
if(typeof this.n__currentCoupon.n__couponWatchEngravingFree == 'undefined' && n__hadPriorCouponWithFreeWatchEngravingWrap == true)
{
this.n__itemArray[n__property][i].n__itemPrice += n__round(this.n__itemArray[n__property][i].n__itemCustomizationArray['engravingWatch']['additionalCharge'], 2);
//update dom
this.n__itemArray[n__property][i].n__itemPriceCell.innerHTML = n__currencySymbol + parseFloat(this.n__itemArray[n__property][i].n__itemPrice).toFixed(2) + n__currencyCodeString;
}
}
}
catch (err){}
}
}
},
//when a user requests to add a coupon to the system
n__addCouponByCode : function(n__couponCode, silent)
{
//if no coupon
if(n__trim(n__couponCode) == "" && !silent)
{
n__showAlertModal("An Error Occurred", "Please specify your gift code.", "", function(){}, "OKAY", function(){}, function(){});
return;
}
if (!silent) {
n__showLoadingOverlay();
}
//now we perform the ajax request
var n__param = "couponCode="+n__urlEncodeString(n__couponCode)+"&addRemove=1";
var n__newAjaxRequest = new n__ajaxRequest("GET", "/requests/request.addRemoveCoupon.php", n__param, true, true);
n__newAjaxRequest.n__onResponse = function(n__responseText)
{
if (!silent) {
n__hideLoadingOverlay();
}
var n__json = n__parseJSON(n__responseText);
//if we have an error message, print it
if(n__json.errorCode > 0)
{
if (!silent) {
n__showAlertModal("Gift Code Error", n__json.errorText, "", function(){}, "OKAY", function(){}, function(){});
}
return;
}
else //we were successfuly
{
//reparse the shopping cart (fire the onShoppingCart change)
n__shoppingCart.n__parseShoppingCartFeed(n__json, true);
if (!silent) {
n__showAlertModal("Discount Applied!", "The gift code you have entered has been successfully applied to your shopping cart.", "", function(){}, "OKAY", function(){}, function(){});
}
return;
}
};
//if we hit an error, then tell the user
n__newAjaxRequest.n__onError = function(n__error)
{
if (!silent) {
n__hideLoadingOverlay();
n__showAlertModal("An Error Occurred", "An unknown error has occurred while attempting to add the discount code to your shopping cart. Please try again. If this problem persists, please contact our sales team.", "", function(){}, "OKAY", function(){}, function(){});
return;
}
}
n__newAjaxRequest.n__process();
},
//this function will take a shopping cart feed, and update this menu accordingly
n__parseShoppingCartFeed : function(n__jsonFeed, n__fireOnShoppingCartChange)
{
//first we need to clear out all of the shopping cart
this.n__itemCount = 0;
this.n__totalCost = 0;
this.n__subTotalCost = 0;
this.n__shippingCost = 0;
this.n__itemArray = new Array();
this.n__currentCoupon = false;
this.n__shippingRateArray = new Array();
//add the coupon if it exists
if(n__jsonFeed.shoppingCart.coupon)
{
this.n__addCouponToDom( false,
n__jsonFeed.shoppingCart.coupon.couponId,
n__jsonFeed.shoppingCart.coupon.couponType,
n__jsonFeed.shoppingCart.coupon.couponDiscountType,
n__jsonFeed.shoppingCart.coupon.couponDiscount,
n__jsonFeed.shoppingCart.coupon.couponShippingFree,
n__jsonFeed.shoppingCart.coupon.couponSizingFree,
n__jsonFeed.shoppingCart.coupon.couponGiftWrapFree,
n__jsonFeed.shoppingCart.coupon.couponBoxEngravingFree,
n__jsonFeed.shoppingCart.coupon.couponWatchEngravingFree,
n__jsonFeed.shoppingCart.coupon.couponSalesTaxFree,
n__jsonFeed.shoppingCart.coupon.couponCode,
n__jsonFeed.shoppingCart.coupon.couponDescription,
n__jsonFeed.shoppingCart.coupon.productId,
n__jsonFeed.shoppingCart.coupon.productQtyAvailable,
n__jsonFeed.shoppingCart.coupon.productQtyUsed,
n__jsonFeed.shoppingCart.coupon.globalQtyAvailable,
n__jsonFeed.shoppingCart.coupon.globalQtyUsed
);
}
//loop through and add all of the items
for(var i = 0; i < n__jsonFeed.shoppingCart.products.length; i++)
{
this.n__addItemToDom( n__jsonFeed.shoppingCart.products[i].productId,
n__jsonFeed.shoppingCart.products[i].productType,
n__jsonFeed.shoppingCart.products[i].productIsLimited,
n__jsonFeed.shoppingCart.products[i].productSlug,
n__jsonFeed.shoppingCart.products[i].productSlugChild,
n__jsonFeed.shoppingCart.products[i].productNameCart,
n__jsonFeed.shoppingCart.products[i].productQuantity,
n__jsonFeed.shoppingCart.products[i].productPrice,
n__jsonFeed.shoppingCart.products[i].productImageFull,
n__jsonFeed.shoppingCart.products[i].productImageThumb,
n__jsonFeed.shoppingCart.products[i].parentProductId,
n__jsonFeed.shoppingCart.products[i].productOnBackorder,
n__Base64.n__decode(n__jsonFeed.shoppingCart.products[i].customization),
n__Base64.n__decode(n__jsonFeed.shoppingCart.products[i].productShippingRates)
);
}
//loop through the shipping rates
for(n__property in n__jsonFeed.shoppingCart.shipping)
{
this.n__addShippingRate( n__jsonFeed.shoppingCart.shipping[n__property].shippingRateId,
n__jsonFeed.shoppingCart.shipping[n__property].shippingRateTitle,
n__jsonFeed.shoppingCart.shipping[n__property].shippingRatePrice,
n__jsonFeed.shoppingCart.shipping[n__property].shippingRateLocation
);
}
//set the shipping rate to be what was selected
this.n__shippingRateId = n__jsonFeed.shoppingCart.shippingRateId;
this.n__shippingCountryCode = n__jsonFeed.shoppingCart.shippingCountryCode;
this.n__billingState = n__jsonFeed.shoppingCart.currentBillingState;
this.n__salesTaxDescription = n__jsonFeed.shoppingCart.currentSalesTaxDescription;
this.n__currencyCode = n__jsonFeed.shoppingCart.currencyCode;
this.n__currencyConversionRate = parseFloat(n__jsonFeed.shoppingCart.currencyConversionRate);
//refresh the shopping cart
this.n__refresh();
if(typeof n__fireOnShoppingCartChange != 'undefined' && n__fireOnShoppingCartChange == true)
{
//fire the on shopping cart change
n__shoppingCart.n__onShoppingCartChange();
}
},
n__item : function()
{
var n__item = {
n__itemId : "",
n__itemType : "",
n__itemIsLimited: false,
n__itemSlug : "",
n__itemSlugChild : "",
n__itemImageFull : "",
n__itemImageThumb : "",
n__itemTitle : "",
n__itemQty : 0,
n__itemPrice : 0,
n__itemOnBackorder : 0,
n__itemCustomization : "",
n__itemCustomizationArray : new Array(),
n__itemShippingRates : "",
n__itemShippingRatesArray : new Array(),
n__itemParentProductId : "",
n__itemListItem : document.createElement('li'),
n__itemDeleteLink : document.createElement('a'),
n__itemProductLink : document.createElement('a'),
n__itemProductImage : document.createElement('img'),
n__itemProductDescriptionDiv : document.createElement('div'),
n__itemProductDescriptionCustomDiv : document.createElement('div'),
n__itemQuantityH5 : document.createElement('h5'),
n__itemProductDescriptionLimitedDiv : document.createElement('div'),
n__itemProductDescriptionNoDiscountsDiv : document.createElement('div'),
n__itemProductDescriptionBackorderDiv : document.createElement('div'),
n__init : function()
{
//delete link
this.n__itemDeleteLink.href = "#";
this.n__itemDeleteLink.setAttribute("aria-label", "Remove Item Button");
this.n__itemDeleteLink.innerHTML = "";
n__setClass(this.n__itemDeleteLink, "delete");
this.n__itemDeleteLink.onclick = function()
{
n__shoppingCart.n__removeItem(n__item.n__itemId, n__item.n__itemCustomization);
return false;
}
this.n__itemListItem.appendChild(this.n__itemDeleteLink);
//product link
this.n__itemProductLink.href = "https://www.jord.co/series/"+this.n__itemSlug+"/"+this.n__itemSlugChild;
if(this.n__itemType == "watch-link")
{
this.n__itemProductLink.href = "https://www.jord.co/additional-links";
}
else if(this.n__itemType == "gift-card")
{
this.n__itemProductLink.href = "https://www.jord.co/gift-cards";
}
else if(this.n__itemType == "accessory" && this.n__itemId < 126)
{
this.n__itemProductLink.href = "https://www.jord.co/care";
}
else if(this.n__itemType == "accessory" && this.n__itemId <= 126)
{
this.n__itemProductLink.href = "https://www.jord.co/series/hat";
}
else if(this.n__itemType == "accessory" && this.n__itemParentProductId == '290')
{
this.n__itemProductLink.href = "https://www.jord.co/wood-postcard";
}
else if(this.n__itemType == "watch-band")
{
//same as watch, but just calling it out separate here
this.n__itemProductLink.href = "https://www.jord.co/series/"+this.n__itemSlug+"/"+this.n__itemSlugChild;
}
this.n__itemListItem.appendChild(this.n__itemProductLink);
//image
if(this.n__itemImageThumb=='/images/products/shop/'){
this.n__itemImageThumb ='/images/gift-set.png';
}
this.n__itemProductImage.src = n__staticSource + this.n__itemImageThumb;
this.n__itemProductImage.alt = this.n__itemTitle;
this.n__itemProductLink.appendChild(this.n__itemProductImage);
//product description
this.n__itemProductDescriptionDiv.innerHTML = this.n__itemTitle;
n__setClass(this.n__itemProductDescriptionDiv, "item-product-description");
this.n__itemProductLink.appendChild(this.n__itemProductDescriptionDiv);
//product description custom
this.n__itemProductDescriptionCustomDiv.style.display = 'none';
try
{
/*
n__jsonCustomizationArray['engravingWatch']['text']
n__jsonCustomizationArray['engravingWatch']['additionalCharge']
n__jsonCustomizationArray['engravingWatch']['timeframe']
n__jsonCustomizationArray['engravingWatch']['lineHeight']
n__jsonCustomizationArray['engravingWatch']['textAlign']
n__jsonCustomizationArray['engravingWatch']['fontFamily']
n__jsonCustomizationArray['engravingWatch']['fontSize']
n__jsonCustomizationArray['engravingWatch']['html']
*/
if(typeof this.n__itemCustomizationArray['engravingWatch'] != 'undefined')
{
var n__rushedText = "";
try
{
if(this.n__itemCustomizationArray['engravingWatch']['timeframe'] == "rush")
{
n__rushedText = " (Rushed)";
}
}catch(err){}
//modal popup of circle (opening modal includes fonts)
this.n__itemProductDescriptionCustomDiv.innerHTML += "Backplate Engraved"+n__rushedText+"
";
this.n__itemProductDescriptionCustomDiv.style.display = '';
}
}
catch (err){}
try
{
/*
n__jsonCustomizationArray['engravingBox']['file'] //file or text (one or the other
n__jsonCustomizationArray['engravingBox']['text']
n__jsonCustomizationArray['engravingBox']['fontFamily']
n__jsonCustomizationArray['engravingBox']['timeframe']
n__jsonCustomizationArray['engravingBox']['additionalCharge']
*/
if(typeof this.n__itemCustomizationArray['engravingBox'] != 'undefined')
{
var n__rushedText = "";
try
{
if(this.n__itemCustomizationArray['engravingBox']['timeframe'] == "rush")
{
n__rushedText = " (Rushed)";
}
}catch(err){}
if(typeof this.n__itemCustomizationArray['engravingBox']['text'] != "undefined" &&
this.n__itemCustomizationArray['engravingBox']['text'] != "")
{
if(this.n__itemParentProductId!='290'){
this.n__itemProductDescriptionCustomDiv.innerHTML += "Watch Box Engraved"+n__rushedText+"
";
}
this.n__itemProductDescriptionCustomDiv.style.display = '';
}
else if(typeof this.n__itemCustomizationArray['engravingBox']['file'] != "undefined" &&
this.n__itemCustomizationArray['engravingBox']['file'] != "")
{
//popup of image
if(this.n__itemParentProductId!='290'){
this.n__itemProductDescriptionCustomDiv.innerHTML += "Watch Box Engraved"+n__rushedText+"";
}
this.n__itemProductDescriptionCustomDiv.style.display = '';
}
}
}
catch (err){}
try
{
/*
n__jsonCustomizationArray['bandType'] = "apple"
n__jsonCustomizationArray['caseSize'] = "38mm"
*/
if(this.n__itemCustomizationArray['bandType'] == 'apple' && this.n__itemCustomizationArray['caseSize'] != '')
{
this.n__itemProductDescriptionCustomDiv.innerHTML += "For " + this.n__itemCustomizationArray['caseSize'] + (this.n__itemCustomizationArray['lugEndColor'] ? ' (' + this.n__itemCustomizationArray['lugEndColor'] + ' ends)' : '') + " Apple Watch
";
this.n__itemProductDescriptionCustomDiv.style.display = '';
}
}
catch (err){}
try
{
/*n__jsonCustomizationArray['sized']['numberOfLinks']
n__jsonCustomizationArray['sized']['additionalCharge']
n__jsonCustomizationArray['sized']['wristSizeDecimal']
n__jsonCustomizationArray['sized']['wristSizeFraction']
*/
if(typeof this.n__itemCustomizationArray['sized'] != 'undefined')
{
this.n__itemProductDescriptionCustomDiv.innerHTML += "Sized To "+this.n__itemCustomizationArray['sized']['wristSizeFraction']+"
";
this.n__itemProductDescriptionCustomDiv.style.display = '';
}
}
catch (err){}
try
{
/*n__jsonCustomizationArray['watchLinks']['watchId']
n__jsonCustomizationArray['watchLinks']['watchName']
n__jsonCustomizationArray['watchLinks']['numberOfLinks']
n__jsonCustomizationArray['watchLinks']['chargeEach']
n__jsonCustomizationArray['watchLinks']['totalCharge']
*/
if(typeof this.n__itemCustomizationArray['watchLinks'] != 'undefined')
{
this.n__itemProductDescriptionCustomDiv.innerHTML += "For "+this.n__itemCustomizationArray['watchLinks']['watchName']+"
";
this.n__itemProductDescriptionCustomDiv.style.display = '';
}
}
catch (err){}
try
{
/*
n__jsonCustomizationArray.giftCard.deliveryMethod = n__eById('giftCardDeliveryMethod').value;
n__jsonCustomizationArray.giftCard.amount = n__round(n__eById('giftCardAmount').value, 2, false);
*/
if(typeof this.n__itemCustomizationArray['giftCard'] != 'undefined')
{
var n__deliveryMethod = "Digital";
if(this.n__itemCustomizationArray['giftCard']['deliveryMethod'] == "physical")
{
n__deliveryMethod = "Physical Card";
}
this.n__itemProductDescriptionCustomDiv.innerHTML += "Delivery Method: "+n__deliveryMethod+"
";
this.n__itemProductDescriptionCustomDiv.style.display = '';
}
}
catch (err){}
try
{
/*n__jsonCustomizationArray['giftWrap']['style']
n__jsonCustomizationArray['giftWrap']['additionalCharge']
*/
if(typeof this.n__itemCustomizationArray['giftWrap'] != 'undefined')
{
if(this.n__itemCustomizationArray['giftWrap']['style'] == "fathers-day")
{
this.n__itemProductDescriptionCustomDiv.innerHTML += "With Father's Day Gift Sleeve
";
this.n__itemProductDescriptionCustomDiv.style.display = '';
}
}
}
catch (err){}
n__setClass(this.n__itemProductDescriptionCustomDiv, "item-product-description-custom");
this.n__itemProductLink.appendChild(this.n__itemProductDescriptionCustomDiv);
//qty/price section
n__setClass(this.n__itemQuantityH5, "quantity");
this.n__refreshQty();
this.n__itemListItem.appendChild(this.n__itemQuantityH5);
//limited text
this.n__itemProductDescriptionLimitedDiv.style.display = "none";
n__setClass(this.n__itemProductDescriptionLimitedDiv, "item-product-description-limited");
this.n__itemProductDescriptionLimitedDiv.innerHTML = "Limited
(Coupons and discounts unavailable)";
this.n__itemListItem.appendChild(this.n__itemProductDescriptionLimitedDiv);
try {
if (this.n__itemIsLimited) {
this.n__itemProductDescriptionLimitedDiv.style.display = "";
}
} catch (err) {}
//No discounts
this.n__itemProductDescriptionNoDiscountsDiv.style.display = "none";
n__setClass(this.n__itemProductDescriptionNoDiscountsDiv, "item-product-description-no-discounts");
this.n__itemProductDescriptionNoDiscountsDiv.innerHTML = "Limited Pricing!
Can not be combined with any codes";
this.n__itemListItem.appendChild(this.n__itemProductDescriptionNoDiscountsDiv);
try {
if (this.n__itemParentProductId == 121) {
this.n__itemProductDescriptionNoDiscountsDiv.style.display = "";
}
} catch (err) {}
//backorder text
this.n__itemProductDescriptionBackorderDiv.style.display = "none";
n__setClass(this.n__itemProductDescriptionBackorderDiv, "item-product-description-backorder");
this.n__itemProductDescriptionBackorderDiv.innerHTML = "On Preorder";
this.n__itemListItem.appendChild(this.n__itemProductDescriptionBackorderDiv);
try {
if (parseInt(this.n__itemOnBackorder) == 1) {
this.n__itemProductDescriptionBackorderDiv.style.display = "";
}
} catch (err) {}
},
n__refreshQty : function()
{
this.n__itemQuantityH5.innerHTML = "";
if(this.n__itemQty > 1)
{
this.n__itemQuantityH5.innerHTML = "Qty "+this.n__itemQty+" - ";
}
this.n__itemQuantityH5.innerHTML += n__currencySymbol + parseFloat(this.n__itemPrice).toFixed(2) + n__currencyCodeString;
}
}
return n__item;
},
n__coupon : function()
{
var n__coupon = {
n__couponId : 0,
n__couponType : "",
n__couponDiscountType : "",
n__couponDiscount : 0,
n__couponShippingFree : "NO",
n__couponSizingFree : "NO",
n__couponBoxEngravingFree : "NO",
n__couponWatchEngravingFree : "NO",
n__couponSalesTaxFree : "NO",
n__couponCode : "",
n__couponDescription : "",
n__productId : "",
n__productQtyAvailable : 0,
n__productQtyUsed : 0,
n__globalQtyAvailable : 0,
n__globalQtyUsed : 0,
n__actualDiscount : 0,
n__couponListItem : document.createElement('li'),
n__couponDeleteLink : document.createElement('a'),
n__couponDescriptionDiv : document.createElement('div'),
n__couponDiscountH5 : document.createElement('h5'),
n__init : function()
{
//BUILD DOM
this.n__couponListItem.appendChild(this.n__couponDeleteLink);
this.n__couponListItem.appendChild(this.n__couponDescriptionDiv);
this.n__couponListItem.appendChild(this.n__couponDiscountH5);
//delete link
this.n__couponDeleteLink.href = '#';
n__setClass(this.n__couponDeleteLink, "delete");
this.n__couponDeleteLink.setAttribute("aria-label", "Remove Coupon Button");
this.n__couponDeleteLink.innerHTML = '';
this.n__couponDeleteLink.onclick = function()
{
n__shoppingCart.n__removeCoupon(true);
return false;
}
//descritption
this.n__couponDescriptionDiv.innerHTML = this.n__couponDescription;
//discount amount
n__setClass(this.n__couponDiscountH5, "quantity");
},
//to set the actual discount value
n__setActualDiscount : function()
{
var n__actualDiscount = parseFloat(this.n__actualDiscount).toFixed(2);
if(n__actualDiscount > 0)
{
this.n__couponDiscountH5.innerHTML = '-' + n__currencySymbol + n__numberFormatWithCommas(n__actualDiscount, 2) + n__currencyCodeString;
}
else
{
this.n__couponDiscountH5.innerHTML = '';
}
}
}
return n__coupon;
},
n__shippingRate : function()
{
var n__shippingRate = {
n__shippingRateId : 0,
n__shippingRateTitle : "",
n__shippingRatePrice : 0,
n__shippingRateLocation : "",
n__init : function()
{
}
}
return n__shippingRate;
}
}
return n__shoppingCart;
}