"); } else{ $("#"+clockId).html(ends_message); } clearInterval(inte); } } } function add_discount__v202(data, callback){ var $jscomp$destructuring$var0 = data, dg = $jscomp$destructuring$var0.dg, discount_on_specific_products = $jscomp$destructuring$var0.discount_on_specific_products, discount_on_specific_collections = $jscomp$destructuring$var0.discount_on_specific_collections, discount_on_entire_store = $jscomp$destructuring$var0.discount_on_entire_store, discount_on_specific_variants = $jscomp$destructuring$var0.discount_on_specific_variants, render_for = $jscomp$destructuring$var0.render_for, status = "rejected"; switch(dg.applies_to){ case "specific_variants": if(WholesaleAIO.template === "product"){ if(dg.variants.findIndex(function(x){ return x.id == selected_variant_id }) > -1){ status = "approved"; } } break; case "specific_products": if(WholesaleAIO.template === "product"){ if(dg.products.findIndex(function(x){ return x.id == current_product.id }) > -1){ status = "approved"; } } else{ status = "approved"; } break; case 'specific_collections': if(render_for === "hcsrp"){ status = "approved"; } else{ if(WholesaleAIO.template === "index"){ if(typeof homePageCollection === 'object' && homePageCollection.id){ if(dg.collections.findIndex(function(x){return x.id == homePageCollection.id}) > -1){ status = "approved"; } } else{ log("WAIO message: Home page collection's is not found!","warning"); } } else if(WholesaleAIO.template === "product"){ if(current_product_in_collections.length > 0){ for(var iter = 0; iter -1){ status = "approved"; break; } else if(dg.collections.findIndex(function(x){return x.id == col.collection_id}) > -1){ status = "approved"; break; } } } else{ log("WAIO LOG!", "Current product's collections not found!","warning") } } else{ if(collection_id){ if(dg.collections.findIndex(function(x){return x.id == collection_id }) > -1){ status = "approved"; } } else if(collection_handle == "all"){ if(discount_on_specific_collections.length == 0){ status = "approved"; } log("WAIO message: All collections rendered!") } else{ if(discount_on_specific_collections.length == 0){ status = "approved"; } log("WAIO message: Current collection's id not found!") } } } break; case 'entire_store': if(WholesaleAIO.template === "product"){ if(discount_on_specific_collections.length == 0 && discount_on_specific_products.length == 0 && discount_on_specific_variants.length == 0){ status = "approved"; } } else{ if(discount_on_specific_collections.length === 0){ status = "approved"; } } break; default: break; } callback({type:dg.applies_to,status:status}) } function get_relivant_rule_v202(data, callback){ var $jscomp$destructuring$var0 = data, variant_id = $jscomp$destructuring$var0.variant_id, product_id = $jscomp$destructuring$var0.product_id, variants_array = $jscomp$destructuring$var0.variants_array, products_array = $jscomp$destructuring$var0.products_array, collections_array = $jscomp$destructuring$var0.collections_array, entireStore_array = $jscomp$destructuring$var0.entireStore_array, collectionsIds = $jscomp$destructuring$var0.collectionsIds; var final_result = []; for(var iter = 0; iter -1){ if(typeof final_result.customers_group !== "undefined"){ switch(va.customers_group){ case "tagged_customer": if(final_result.customers_group != "tagged_customer"){ final_result = va; } break; case "only_logged_in_customers": if(final_result.customers_group != "tagged_customer"){ final_result = va; } break; case "all": if(final_result.customers_group != "tagged_customer" && final_result.customers_group != "only_logged_in_customers"){ final_result = va; } break; default: break; } } else{ final_result = va; } } }// end for loop for(var iter = 0; iter -1){ if(typeof final_result.customers_group !== "undefined"){ if(final_result.applies_to === "specific_variants") break; switch(pa.customers_group){ case "tagged_customer": if(final_result.customers_group != "tagged_customer"){ final_result = pa; } break; case "only_logged_in_customers": if(final_result.customers_group != "tagged_customer"){ final_result = pa; } break; case "all": if(final_result.customers_group != "tagged_customer" && final_result.customers_group != "only_logged_in_customers"){ final_result = pa; } break; default: break; } } else{ final_result = pa; } } } for(var iter = 0; iter -1){continue;} if(WholesaleAIO.template == "collection" || WholesaleAIO.template == "search" || WholesaleAIO.template == "index"){ var find = productInCollects.findIndex(function(x){ return x.product_id == product_id }); if(find > -1){ for(var iter1 = 0; iter1 -1){ if(typeof final_result.customers_group !== "undefined"){ if(final_result.applies_to === "specific_products" || final_result.applies_to === "specific_variants") break; switch(ca.customers_group){ case "tagged_customer": if(final_result.customers_group != "tagged_customer"){ final_result = ca; } break; case "only_logged_in_customers": if(final_result.customers_group != "tagged_customer"){ final_result = ca; } break; default: break; } } else{ final_result = ca; } break; } } // end for loop } else if(collectionsIds){ collectionsIds = collectionsIds.toString().split(","); for(var itery = 0; itery -1){ if(typeof final_result.customers_group !== "undefined"){ if(final_result.applies_to === "specific_products" || final_result.applies_to === "specific_variants") break; switch(ca.customers_group){ case "tagged_customer": if(final_result.customers_group != "tagged_customer"){ final_result = ca; } break; case "only_logged_in_customers": if(final_result.customers_group != "tagged_customer"){ final_result = ca; } break; default: break; } } else{ final_result = ca; } } } } else{ } } else if(WholesaleAIO.template == "product"){ for(var iter = 0; iter -1; var findTwo = ca.collections.findIndex(function(x){return x.id == col.collection_id}) > -1; if(findOne || findTwo){ if(typeof final_result.customers_group !== "undefined"){ if(final_result.applies_to === "specific_products" || final_result.applies_to === "specific_variants") break; switch(ca.customers_group){ case "tagged_customer": if(final_result.customers_group != "tagged_customer"){ final_result = ca; } break; case "only_logged_in_customers": if(final_result.customers_group != "tagged_customer"){ final_result = ca; } break; default: break; } } else{ final_result = ca; } break; } } // end for loop } else{ if(ca.collections.findIndex(function(x){return x.id == homePageCollection.id}) > -1){ if(typeof final_result.customers_group !== "undefined"){ if(final_result.applies_to === "specific_products" || final_result.applies_to === "specific_variants") break; switch(ca.customers_group){ case "tagged_customer": if(final_result.customers_group != "tagged_customer"){ final_result = ca; } break; case "only_logged_in_customers": if(final_result.customers_group != "tagged_customer"){ final_result = ca; } break; default: break; } } else{ final_result = ca; } break; } } } for(var iter = 0; iter -1){continue;} var find = productInCollects.findIndex(function(x){ return x.product_id == product_id }); var excluded = false; if(find > -1){ for(var iter1 = 0; iter1 -1){ excluded = true; } } } if(collectionsIds){ collectionsIds = collectionsIds.toString().split(","); for(var iter2 = 0; iter2 -1){ excluded = true; } } } if(excluded){break;} if(typeof final_result.customers_group === "undefined"){ final_result = esa; } } var status = typeof final_result.customers_group !== "undefined"?1:0; callback({status:status,final_result:final_result}); } function cart_subtotal__price(discount){ return mF(Number(discount.cart_subtotal)) - Number(discount.total_discount); } function product_total__price(product){ return mF(Number(product.line_price)); } function product_discounted__price(product){ return decimal(mF(Number(product.line_price)) - product.total_discount); } function updatePriceHTML(params){ var $jscomp$destructuring$var0 = params, template = $jscomp$destructuring$var0.template, discountType = $jscomp$destructuring$var0.discountType, discountValue = $jscomp$destructuring$var0.discountValue, productPrice = $jscomp$destructuring$var0.productPrice, compareAtPrice = $jscomp$destructuring$var0.compareAtPrice, productId = $jscomp$destructuring$var0.productId, priceElement = $jscomp$destructuring$var0.priceElement, html_contents = $jscomp$destructuring$var0.html_contents, pIdAttrSelector = $jscomp$destructuring$var0.pIdAttrSelector; var discount = 0; var wholesalePrice = productPrice; var productPriceCurrencyFormat=currency_format,wholesalePriceCurrencyFormat=currency_format,savedPriceCurrencyFormat=currency_format; switch(discountType){ case "percentage": discount = WholesaleAIO.priceFloat(( Number(mF(Number(productPrice)) * Number(mF(Number(discountValue))))/100).toString()); wholesalePrice = (Number(productPrice)) - WholesaleAIO.priceFormat(Number(discount)); log("Discount ",discount); log("Wholesale Price ",wholesalePrice); log("Product Price ",productPrice); break; case "fixed_price": if(Number(productPrice) > Number(discountValue)){ wholesalePrice = discountValue; } else{ wholesalePrice = productPrice; } break; case "price_discount": if(Number(productPrice) = Number(productPrice)){ var hideMe = '[[strikethrough_price]]'; html_contents = html_contents.replaceMeW('[[strikethrough_price]]',hideMe); } var _discounted_price = WholesaleAIO.formatMoney(wholesalePrice, wholesalePriceCurrencyFormat); var _strikethrough_price = WholesaleAIO.formatMoney(productPrice, wholesalePriceCurrencyFormat); saved_fixed_amount = WholesaleAIO.formatMoney(WholesaleAIO.priceFormat(saved_fixed_amount), savedPriceCurrencyFormat); //alert(saved_fixed_amount) !saved_in_percent&&(saved_in_percent=""); !saved_fixed_amount&&(saved_fixed_amount=""); var html = html_contents.replaceMeW('[[wholesale_price]]',_discounted_price) .replaceMeW('[[strikethrough_price]]',_strikethrough_price) .replaceMeW('[[saved_in_percent]]',saved_in_percent) .replaceMeW('[[saved_fixed_amount]]',saved_fixed_amount); if(template === "product"){ $(priceElement).html(html); $(priceElement).addClass("WAIO--"+mF(discountValue)+"-"+discountType+"-applied"); } else{ $("["+pIdAttrSelector+"='"+productId+"']").html(html); $("["+pIdAttrSelector+"='"+productId+"']").addClass("WAIO--"+mF(discountValue)+"-"+discountType+"-applied"); } } function productOriginalPriceHTML(config){ var $jscomp$destructuring$var0 = config, original_price = $jscomp$destructuring$var0.original_price, compare_at_price = $jscomp$destructuring$var0.compare_at_price, product_id = $jscomp$destructuring$var0.product_id, variant_id = $jscomp$destructuring$var0.variant_id, element = $jscomp$destructuring$var0.element, html_contents = $jscomp$destructuring$var0.html_contents, show_compare_at_price = $jscomp$destructuring$var0.show_compare_at_price; var disVal = Number(compare_at_price) - Number(original_price); var savedAmount=WholesaleAIO.savedAmount(mF(original_price),mF(disVal),"price_discount"),saved_in_percent="",saved_fixed_amount=""; savedAmount&&!savedAmount.error?(saved_in_percent=savedAmount.in_percent,saved_fixed_amount=savedAmount.fixed_amount):log("WAIO Warning","Saved amount not working as expected. Debug code to find out the bug or error.","warning"); if(Number(original_price) >= Number(compare_at_price)){ var hideMe = '[[strikethrough_price]]'; html_contents = html_contents.replaceMeW('[[strikethrough_price]]',hideMe); } else if(!WholesaleAIO.settings.compare_at_price){ var hideMe = '[[strikethrough_price]]'; html_contents = html_contents.replaceMeW('[[strikethrough_price]]',hideMe); } !saved_in_percent&&(saved_in_percent=""); !saved_fixed_amount&&(saved_fixed_amount=""); var normalPrice = WholesaleAIO.formatMoney(mF(original_price), currency_format); //console.warn(currency_format,'thgggggggggggggggggggggggggggggggg1122') // console.warn(normalPrice,'thgggggggggggggggggggggggggggggggg') var compareAtPrice = WholesaleAIO.formatMoney(mF(compare_at_price), currency_format); var html = html_contents.replaceMeW('[[wholesale_price]]',normalPrice) .replaceMeW('[[strikethrough_price]]',compareAtPrice) .replaceMeW('[[saved_in_percent]]',saved_in_percent) .replaceMeW('[[saved_fixed_amount]]',saved_fixed_amount); return html; } function calc_discount(item,product_price){ var value_range = []; item.volume_discount.forEach( function(v){ value_range.push(v.value); }); var min = Math.min.apply(null, value_range); var max = Math.max.apply(null, value_range); if(item.qb_calculation_type === "fixed_price"){ return waioTranslations.from + WholesaleAIO.formatMoney(decimal(min), currency_format); } else if(item.qb_calculation_type === "price_discount"){ if(product_price){ product_price = product_price - (max*100); return waioTranslations.from + WholesaleAIO.formatMoney(product_price, currency_format); } else{ return waioTranslations.from + WholesaleAIO.formatMoney(decimal(min), currency_format); } } else if(item.qb_calculation_type === "percent_discount"){ if(product_price){ product_price = product_price - ( ( product_price * max ) / 100); return waioTranslations.from + WholesaleAIO.formatMoney(product_price, currency_format); } else{ return "Upto "+max+"% "+ waioTranslations.off; } } } // quantity breaks grid tables // calculate prices function calc_price(product,vd,data){ var discount = 0; var product_price = 0; if(data.price){ product_price = data.price; } var variant_id = data.variant_id || selected_variant_id; var z = current_product.variants.findIndex(function(x){return x.id == variant_id }); if(z>-1 && !product_price){ if(current_product.variants[z].price){ product_price = current_product.variants[z].price; } } if(!product_price){ product_price = current_product.price; } if(data.quick_view){ if(data.quick_view.price){ product_price = data.quick_view.price; } } product_price = mF(Number(product_price)); if(!product_price){ log("waio price warning:","Updated price not found in qb", "warning"); } if(product.qb_calculation_type === "fixed_price"){ if(product_price <= vd.value){ discount = 0; } else{ discount = product_price - vd.value; } } else if(product.qb_calculation_type === "price_discount"){ if(product_price -1 && !product_price){ if(current_product.variants[z].price){ product_price = current_product.variants[z].price; } } if(!product_price){ product_price = current_product.price; } if(data.quick_view){ if(data.quick_view.price){ product_price = data.quick_view.price; } } product_price = mF(Number(product_price)); if(!product_price){ log("waio price warning:","Updated price not found in qb", "warning"); } if(product.qb_calculation_type === "fixed_price"){ if(product_price <= vd.value){ discount = 0; } else{ discount = product_price - vd.value; } } else if(product.qb_calculation_type === "price_discount"){ if(product_price -1){ whereTo = element.split(":")[1]; var newEl = element.split(":")[0]; switch(whereTo){ case "append": $(newEl).append(table); break; case "prepend": $(newEl).prepend(table); break; case "before": $(table).insertBefore(newEl); break; case "after": $(table).insertAfter(newEl); break; default: $(newEl).html(table); break; } } else{ $(element).html(table); } } function findLocationAndAddHTML(element, html){ var whereTo = null; if(element.indexOf(":") > -1){ whereTo = element.split(":")[1]; var newEl = element.split(":")[0]; switch(whereTo){ case "append": $(newEl).append(html); break; case "prepend": $(newEl).prepend(html); break; case "before": $(html).insertBefore(newEl); break; case "after": $(html).insertAfter(newEl); break; default: $(newEl).html(html); break; } } else{ $(element).html(html); } } // tables grid function basic_grid(product,data, table_Id){ if(product.volume_discount.length > 0){ var table_data = ""; var currency_symbol = ""; var percent_symbol = ""; product.volume_discount.sort(compareAndSortVD); product.volume_discount.forEach( function(vd,i){ var next_qty = waioTranslations.range_so_on; if(product.volume_discount[i+1]){ next_qty = Number(product.volume_discount[i+1].qty) - 1; } if(product.qb_calculation_type === "percent_discount"){ percent_symbol = waioTranslations.percent_symbol; } else{ currency_symbol = waioTranslations.currency_symbol; } table_data += '