// 6 - april - 2021 // function start(){ if(!window.is_hulk_load_js && !window.hulkapps_v2_beta_js) { window.is_hulk_load_js = true var checkout_selectors = "input[name='checkout']:not(.hulkapps-ignore), input[value='Checkout']:not(.hulkapps-ignore), button[name='checkout']:not(.hulkapps-ignore), [href$='checkout']:not(.hulkapps-ignore), button[value='Checkout']:not(.hulkapps-ignore), input[name='goto_pp'], button[name='goto_pp'], input[name='goto_gc'], button[name='goto_gc'],.hulkapps_checkout" window.hulkLoadScript = function (url, callback) { var script = document.createElement("script"); script.type = "text/javascript"; // If the browser is Internet Explorer if (script.readyState) { script.onreadystatechange = function () { if (script.readyState == "loaded" || script.readyState == "complete") { script.onreadystatechange = null; callback(); } }; // For any other browser } else { script.onload = function () { callback(); }; } script.src = url; document.getElementsByTagName("head")[0].appendChild(script); }; window.checkAppInstalled = function (version) { window.hulkapps.is_product_option = true hulkLoadScript('https://cdnjs.cloudflare.com/ajax/libs/intl-tel-input/17.0.13/js/intlTelInput.min.js', function () { commonJS(version); cartPageJS(version); productPageJS(version); }); }; window.commonJS = function ($) { window.hulkDraftOrder = function () { return window.is_draft_order } window.hulkappsDoActions = function (data) { if (data.discounts.discount_show) { $(".discount_code_box").css("display", "block"); } if (data.discounts.plan) { $(".edit_cart_option").css("display", "block"); } if (typeof data.discounts == "object" && typeof data.discounts.cart == "object" && typeof data.discounts.cart.items == "object") { hulkappsShowCartDiscounts(data.discounts) } if (data.discounts.is_draft_order) { $(document).on('click', checkout_selectors, function (e) { e.preventDefault(); if (typeof hulkappsCheckout != "function") { window.location = "/checkout"; } // Order Delivery Date App Code for validation issue. hulkappsCheckoutClick() function is at frontend side in theme if (typeof hulkappsCheckoutClick === 'undefined') { hulkappsCheckout(null); } else { var result = hulkappsCheckoutClick(); if (result.required == true) { hulkappsCheckout(result); } else if (result.required != false) { hulkappsCheckout(result); } } }); } } window.hulkappsShowCartDiscounts = function (discounts) { window.hulkapps.discounts = discounts; discounts.cart.items.forEach(function (item) { $(".hulkapps-cart-item-price[data-key='" + item.key + "']").html("" + item.original_price_format + ""); $(".hulkapps-cart-item-line-price[data-key='" + item.key + "']").html("" + item.original_line_price_format + "") }); var discounted_price = parseFloat(discounts.discount_cut_price); if (discounts.discount_code && discounts.discount_error == 1) { $(".hulkapps-cart-original-total").html(discounts.original_price_total); hulkapps_jQuery(".hulkapps_summary").remove(); $(".hulkapps_discount_hide").after("Discount code does not match"); localStorage.removeItem('discount_code'); } else if (discounts.is_free_shipping) { hulkapps_jQuery(".hulkapps_summary").remove(); hulkapps_jQuery(".hulkapps_discount_hide").after("" + discounts.discount_code + "Free Shipping"); } else if (discounts.discount_code && discounted_price <= 0 && $('.discount_code_box').is(":visible")) { hulkapps_jQuery(".hulkapps-cart-original-total").html(discounts.original_price_total); hulkapps_jQuery(".hulkapps_discount_hide").after("" + discounts.discount_code + " discount code isn’t valid for the items in your cart"); hulkapps_jQuery(".hulkapps_discount_code").val("") localStorage.removeItem('discount_code'); } else if (discounts.discount_code && $('.discount_code_box').is(":visible")) { hulkapps_jQuery(".hulkapps-summary-line-discount-code,.after_discount_price").remove(); hulkapps_jQuery(".hulkapps_discount_hide").after("" + discounts.discount_code + "" + " -" + discounts.with_discount + "Total" + discounts.final_with_discounted_price + ""); hulkapps_jQuery(".hulkapps-cart-original-total").html(discounts.original_price_total) if (discounts.original_price_total != discounts.final_with_discounted_price) { $(".hulkapps-cart-original-total").css("text-decoration", "line-through"); } $(".hulkapps-cart-total").remove(); } else { $(".hulkapps-cart-original-total").html(discounts.original_price_total); } } window.hulkappsCheckout = function (result) { var order_app = {} if (result != null) { if (result.shipping_status == 1) { order_app = {"price": result.shipping_price, "title": result.shipping_method} } } var storage_code = localStorage.getItem('discount_code'); $.getJSON('/cart.js', {_: new Date().getTime()}, function (cart) { window.hulkapps.cart = cart; $.ajax({ type: "POST", url: window.hulkapps.po_url + "/store/create_draft_order", data: { cart_json: window.hulkapps, store_id: window.hulkapps.store_id, discount_code: storage_code, cart_collections: JSON.stringify(window.hulkapps.cart_collections), order_app: order_app, customer_tags: window.hulkapps.customer != null ? window.hulkapps.customer.tags.split(",") : '' }, crossDomain: true, success: function (res) { if (typeof res == "string") { window.location.href = res } else { window.location.href = "/checkout" } localStorage.removeItem('discount_code'); } }); }); } window.hulkappsStart = function ($) { window.hulkappsc = {}; window.hulkappsc.$first_add_to_cart_el = null; var selectors = ["input[name='add']", "button[name='add']", "#add-to-cart", "#AddToCartText", "#AddToCart"]; var found_selectors = 0; selectors.forEach(function (selector) { found_selectors += $(selector).length; if (window.hulkappsc.$first_add_to_cart_el == null && found_selectors) { window.hulkappsc.$first_add_to_cart_el = $(selector).first() } }); if (window.hulkapps.page_type == "product" && window.hulkappsc.$first_add_to_cart_el != null) { // if (window.hulkapps.page_type == "product") { var vol_el_after = window.hulkappsc.$first_add_to_cart_el; if (vol_el_after.parent().is("div")) { vol_el_after = vol_el_after.parent() } if ($('#hulkapps_custom_options_' + window.hulkapps.product_id).length == 0) { vol_el_after.before('
'); // $("#hulkapps_custom_options").append('
'); } } if (window.hulkapps.page_type == "product") { $.ajax({ type: "GET", url: window.hulkapps.po_url + "/api/v2/store/get_all_relationships", data: {pid: window.hulkapps.product_id, store_id: window.hulkapps.store_id,tags: window.hulkapps.product.tags,vendor: window.hulkapps.product.vendor,ptype: window.hulkapps.product.type,customer_tags: window.hulkapps.customer != null ? window.hulkapps.customer.tags.split(",") : ''}, sync: false, crossDomain: true, success: function (data) { if ($.type(data) != 'string') { // setTimeout(function(){ var conditional_html = '' let a = {}; if (data['condition'] != undefined) { conditional_html += "" } var title_text = data['options_title']['title_text'].length != 0 ? data['options_title']['title_text'] : 'Choose Your Product Options:'; var ho_title = ".hulkapps_option_title{" ho_title = ho_title + ((data['options_title']['title_padding'].length != 0) ? "padding: " + data['options_title']['title_padding'] + "px;" : 'padding: 15px;') ho_title = ho_title + ((data['options_title']['title_font_size'].length != 0) ? "font-size: " + data['options_title']['title_font_size'] + "px;" : 'font-size: 16px;') ho_title = ho_title + ((data['options_title']['title_text_align'].length != 0) ? "text-align: " + data['options_title']['title_text_align'] + ";" : 'text-align: left;') ho_title = ho_title + ((data['options_title']['title_background'].length != 0) ? "background-color: " + data['options_title']['title_background'] + ";" : 'background-color: #ffffff;') ho_title = ho_title + ((data['options_title']['title_border'].length != 0) ? "border: 1px solid " + data['options_title']['title_border'] + ";" : 'border: 1px solid #000000;') ho_title = ho_title + ((data['options_title']['title_font_color'].length != 0) ? "color: " + data['options_title']['title_font_color'] + ";" : 'color:#000000;') ho_title = ho_title + ((parseInt(data['options_title']['title_bold']) == 1) ? "font-weight:bold;" : 'font-weight:normal;') ho_title = ho_title + ((parseInt(data['options_title']['title_display']) == 1) ? "" : 'display:none;') ho_title = ho_title + "border-bottom: none;" ho_title = ho_title + "}" var enable_tooltip = data['options_container_style']['enable_tooltip'] var enable_helptext = data['options_container_style']['enable_helptext'] var oc_style = "#hulkapps_option_list_" + data['pid'] + "{" oc_style = oc_style + ((data['options_container_style']['background_color'].length != 0) ? "background-color: " + data['options_container_style']['background_color'] + ";" : 'background-color: #fff;') oc_style = oc_style + ((data['options_container_style']['border_color'].length != 0) ? "border: 1px solid " + data['options_container_style']['border_color'] + ";" : 'border: 0 none;') oc_style = oc_style + ((data['options_container_style']['padding'].length != 0) ? "padding: " + data['options_container_style']['padding'] + "px;" : 'padding: 10px;') oc_style = oc_style + "}.hulkapps_option {width: 100%;display: block;" oc_style = oc_style + ((data['options_container_style']['spacing_between_options'].length != 0) ? "padding-bottom: #{@spacing_between_options}px;margin-bottom: " + data['options_container_style']['spacing_between_options'] + "px;" : 'padding-bottom: 6px;margin-bottom: 6px;') oc_style = oc_style + ((data['options_container_style']['line_between_options'].length != 0) ? "border-bottom: 1px solid " + data['options_container_style']['line_between_options'] + ";" : '') oc_style = oc_style + "}" var option_name_inline = data['options_name_style']['option_name_inline'] var on_style = ".hulkapps_option_name {" on_style = on_style + ((data['options_name_style']['option_name_width'].length != 0) ? "width: " + data['options_name_style']['option_name_width'] + "px;" : 'width: 180px;') on_style = on_style + ((data['options_name_style']['option_name_font_size'].length != 0) ? "font-size: " + data['options_name_style']['option_name_font_size'] + "px;" : 'font-size: 14px;') on_style = on_style + ((data['options_name_style']['option_name_text_align'].length != 0) ? "text-align: " + data['options_name_style']['option_name_text_align'] + ";" : 'text-align: left;') on_style = on_style + ((data['options_name_style']['font_color'].length != 0) ? "color: " + data['options_name_style']['font_color'] + ";" : 'color: #424242;') on_style = on_style + ((parseInt(data['options_name_style']['on_title_bold']) == 1) ? "font-weight: bold;" : 'font-weight: normal;') on_style = on_style + "display: table-cell;min-width: " + data['options_name_style']['option_name_width'] + "px;padding-right: 15px;box-sizing: border-box;-webkit-box-sizing: border-box;-moz-box-sizing: border-box;-ms-box-sizing: border-box;vertical-align: top;}" var ov_padding = data['option_values_style']['ov_padding'] var ov_width = data['option_values_style']['ov_width'] var spacing_left_of_values = data['option_values_style']['spacing_left_of_values'] var single_line = data['option_values_style']['single_line'] var ov_style = ".hulkapps_option_value {" ov_style = ov_style + "width:100%;min-width: 100%;text-align: left;display: table-cell;vertical-align: top;}" ov_style = ov_style + ".hulkapps_option .hulkapps_option_value, .pn_render .hulkapps_option_child, .et_render .hulkapps_option_child, .tb_render .hulkapps_option_child, .ta_render .hulkapps_option_child, .fu_render .hulkapps_option_child, .dd_render .hulkapps_option_child, .dd_multi_render .hulkapps_option_child, .nf_render .hulkapps_option_child, .dp_render .hulkapps_option_child{" ov_style = ov_style + ((data['option_values_style']['ov_font_size'].length != 0) ? "font-size: " + data['option_values_style']['ov_font_size'] + "px !important;" : '') ov_style = ov_style + ((data['option_values_style']['ov_font_color'].length != 0) ? "color: " + data['option_values_style']['ov_font_color'] + " !important;" : '') ov_style = ov_style + ((data['option_values_style']['ov_font_weight'] != undefined) ? "font-weight:bold;" : 'font-weight:normal;') ov_style = ov_style + "}" var custom_js = data['advanced_users']['custom_js'] var custom_css = data['advanced_users']['custom_css'] var swatch_width = parseInt(data['swatch_settings']['swatch_width']) var swatch_height = parseInt(data['swatch_settings']['swatch_height']) var tooltip_position = data['swatch_settings']['tooltip_position'] var tooltip_contains = data['swatch_settings']['tooltip_contains'] var tooltip_display = parseInt(data['swatch_settings']['tooltip_display']) var round_corners = parseInt(data['swatch_settings']['round_corners']) var enable_swatch_images = parseInt(data['swatch_settings']['enable_swatch_images']) var enable_swatch_with_text = parseInt(data['swatch_settings']['enable_swatch_with_text']) var swatch_width = (swatch_width == '' || swatch_width < 0) ? "width:35px;" : "width:" + swatch_width + "px;" var swatch_height = (swatch_height == '' || swatch_height < 0) ? "height:35px;" : "height:" + swatch_height + "px;" var tooltip_position = (tooltip_position == 'top') ? 'top' : 'bottom' var round_corners = (round_corners == 1) ? '-webkit-border-radius: 50%;-moz-border-radius: 50%;border-radius: 50%;' : '' var button_option_background = ((data['button_option_settings']['button_option_background'].length != 0) ? 'background-color: ' + data['button_option_settings']['button_option_background'] + ';' : '') var button_option_font_color = ((data['button_option_settings']['button_option_font_color'].length != 0) ? 'color: ' + data['button_option_settings']['button_option_font_color'] + ';' : '') var button_option_border_color = ((data['button_option_settings']['button_option_border_color'].length != 0) ? 'border-color: ' + data['button_option_settings']['button_option_border_color'] + ';' : '') var update_total_text = data['premium_option_settings']['update_total_text'] var amount_note_display = (data['premium_option_settings']['amount_note_display'] == undefined) ? 1 : data['premium_option_settings']['amount_note_display'] var post_total_text = data['premium_option_settings']['post_total_text'] var total_container_background_color = data['premium_option_settings']['total_container_background_color'] var total_container_border_color = data['premium_option_settings']['total_container_border_color'] var total_container_font_color = data['premium_option_settings']['total_container_font_color'] var total_container_price_color = data['premium_option_settings']['total_container_price_color'] var po_settings = "#option_total {" po_settings = po_settings + (total_container_background_color !== '' ? "background: none repeat scroll 0 0 " + total_container_background_color + ";" : "background: none repeat scroll 0 0 #fff;") po_settings = po_settings + (total_container_border_color !== '' ? "border:1px solid " + total_container_border_color + ";" : 'border:1px solid #000000;') po_settings = po_settings + (total_container_font_color !== '' ? "color: " + total_container_font_color + ";" : "color: #000;") po_settings = po_settings + "}#formatted_option_total {" po_settings = po_settings + (total_container_price_color !== '' ? "color: " + total_container_price_color + ";" : "color: #000;") po_settings = po_settings + "}" var single_inline_css = parseInt(single_line) == 0 ? '0px' : '10px' var other_css = "#hulkapps_custom_options_" + data['pid'] + "{clear: both}#hulkapps_options_" + data['pid'] + "{margin:15px 0;}#hulkapps_option_list_" + data['pid'] + " select{width:100%;padding-top: 12px;padding-bottom: 12px}.popup_detail{position: fixed;background-color: #F7F7F7;padding: 15px;top: 50%;left: 50%;transform: translate(-50%, -50%);justify-content: space-between;z-index: 3;min-width: 300px;max-width: fit-content;overflow-y: auto;max-height: 500px;}.popup_detail a{cursor: pointer;}.popup_detail img{width: 15px;height: 15px;margin: 5px;}.popup_detail p{margin:0;}.overlay-popup{position: fixed;display: none;width: 100%;height: 100%;top: 0;left: 0;bottom: 0;background-color: rgba(0,0,0,0.5);z-index: 2;}.popup_render{margin-bottom:0!important;display:flex;align-items:center!important}.popup_render .hulkapps_option_value{min-width:auto!important}.popup_render a{text-decoration:underline!important;transition:all .3s!important;font-weight: normal !important;}.popup_render a:hover{color:#6e6e6e}.cut-popup-icon{display:flex;align-items:center}.cut-popup-icon-span{display:flex}.des-detail{font-weight: normal;}#hulkapps_option_list_" + data['pid'] + " input[type='text']{width:100%;border-radius:0}#hulkapps_option_list_" + data['pid'] + " input,#hulkapps_option_list_" + data['pid'] + " textarea,#hulkapps_option_list_" + data['pid'] + " select{border:1px solid #ddd;box-shadow: none;-webkit-appearance: none;padding: 6px 10px;min-height: 36px;}#hulkapps_option_list_" + data['pid'] + " .validation_error{color:#FF0808;background-color:#FFF8F7;border-style:solid;border-width:1px;border-color:#FFCBC9;border-bottom: 1px solid #ffcbc9 !important;padding: 2px 6px;display: inline-block;margin-top: 2px;}#hulkapps_option_list_" + data['pid'] + " .validation_error .hulkapps_option_value{color:#FF0808}#hulkapps_option_list_" + data['pid'] + " .validation_error .hulkapps_option_name{color:#FF0808}.hulkapps_option_value:first-child{display:flex;align-items: center;} .hulkapps_option_value:first-child span{display: flex;padding-right: 10px;}.hulkapps_option_value:first-child a{cursor: pointer;} .hulkapps_helptext{color: #000 !important;}.conditional{display:none !important}.hulkapps_full_width{width:100%;font-size:16px !important;padding:5px;display:block;}.hulkapps_check_option,.hulkapps_radio_option{display:block;margin-right:0;font-weight:normal !important;}.single_line .hulkapps_option_value .hulkapps_check_option,.single_line .hulkapps_option_value .hulkapps_radio_option{display:inline-flex !important;margin-right:20px;font-weight:normal; align-items: center; }#hulkapps_option_list_" + data['pid'] + " input[type='checkbox']{margin-right: 5px;vertical-align: baseline;min-height:auto; height: auto;display: inline-block !important;-webkit-appearance: checkbox;-moz-appearance: checkbox;appearance: checkbox;}.hulkapps_check_option input[type='checkbox']{margin-right:5px;}#hulkapps_option_list_" + data['pid'] + " input[type='radio']{margin-right:5px;vertical-align:baseline;display: none;}i.hulkapps_tooltip_identifier{color:rgb(255, 255, 255);border-radius:12px;font-size:10px;margin-right:6px;margin-left:4px;padding:0px 4px;background:#000000}span.hulkapps_option_name_additional_info{position:relative}span.hulkapps_option_name_additional_info .hulkapps_tool_tip{display:none}span.hulkapps_option_name_additional_info:hover .hulkapps_tool_tip{content:attr(data-additional-info);padding:4px 8px;color:#fff;position:absolute;left:0;bottom:160%;z-index:20px;-moz-border-radius:5px;-webkit-border-radius:5px;border-radius:5px;display:block;background:#000000;width:150px}span.hulkapps_option_name_additional_info:hover:after{display:block}i.hulkapps_tooltip_identifier:before{content:'?';font-style:normal}#formatted_option_total{font-weight:bold;margin:0 7px}.td_render .hulkapps_option_name.full_name{float:none;width:auto}.hulkapps_option.full_width .hulkapps_option_name,.hulkapps_option.full_width .hulkapps_option_value{width:100%;display:block;}.hulkapps_option.full_width .hulkapps_option_name{padding-bottom:5px}.hulkapps_option:after{content:'';clear:both;display:block}.hulkapps_option_name a:link {color: grey;text-decoration: none;font-weight: normal;}.hulkapps_option_name a:hover {color: rgb(93, 156, 236);background: transparent;}.hulkapps_swatch_option .hulkapps_option_child{border: 2px solid #ccc;cursor: pointer;}.hulkapps_mswatch_option .hulkapps_option_child{border: 2px solid #ccc;cursor: pointer;}.hulkapps_swatch_option .swatch_selected,.button_selected{border: 2px solid #00a9a2;}.hulkapps_radio_option .radio_selected{border: 2px solid #0090FA;background:#0090FA;color:#fff;}.radio_div{border: 2px solid #eee;padding: 8px 20px;padding: 6px 12px;}.radio_div:hover{border: 2px solid #0090FA;cursor:pointer;}.tooltip.in{opacity:1 !important;}#option_display_total_format{padding-left:5px;}.hulkapps_swatch_option .tooltip-inner{padding: 0px 5px !important;}.hulkapps_check_option,.hulkapps_radio_option{margin-right:" + single_inline_css + "}.hulkapps_swatch_option,.hulkapps_mswatch_option{ margin-right:10px !important; display: inline-block !important;vertical-align: middle;}.hulkapps-tooltip.tooltip-left-pos .hulkapps-tooltip-inner.swatch-tooltip{left: 0 !important;right: auto !important;}.hulkapps-tooltip.tooltip-left-pos .hulkapps-tooltip-inner.swatch-tooltip:after{right: auto !important;left: 10px !important;}.hulkapps-tooltip.tooltip-right-pos .hulkapps-tooltip-inner.swatch-tooltip{right: 0 !important;left: auto !important;}.hulkapps-tooltip.tooltip-right-pos .hulkapps-tooltip-inner.swatch-tooltip:after{left: auto !important;right: 10px !important;}.hulkapps-tooltip.tooltip-center-pos .hulkapps-tooltip-inner.swatch-tooltip{left: 50% !important;transform: translateX(-50%);}.hulkapps-tooltip.tooltip-center-pos .hulkapps-tooltip-inner.swatch-tooltip:after{left: 50% !important;transform: translateX(-50%);}.phone_number{padding: 6px 10px 6px 50px !important;}#option_total{padding:3px 6px;}.hulkapps_mswatch_option .swatch_selected{border: 2px solid #00a9a2;}.hulkapps-tooltip.tooltip-left-pos .hulkapps-tooltip-inner.multiswatch-tooltip{left: 0 !important;right: auto !important;}.hulkapps-tooltip.tooltip-left-pos .hulkapps-tooltip-inner.multiswatch-tooltip:after{right: auto !important;left: 10px !important;}.hulkapps-tooltip.tooltip-right-pos .hulkapps-tooltip-inner.multiswatch-tooltip{right: 0 !important;left: auto !important;}.hulkapps-tooltip.tooltip-right-pos .hulkapps-tooltip-inner.multiswatch-tooltip:after{left: auto !important;right: 10px !important;}.hulkapps-tooltip.tooltip-center-pos .hulkapps-tooltip-inner.multiswatch-tooltip{left: 50% !important;transform: translateX(-50%);}.hulkapps-tooltip.tooltip-center-pos .hulkapps-tooltip-inner.multiswatch-tooltip:after{left: 50% !important;transform: translateX(-50%);}.hulkapps_swatch_option, .hulkapps_mswatch_option{margin-bottom: 10px !important;}.hulkapps_buton_option .hulkapps_option_child{ width: auto;min-height: 36px;padding: 6px 12px;border: 2px solid;border-radius: 0;font-weight: 500;display: flex;justify-content: center;align-items: center;margin: 2px;}.button_selected {color: #00A9A2 !important;background-color: #fff !important;border-color: #00A9A2 !important;font-weight: 700 !important;}" var all_css = ho_title + oc_style + on_style + ov_style + po_settings + other_css + custom_css var custom_js = "" var addtocart_html = "
" var hidden_fields = '' addtocart_html = addtocart_html + hidden_fields + conditional_html + "" + custom_js addtocart_html = addtocart_html + "
" + title_text + "
" addtocart_html = addtocart_html + "
" if (amount_note_display !== '' || parseInt(amount_note_display) == 1) { addtocart_html = addtocart_html + "" } else { addtocart_html = addtocart_html + "" } var relation = data['relationship'] var all_html = '' var all_phone_js = '' if(data['relationship_option'].length != 0){ var hulkapps_required_html = " * " addtocart_html = addtocart_html + "
" $.each(data['relationship_option'], function(key, val){ var option = parseInt(val[0]) let com_con_ids = []; for (const [ key, value ] of Object.entries(a)) { if(value.includes(option)){ com_con_ids.push(key); } } var required = val[1] if(data['option_id_array'].indexOf(option) >= 0){ var option_name = $.trim(data['option_associative_array'][option]['option_name']) var tooltip_text = $.trim(data['option_associative_array'][option]['tooltip']) var helptext = $.trim(data['option_associative_array'][option]['helptext']) var placeholder = $.trim(data['option_associative_array'][option]['placeholder']) var tooltip = (tooltip_text.length > 0) ? "
" : '' var helptext_html = (helptext.length > 0) ? ""+helptext+"" : '' var option_limit = data['option_associative_array'][option]['extra_field'] var option_type = data['option_associative_array'][option]['option_type'] var option_id = option var values_json = $.parseJSON(data['option_associative_array'][option]['values_json']) var is_hide_arr = data['hide_show_array'][option_id] ? data['hide_show_array'][option_id] : '' let is_com_arr = '' let new_action_type = '' com_con_ids.forEach((item) => { $.each(data['condition'], function (index, con) { let condition_id = con['id'] var conditions = hulkapps_jQuery.parseJSON(con['conditions']) if(condition_id == item){ $.each(conditions['actions'], function (index, action) { if (parseInt(action['action_type']) == 1 && is_hide_arr.includes("condition_show")) { new_action_type = 'show'; is_com_arr += " conditional_logic_" + item + "_" + new_action_type return false; } else{ if(is_hide_arr.includes("condition_hide")){ new_action_type = 'hide'; is_com_arr += " conditional_logic_" + item + "_" + new_action_type return false; } } }); } }); }) var is_required = required == 'required' ? "required" : '' var is_inline = parseInt(option_name_inline) == 0 ? 'full_width' : '' var is_required_html = required == 'required' ? hulkapps_required_html : '' var is_enabled_tooltip = data['options_container_style']['enable_tooltip']=='1' ? tooltip : '' var is_enable_helptext = enable_helptext=='1' ? "
"+helptext_html+"
" : '' if(option_type == 'dropdown'){ html = "
" html += "
"+option_name + " " + is_required_html + " " + is_enabled_tooltip + " : " + is_enable_helptext+"
" html += "
" html += "
" all_html = all_html + html }else if(option_type=='dropdown_multiple'){ var min_selection = option_limit != undefined && option_limit != '' && option_limit['minimum_selection'] != '' && option_limit['minimum_selection'] != undefined ? option_limit['minimum_selection'].toString() : '0' var max_selection = option_limit != undefined && option_limit != '' && option_limit['maximum_selection'] != '' && option_limit['maximum_selection'] != undefined ? option_limit['maximum_selection'].toString() : '0' var selection_text = (min_selection != '0' && max_selection != '0' && checkPlan('validation_for_min_max_option_selection','boolean',data['plan_id'], data['plans_features'],data['is_on_trial_period'])) ? '[Choose from '+ min_selection +' to '+ max_selection +' values]' : (min_selection != '0' && checkPlan('validation_for_min_max_option_selection','boolean',data['plan_id'], data['plans_features'],data['is_on_trial_period'])) ? '[Choose atleast '+ min_selection +' values]' : (max_selection != '0' && checkPlan('validation_for_min_max_option_selection','boolean',data['plan_id'], data['plans_features'],data['is_on_trial_period'])) ? '[Choose upto '+ max_selection +' values]': '' var html = "
" var data_min = min_selection != undefined ? min_selection : '' var data_max = max_selection != undefined ? max_selection : '' html += "
"+option_name + " " + is_required_html + " " + is_enabled_tooltip + " :
"+ selection_text + is_enable_helptext +"
" html += "
" html += "Choose from "+min_selection+" to "+max_selection+" values" } } else if(min_selection != '0' && max_selection == '0' && checkPlan('validation_for_min_max_option_selection','boolean',data['plan_id'], data['plans_features'],data['is_on_trial_period'])){ if (parseInt(default_count) < parseInt(min_selection)){ html += "Choose atleast "+min_selection+" values" } } else if(min_selection == '0' && max_selection != '0' && checkPlan('validation_for_min_max_option_selection','boolean',data['plan_id'], data['plans_features'],data['is_on_trial_period'])){ if (parseInt(default_count) > parseInt(max_selection)){ html += "Choose upto "+max_selection+" values" } } } var validation_error = '' html += "
" all_html = all_html + html }else if(option_type=='swatch'){ var swatchcount=0 var html = "
" html += "
"+option_name + " " + is_required_html + " " + is_enabled_tooltip + " : " + is_enable_helptext+"
" html += "
" $.each(values_json, function(index,ovalue){ var price = ovalue[1] var swatch_text = (ovalue[0] != '') ? ovalue[0]:'' var swatch_type = (ovalue[2] != '') ? ovalue[2]:'' var swatch_val = (ovalue[3] != '') ? ovalue[3]:'' var vp1=(price != null && price != "") ? " [ "+data['currency_symbol']+price+" ]" : "" var vp=(price != null && price != "") ? "(+"+data['currency_symbol']+price+")" : "" var vprice=(price != null && price != "") ? price:'0.00' var opt_class = vprice != '' ? 'price-change' : '' var default_value = (typeof(ovalue[8]) == 'undefined') == true ? (ovalue[6] != undefined) ? (ovalue[6] == 'true' || ovalue[6] == 'false') ? ovalue[6] : ovalue[4] : ovalue[4] : ovalue[6] //var default_value = (ovalue[8] != undefined) ? ovalue[6] : ovalue[4] var selectedopt = (default_value == true) ? "swatch_selected" : '' var checkdopt = (default_value == true) ? "checked" : '' var swatch_title = "

"+ovalue[0]+"
"+vp+"

" var s_image = '' if(swatch_type=='image'){ swatch_style="background-image:url("+swatch_val+"); background-size:cover;background-position: center center;"+round_corners+"" swatch_image="data-image='"+swatch_val+"'" s_image = swatch_val }else{ try { var swatch_color_option = swatch_val.split(",") } catch(err) { swatch_color_option = null } if(swatch_color_option != null){ if(swatch_color_option[1] != undefined){ swatch_color_dual_ton = "background: linear-gradient(to bottom, "+swatch_color_option[0]+" 0%, "+swatch_color_option[0]+" 50%, "+swatch_color_option[1]+" 50%, "+swatch_color_option[1]+" 100%); "+round_corners+"" var swatch_style=swatch_color_dual_ton var swatch_image="data-image=''" }else{ var swatch_style="background-color:"+swatch_color_option[0]+";"+round_corners+"" var swatch_image="data-image=''" } } } if(swatch_title != undefined){ if(swatch_val != undefined){ if(tooltip_contains=="both"){ var titlee ="
"+ swatch_title + "
" }else if(tooltip_contains=="image_only"){ titlee ="
" }else{ titlee = "
"+ swatch_title + "
" } }else{ titlee ="
"+ swatch_title + "
" } }else{ titlee = "
" } tooltip_val = "
"+titlee+"
" tooltip_display_html = parseInt(tooltip_display) == 1 ? tooltip_val : '' swatch_with_text = parseInt(enable_swatch_with_text) == 1 ? swatch_text : '' html += "" swatchcount += 1 }); html += "
" all_html = all_html + html }else if(option_type=='button'){ if(checkPlan('button_option','boolean',data['plan_id'], data['plans_features'],data['is_on_trial_period']) ){ var buttoncount=0 var html = "
" html += "
"+option_name + " " + is_required_html + " " + is_enabled_tooltip + " : " + is_enable_helptext+"
" html += "
" $.each(values_json, function(index,ovalue){ var price = ovalue[1] var button_text = (ovalue[0] != '') ? ovalue[0]:'' var button_val = (ovalue[2] != '') ? ovalue[2]:'' var vp1=(price != null && price != "") ? " [ "+data['currency_symbol']+price+" ]" : "" var vp=(price != null && price != "") ? "(+"+data['currency_symbol']+price+")" : "" var vprice=(price != null && price != "") ? price:'0.00' var opt_class = vprice != '' ? 'price-change' : '' var default_value = (typeof(ovalue[7]) == 'undefined') == true ? (ovalue[5] != undefined) ? (ovalue[5] == 'true' || ovalue[5] == 'false') ? ovalue[5] : ovalue[3] : ovalue[3] : ovalue[5] //var default_value = (ovalue[7] != undefined) ? ovalue[5] : ovalue[3] var selectedopt = (default_value == true) ? "button_selected" : '' var checkdopt = (default_value == true) ? "checked" : '' //var button_title = "

"+ovalue[0]+"
"+vp+"

" var button_title = ovalue[0]+"
"+vp if(button_title != undefined){ titlee = "
"+ button_title + "
" }else{ titlee = "
" } //tooltip_val = "
"+titlee+"
" tooltip_val = "
"+button_title+"
" tooltip_display_html = parseInt(tooltip_display) == 1 ? tooltip_val : '' html += "" buttoncount += 1 }); html += "
" all_html = all_html + html } }else if(option_type=='swatch_multiple'){ var min_selection = option_limit != undefined && option_limit['minimum_selection'] != undefined && option_limit != '' && option_limit['minimum_selection'] != '' ? option_limit['minimum_selection'].toString() : '0' var max_selection = option_limit != undefined && option_limit['maximum_selection'] != undefined && option_limit != '' && option_limit['maximum_selection'] != '' ? option_limit['maximum_selection'].toString() : '0' var swatchcount=0 var selection_text = (min_selection != '0' && max_selection != '0' && checkPlan('validation_for_min_max_option_selection','boolean',data['plan_id'], data['plans_features'],data['is_on_trial_period'])) ? '[Choose from '+ min_selection +' to '+ max_selection +' values]' : (min_selection != '0' && checkPlan('validation_for_min_max_option_selection','boolean',data['plan_id'], data['plans_features'],data['is_on_trial_period'])) ? '[Choose atleast '+ min_selection +' values]' : (max_selection != '0' && checkPlan('validation_for_min_max_option_selection','boolean',data['plan_id'], data['plans_features'],data['is_on_trial_period'])) ? '[Choose upto '+ max_selection +' values]': '' var html = "
" html += "
"+option_name + " " + is_required_html + " " + is_enabled_tooltip + " : " +"
"+selection_text+" "+is_enable_helptext+"
" html += "
" var valueofhiddenprop = [] var default_count = 0 $.each(values_json, function(index,ovalue){ var price = ovalue[1] var swatch_text = (ovalue[0] != '') ? ovalue[0]:'' var swatch_type = (ovalue[2] != '') ? ovalue[2]:'' var swatch_val = (ovalue[3] != '') ? ovalue[3]:'' var vp1=(price != null && price != "") ? " [ "+data['currency_symbol']+price+" ]" : "" var vp=(price != null && price != "") ? "(+"+data['currency_symbol']+price+")" : "" var vprice=(price != null && price != "") ? price:'0.00' var opt_class = vprice != '' ? 'price-change' : '' var default_value = (typeof(ovalue[8]) == 'undefined') == true ? (ovalue[6] != undefined) ? (ovalue[6] == 'true' || ovalue[6] == 'false') ? ovalue[6] : ovalue[4] : ovalue[4] : ovalue[6] //var default_value = (typeof(ovalue[8]) == 'undefined') == true ? ovalue[4] : ovalue[6] if(default_value == true){ default_count += 1 valueofhiddenprop.push(ovalue[0].toString().trim()+vp1) } var selectedopt = (default_value == true) ? "swatch_selected" : '' var checkdopt = (default_value == true) ? "checked" : '' var swatch_title = "

"+ovalue[0]+"
"+vp+"

" var s_image = '' if(swatch_type=='image'){ swatch_style="background-image:url("+swatch_val+");background-size:cover;background-position: center center;"+round_corners+"" swatch_image="data-image='"+swatch_val+"'" s_image = swatch_val }else{ try { var swatch_color_option = swatch_val.split(",") } catch(err) { swatch_color_option = null } if(swatch_color_option != null){ if(swatch_color_option[1] != null){ swatch_color_dual_ton = "background: linear-gradient(to bottom, "+swatch_color_option[0]+" 0%, "+swatch_color_option[0]+" 50%, "+swatch_color_option[1]+" 50%, "+swatch_color_option[1]+" 100%); "+round_corners+"" var swatch_style=swatch_color_dual_ton var swatch_image="data-image=''" }else{ var swatch_style="background-color:"+swatch_color_option[0]+";"+round_corners+"" var swatch_image="data-image=''" } } } if(swatch_title != undefined){ if(swatch_val != ''){ if(tooltip_contains=="both"){ var titlee ="
"+ swatch_title + "
" }else if(tooltip_contains=="image_only"){ titlee ="
" }else{ titlee = "
"+ swatch_title + "
" } }else{ titlee ="
"+ swatch_title + "
" } }else{ titlee = "
" } tooltip_val = "
"+titlee+"
" tooltip_display_html = parseInt(tooltip_display) == 1 ? tooltip_val : '' swatch_with_text = parseInt(enable_swatch_with_text) == 1 ? swatch_text : '' html += "" swatchcount += 1 }); if(enable_swatch_images == 1){ html += "var swatch_image_url = "+$(this).find('.swatch_radio').attr('data-image')+"if ("+swatch_image_url+" != ''){$('.hulkapps_swatch_image_change img').attr('src',"+swatch_image_url+");$('.hulkapps_swatch_image_change img').attr('srcset',"+swatch_image_url+");$('.hulkapps_swatch_image_change img').attr('data-srcset',"+swatch_image_url+");}" } if(default_count > 0){ if (min_selection != '0' && max_selection != '0' && checkPlan('validation_for_min_max_option_selection','boolean',data['plan_id'], data['plans_features'],data['is_on_trial_period'])){ if (parseInt(default_count) < parseInt(min_selection) || parseInt(default_count) > parseInt(max_selection)){ html += "Choose from "+min_selection+" to "+max_selection+" values" } } else if(min_selection != '0' && max_selection == '0' && checkPlan('validation_for_min_max_option_selection','boolean',data['plan_id'], data['plans_features'],data['is_on_trial_period'])){ if (parseInt(default_count) < parseInt(min_selection)){ html += "Choose atleast "+min_selection+" values" } } else if(min_selection == '0' && max_selection != '0' && checkPlan('validation_for_min_max_option_selection','boolean',data['plan_id'], data['plans_features'],data['is_on_trial_period'])){ if (parseInt(default_count) > parseInt(max_selection)){ html += "Choose upto "+max_selection+" values" } } } var validation_error = '' html += "
" all_html = all_html + html }else if(option_type=='checkbox'){ var min_selection = option_limit != undefined && option_limit != '' && option_limit['minimum_selection'] != undefined && option_limit['minimum_selection'] != '' ? option_limit['minimum_selection'].toString() : '0' var max_selection = option_limit != undefined && option_limit != '' && option_limit['maximum_selection'] != undefined && option_limit['maximum_selection'] != '' ? option_limit['maximum_selection'].toString() : '0' var is_single_line = parseInt(single_line) == 1 ? 'single_line' : '' var selection_text = (min_selection != '0' && max_selection != '0' && checkPlan('validation_for_min_max_option_selection','boolean',data['plan_id'], data['plans_features'],data['is_on_trial_period'])) ? '[Choose from '+ min_selection +' to '+ max_selection +' values]' : (min_selection != '0' && checkPlan('validation_for_min_max_option_selection','boolean',data['plan_id'], data['plans_features'])) ? '[Choose atleast '+ min_selection +' values]' : (max_selection != '0' && checkPlan('validation_for_min_max_option_selection','boolean',data['plan_id'], data['plans_features'],data['is_on_trial_period'])) ? '[Choose upto '+ max_selection +' values]': '' var html = "
" html += "
"+option_name + " " + is_required_html + " " + is_enabled_tooltip + " : " +"
"+selection_text+" "+is_enable_helptext+"
" html += "
" var valueofhiddenprop = [] var default_count = 0 $.each(values_json, function(index,ovalue){ var price = ovalue[1] var vp1=(price != null && price != "") ? " [ "+data['currency_symbol']+price+" ]" : "" var vp2=(price != null && price != "") ? "(+"+data['currency_symbol']+price+")" : "" var vprice=(price != null && price != "") ? price:'0.00' var default_value = (typeof(ovalue[6]) == 'undefined') == true ? (ovalue[4] != undefined) ? (ovalue[4] == 'true' || ovalue[4] == 'false') ? ovalue[4] : ovalue[2] : ovalue[2] : ovalue[4] //var default_value = (ovalue[6] != undefined) ? ovalue[4] : ovalue[2] if(default_value == true){ default_count += 1 valueofhiddenprop.push(ovalue[0].toString().trim()+vp1) } var selectedopt = (default_value == true) ? "checked" : '' var opt_class = vprice != '' ? 'price-change' : '' html += "" }); if(default_count > 0){ if (min_selection != '0' && max_selection != '0' && checkPlan('validation_for_min_max_option_selection','boolean',data['plan_id'], data['plans_features'],data['is_on_trial_period'])){ if (parseInt(default_count) < parseInt(min_selection) || parseInt(default_count) > parseInt(max_selection)){ html += "Choose from "+min_selection+" to "+max_selection+" values" } } else if(min_selection != '0' && max_selection == '0' && checkPlan('validation_for_min_max_option_selection','boolean',data['plan_id'], data['plans_features'],data['is_on_trial_period'])){ if (parseInt(default_count) < parseInt(min_selection)){ html += "Choose atleast "+min_selection+" values" } } else if(min_selection == '0' && max_selection != '0' && checkPlan('validation_for_min_max_option_selection','boolean',data['plan_id'], data['plans_features'],data['is_on_trial_period'])){ if (parseInt(default_count) > parseInt(max_selection)){ html += "Choose upto "+max_selection+" values" } } } var validation_error = '' html += "
" all_html = all_html + html }else if(option_type=='textbox'){ var cc = '' var is_option_limit = option_limit != undefined && checkPlan('character_limit','boolean',data['plan_id'], data['plans_features'],data['is_on_trial_period']) && option_limit['character_limit'] != '' && option_limit['character_limit'] != undefined ? '[Maximum '+ option_limit['character_limit']+' character]' : '' var html = "
" html += "
"+option_name + " " + is_required_html + " " + is_enabled_tooltip+" :
"+is_option_limit+" "+is_enable_helptext+"
" html += "
" $.each(values_json, function(index,ovalue){ var price = ovalue[1] var vp1 = (price != null && price != "") ? " [ "+data['currency_symbol']+price+" ]" : "" var vprice=(price != null && price != "") ? price:'0.00' var maxlength_limit = '' var opt_class = vprice != '' ? 'price-change' : '' if(option_limit != undefined && checkPlan('character_limit','boolean',data['plan_id'], data['plans_features'],data['is_on_trial_period']) && option_limit['character_limit'] != '' && option_limit['character_limit'] != undefined){ maxlength_limit = "maxlength="+option_limit['character_limit']+"" } html += "" if(option_limit != undefined && checkPlan('character_limit','boolean',data['plan_id'], data['plans_features'],data['is_on_trial_period']) && option_limit['character_limit'] != '' && option_limit['character_limit'] != undefined){ html += "
"+option_limit['character_limit']+ " "+data['display_settings']['charcter_count_message']+"
" } cc += "" }); html = html + cc + "
" all_html = all_html + html }else if(option_type=='textarea'){ var cc = '' var is_option_limit = option_limit != undefined && checkPlan('character_limit','boolean',data['plan_id'], data['plans_features'],data['is_on_trial_period']) && option_limit['character_limit'] != '' && option_limit['character_limit'] != undefined ? '[Maximum '+ option_limit['character_limit']+' character]' : '' var html = "
" html += "
"+option_name + " " + is_required_html + " " + is_enabled_tooltip+" :
"+is_option_limit+" "+is_enable_helptext+"
" html += "
" $.each(values_json, function(index,ovalue){ var price = ovalue[1] var vp1 = (price != null && price != "") ? " [ "+data['currency_symbol']+price+" ]" : "" var vprice=(price != null && price != "") ? price:'0.00' var maxlength_limit = '' var opt_class = vprice != '' ? 'price-change' : '' if(option_limit != undefined && checkPlan('character_limit','boolean',data['plan_id'], data['plans_features'],data['is_on_trial_period']) && option_limit['character_limit'] != '' && option_limit['character_limit'] != undefined){ maxlength_limit = "maxlength="+option_limit['character_limit']+"" } html += "" html += "" if(option_limit != undefined && checkPlan('character_limit','boolean',data['plan_id'], data['plans_features'],data['is_on_trial_period']) && option_limit['character_limit'] != '' && option_limit['character_limit'] != undefined){ html += "
"+option_limit['character_limit']+ " "+data['display_settings']['charcter_count_message']+"
" } cc += "" }); html = html + cc + "
" all_html = all_html + html }else if(option_type=='radiobutton'){ var rbcount = 0 var is_single_line = parseInt(single_line) == 1 ? 'single_line' : '' html = "
" html += "
"+option_name+" "+is_required_html+" "+is_enabled_tooltip+" : "+is_enable_helptext+"
" html += "
" $.each(values_json, function(index,ovalue){ var price = ovalue[1] var vp1=(price != null && price != "" ) ? " [ "+data['currency_symbol']+price+" ]" : "" var vp2=(price != null && price != "") ? "(+"+data['currency_symbol']+price+")" : "" var vprice=(price != null && price != "") ? price:'0.00' var default_value = (typeof(ovalue[6]) == 'undefined') == true ? (ovalue[4] != undefined) ? (ovalue[4] == 'true' || ovalue[4] == 'false') ? ovalue[4] : ovalue[2] : ovalue[2] : ovalue[4] //var default_value = (ovalue[6] != undefined) ? ovalue[4] : ovalue[2] var selectedopt = (default_value == true) ? "radio_selected" : '' var checkdopt = (default_value == true) ? "checked" : '' var opt_class = vprice != '' ? 'price-change' : '' html += "" rbcount += 1 }); html += "
" all_html = all_html + html }else if(option_type=='file_upload'){ html = "
" html += "
"+option_name + " " + is_required_html + " " + is_enabled_tooltip +" : "+is_enable_helptext+"
" html += "
" all_html = all_html + html }else if(option_type=='email'){ var cc = '' html = "
" html += "
"+option_name + " " + is_required_html + " " + is_enabled_tooltip + " : "+is_enable_helptext+"
" html += "
" $.each(values_json, function(index,ovalue){ var price = ovalue[1] var vp1=(price != null && price != "") ? " [ "+data['currency_symbol']+price+" ]" : "" var vp2=(price != null && price != "") ? "(+"+data['currency_symbol']+price+")" : "" var vprice=(price != null && price != "") ? price:'0.00' var opt_class = vprice != '' ? 'price-change' : '' //var default_value = (ovalue[6] != undefined) ? ovalue[4] : ovalue[2] html += "" cc += "" }); html = html + cc + "
" all_html = all_html + html }else if(option_type=='date_picker'){ var cc = '' html = "
" html += "
"+option_name+" "+is_required_html+" "+is_enabled_tooltip+" : "+is_enable_helptext+"
" html += "
" $.each(values_json, function(index,ovalue){ var price = ovalue[1] var vp1=(price != null && price != "") ? " [ "+data['currency_symbol']+price+" ]" : "" var vp2=(price != null && price != "") ? "(+"+data['currency_symbol']+price+")" : "" var vprice=(price != null && price != "") ? price:'0.00' var opt_class = vprice != '' ? 'price-change' : '' html += "" cc = cc+"" }); html = html + cc + "
" all_html = all_html + html }else if(option_type=='color_picker'){ if(checkPlan('color_picker_option','boolean',data['plan_id'], data['plans_features'],data['is_on_trial_period']) ){ var cc = '' html = "
" html += "
"+option_name+" "+is_required_html+" "+is_enabled_tooltip+" : "+is_enable_helptext+"
" html += "
" $.each(values_json, function(index,ovalue){ var price = ovalue[1] var vp1=(price != null && price != "") ? " [ "+data['currency_symbol']+price+" ]" : "" var vp2=(price != null && price != "") ? "(+"+data['currency_symbol']+price+")" : "" var vprice=(price != null && price != "") ? price:'0.00' var opt_class = vprice != '' ? 'price-change' : '' html += "" cc = cc+"" }); html = html + cc + "
" all_html = all_html + html } }else if(option_type=='number_field'){ cc = '' var char_limit = option_limit != undefined && checkPlan('character_limit','boolean',data['plan_id'], data['plans_features']) && option_limit['character_limit'] != '' && option_limit['character_limit'] != undefined var is_option_limit = option_limit != undefined && checkPlan('character_limit','boolean',data['plan_id'], data['plans_features'],data['is_on_trial_period']) && option_limit['character_limit'] != '' && option_limit['character_limit'] != undefined ? '[Maximum '+ option_limit['character_limit']+' character]' : '' var html = "
" html += "
"+option_name + " " + is_required_html + " " + is_enabled_tooltip+" :
"+is_option_limit+" "+is_enable_helptext+"
" html += "
" $.each(values_json, function(index,ovalue){ var price = ovalue[1] var vp1 = (price != null && price != "") ? " [ "+data['currency_symbol']+price+" ]" : "" var vprice=(price != null && price != "") ? price:'0.00' var maxlength_limit = '' var length_validation = '' var opt_class = vprice != '' ? 'price-change' : '' if(option_limit != undefined && checkPlan('character_limit','boolean',data['plan_id'], data['plans_features'],data['is_on_trial_period']) && option_limit['character_limit'] != '' && option_limit['character_limit'] != undefined){ maxlength_limit = "maxlength="+option_limit['character_limit']+"" length_validation = "onKeyPress='if(this.value.length=="+option_limit['character_limit']+") return false;'" } html += "" if(option_limit != undefined && checkPlan('character_limit','boolean',data['plan_id'], data['plans_features'],data['is_on_trial_period']) && option_limit['character_limit'] != '' && option_limit['character_limit'] != undefined){ html += "
"+option_limit['character_limit'] + " " +data['display_settings']['charcter_count_message']+"
" } cc += "" }); html = html + cc + "
" all_html = all_html + html }else if(option_type=='phone_number'){ var cc = '' var phone_option = true var phone_number_js = '' var html = "
" html += "
"+option_name + " " + is_required_html + " " + is_enabled_tooltip +" : "+is_enable_helptext+"
" html += "
" $.each(values_json, function(index,ovalue){ var price = ovalue[1] var vp1 = (price != null && price != "") ? " [ "+data['currency_symbol']+price+" ]" : "" var vprice=(price != null && price != "") ? price:'0.00' var opt_class = vprice != '' ? 'price-change' : '' html += "✓ ValidInvalid number" cc += "" }); html = html + cc + "
" all_html = all_html + html }else if(option_type=='hidden'){ if(checkPlan('hidden_field_option','boolean',data['plan_id'], data['plans_features'],data['is_on_trial_period']) ){ var html = "
" html += "
" $.each(values_json, function(index,ovalue){ var val = ovalue[0] html += "" }); html = html + "
" all_html = all_html + html } }else if(option_type=='popup'){ if(checkPlan('popup_option','boolean',data['plan_id'], data['plans_features'],data['is_on_trial_period']) ){ html = "" all_html = all_html + html } } } }); var currency_hidden_field = "" if(all_html !== ''){ addtocart_html = addtocart_html + all_html + currency_hidden_field } addtocart_html += "
" if( parseInt(amount_note_display) == 1 || amount_note_display == ''){ addtocart_html += "" } addtocart_html += "
" addtocart_html += "
" } $("#hulkapps_custom_options_" + window.hulkapps.product_id).html(addtocart_html); conditional_rules(window.hulkapps.product_id); $('#hulkapps_options_' + window.hulkapps.product_id).closest("form").find(':submit').addClass('hulkapps_submit_cart'); if ($('#hulkapps_option_list_' + window.hulkapps.product_id + ' .hulkapps_option_set').html() == "") { $('#hulkapps_options_' + window.hulkapps.product_id).css("display", "none"); } // }, 500); } } }); } if (window.hulkapps.page_type == 'cart') { (function ($) { $('body').on('click', '.edit_cart_option', function (e) { $('body').addClass('body_fixed'); e.preventDefault(); var key = $(this).data("key"); var cart = window.hulkapps.cart; var store_id = window.hulkapps.store_id; var pid = $(this).data("product_id"); var variant_id = $(this).data("variant_id"); $("[name^='properties']").each(function () { if ($(this).val() == '') { $(this).attr('disabled', true); } }); $.ajax({ type: 'POST', url: window.hulkapps.po_url + "/api/v2/store/edit_cart_extension", data: {cart_data: cart, item_key: key, store_id: store_id, variant_id: variant_id,customer_tags: window.hulkapps.customer != null ? window.hulkapps.customer.tags.split(",") : ''}, cache: false, crossDomain: true, success: function (data) { if (data == 'ok') { location.reload(); } else { hulkapps_jQuery('#edit_cart_popup').last().html(data); hulkapps_jQuery('.edit_popup').show(); calc_options_total(pid); conditional_rules(pid); } } }); }); }(hulkapps_jQuery)); } $("body").on("change", 'input[name="updates[]"]', function (ev) { $('[name="update"]').click() }); if (window.hulkapps.page_type == "cart") { var storage_code = localStorage.getItem('discount_code'); if (storage_code != '') { $('.hulkapps_discount_code').val(storage_code); var get_cart_data = { cart_data: window.hulkapps, store_id: window.hulkapps.store_id, discount_code: storage_code, cart_collections: JSON.stringify(window.hulkapps.cart_collections), customer_tags: window.hulkapps.customer != null ? window.hulkapps.customer.tags.split(",") : '', } } else { var get_cart_data = {cart_data: window.hulkapps, store_id: window.hulkapps.store_id,customer_tags: window.hulkapps.customer != null ? window.hulkapps.customer.tags.split(",") : ''} } var count = 0 window.hulkapps.cart.items.forEach(function (selector) { if (selector['properties'] != null && selector['properties'] != {}) count++ }); if (count > 1) $(checkout_selectors).attr('disabled', true); else $(checkout_selectors).attr('disabled', false); $(checkout_selectors).attr('disabled', true); $.ajax({ type: "POST", url: window.hulkapps.po_url + "/store/get_cart_details", data: get_cart_data, crossDomain: true, success: function (data) { setTimeout(function () { $(checkout_selectors).attr('disabled', false); hulkappsDoActions(data) if (data.discounts.is_draft_order) { window.is_draft_order = true; } else { window.is_draft_order = false; } }, 1) }, error: function (request, error) { $(checkout_selectors).attr('disabled', false); } }); } } hulkappsStart($); } window.cartPageJS = function ($) { // When user enter the phone_number. $(document).on('keypress', '.hulkapps_discount_code', function (e) { if (e.which == 13) { $(".hulkapps_discount_button").click(); } if (e.which === 32) { return false; } }); // Button click for Apply Discount. $(document).on('click', '.hulkapps_discount_button', function (e) { e.preventDefault(); var code = $('.hulkapps_discount_code').val(); if (code == '') { $('.hulkapps_discount_code').addClass('discount_error'); } else { localStorage.setItem('discount_code', code); $('.hulkapps_discount_code').removeClass('discount_error'); location.reload(); } }); $(document).on('click', '.close-tag', function (e) { localStorage.removeItem('discount_code'); location.reload(); }); // When user click on edit_cart save popup. $(document).on('click', '.hulkapp_save', function (e) { e.preventDefault(); if (validate_options($(this).data('product_id'))) { $(checkout_selectors).attr('disabled', true); var line = parseInt($(this).parents('.hulkapp_popupBox').find('.hulkapp_mainContent').find('.h_index').val()) + 1; var qty = $(this).attr('data-quantity'); var line_variant_id = $(this).parents('.hulkapp_popupBox').find('.hulkapp_mainContent').find('.h_variant_id').val(); var properties = {}; $("#edit_cart_popup [name^='properties']").each(function (index, el) { if ($(this).val() == '') { $(this).remove(); } var name; if (this.type == "radio") { if (this.checked) { name = this.name.replace('properties[', '').replace(']', ''); if ($.trim(this.value).length > 0) { properties[name] = this.value; } } } else if (this.type == "file") { name = this.name.replace('properties[', '').replace(']', ''); if ($.trim(this.value).length > 0) { properties[name] = this.value; } } else { name = this.name.replace('properties[', '').replace(']', ''); if ($.trim(this.value).length > 0) { properties[name] = this.value; } } }); if ($.isEmptyObject(properties)) { $.ajax({ type: 'POST', url: '/cart/change.js', data: { quantity: 0, line: line }, dataType: 'json', success: function (cart) { if ($('.upload_cls').val() != '') { $('.upload_h_cls').remove(); } else { $('.upload_cls').remove(); } $('#edit_cart_popup .conditional').each(function (index, element) { $(this).find('.hulkapps_option_value input[type="hidden"]').val(''); }); $("[name^='properties']").each(function (index, el) { if ($(this).val() == '') { $(this).remove(); } }); $.ajax({ type: 'POST', url: '/cart/add.js', data: { quantity: qty, id: line_variant_id }, dataType: 'json', success: function (cart_item) { location.reload(); } }); } }); } else { var formData = new FormData($('#edit_cart_popup')[0]); formData.append('quantity', qty); formData.append('line', line); $.ajax({ type: 'POST', url: '/cart/change.js', data: { quantity: 0, line: line }, dataType: 'json', success: function (cart) { if ($('.upload_cls').val() != '') { $('.upload_h_cls').remove(); } else { $('.upload_cls').remove(); } $('#edit_cart_popup .conditional').each(function (index, element) { $(this).find('.hulkapps_option_value input[type="hidden"]').val(''); }); $("[name^='properties']").each(function (index, el) { if ($(this).val() == '') { $(this).remove(); } }); $.ajax({ type: 'POST', url: '/cart/add.js', data: formData, dataType: 'json', contentType: false, processData: false, success: function (cart_item) { location.reload(); } }); } }); } } ; }); // When edit_cart popup is close. $(document).on('click touchstart', '.hulkapp_close', function (e) { $('.edit_popup').hide(); $('body').removeClass('body_fixed'); }); } window.productPageJS = function ($) { $(document).on('click', '.popup_open_link', function (e) { var id = $(this).attr("data-id"); $("#popupdetailsdesing_" + id).css("display", "flex"); $(".overlay-popup").css("display", "block"); }); $(document).on('click', '.popup_close_link', function (e) { var id = $(this).attr("data-id"); $("#popupdetailsdesing_" + id).css("display", "none"); $(".overlay-popup").css("display", "none"); }); window.conditional_rules = function (prod_id) { pass = false; verify_all = Array(); verify_any = Array(); verified_condition = Array(); pass_array = Array(); $("#hulkapps_option_list_" + prod_id + " .condition_hide").removeClass("conditional"); $("#hulkapps_option_list_" + prod_id + " .condition_show").addClass("conditional"); $("#hulkapps_custom_options_" + prod_id + " #conditional_rules").children().each(function () { pass_array = Array(); pass = false; $(this).children().each(function () { pass = false; var condition_rule = $(this).text(); var field_value; if ($(".option_type_id_" + $(this).attr("data-field-num")).hasClass("dd_multi_render") == true) { var aa = condition_rule; if (aa.indexOf("!=") >= 0) { pass = true; } var count = $(".hulkapps_option_" + $(this).attr("data-field-num") + "_visible:visible :selected").length; var ct = 1; var selected_array = Array(); if ($(".hulkapps_option_" + $(this).attr("data-field-num") + "_visible:visible :selected").length > 0) { $(".hulkapps_option_" + $(this).attr("data-field-num") + "_visible:visible :selected").each(function () { var condition_rule = aa; field_value = $(this).data("conditional-value"); condition_rule = condition_rule.replace("**value11**", field_value); if (condition_rule.indexOf("==") >= 0) { var condition_rule = condition_rule.split("=="); if (condition_rule[0] == condition_rule[1]) { pass = true; } else { pass = false; } } else { var condition_rule = condition_rule.split("!="); if (condition_rule[0] != condition_rule[1]) { pass = true; } else { pass = false; } } selected_array.push(pass); if (ct == count && count > 1) { var result = selected_array.join(' || '); result = eval(result); pass_array.push(result); } else if (count == 1) { pass_array.push(pass); } ct = ct + 1; }); } else { pass_array.push(false); } } else if ($(".option_type_id_" + $(this).attr("data-field-num")).hasClass("cb_render") == true) { var aa = condition_rule; if (aa.indexOf("!=") >= 0) { pass = true; } var ctt = 1; var checked_array = Array(); var countt = $(".hulkapps_option_" + $(this).attr("data-field-num") + "_visible:visible:checked").length; $(".hulkapps_option_" + $(this).attr("data-field-num") + "_visible:visible:checked").each(function () { var condition_rule = aa; field_value = $(this).data("conditional-value"); condition_rule = condition_rule.replace("**value11**", field_value); if (condition_rule.indexOf("==") >= 0) { var condition_rule = condition_rule.split("=="); if (condition_rule[0] == condition_rule[1]) { pass = true; } else { pass = false; } } else { var condition_rule = condition_rule.split("!="); if (condition_rule[0] != condition_rule[1]) { pass = true; } else { pass = false; } } checked_array.push(pass); if (ctt == countt && countt > 1) { var result = checked_array.join(' || '); result = eval(result); pass_array.push(result); } else if (countt == 1) { pass_array.push(pass); } ctt = ctt + 1; }); } else if ($("#hulkapps_option_list_" + prod_id + " .option_type_id_" + $(this).attr("data-field-num")).hasClass("multiswatch_render") == true) { var aa = condition_rule; if (aa.indexOf("!=") >= 0) { pass = true; } var ctt = 1; var checked_array = Array(); var countt = $("#hulkapps_option_list_" + prod_id + " .hulkapps_option_" + $(this).attr("data-field-num") + "_visible:checked").length; $("#hulkapps_option_list_" + prod_id + " .hulkapps_option_" + $(this).attr("data-field-num") + "_visible:checked").each(function () { var condition_rule = aa; field_value = $(this).data("conditional-value"); condition_rule = condition_rule.replace("**value11**", field_value); if (condition_rule.indexOf("==") >= 0) { var condition_rule = condition_rule.split("=="); if (condition_rule[0] == condition_rule[1]) { pass = true; } else { pass = false; } } else { var condition_rule = condition_rule.split("!="); if (condition_rule[0] != condition_rule[1]) { pass = true; } else { pass = false; } } checked_array.push(pass); if (ctt == countt && countt > 1) { var result = checked_array.join(' || '); result = eval(result); pass_array.push(result); } else if (countt == 1) { pass_array.push(pass); } ctt = ctt + 1; }); } else { pass = false; if ($(".option_type_id_" + $(this).attr("data-field-num")).hasClass("dd_render") == true) { field_value = $("#" + $(this).attr("data-field-num") + " option:selected").attr("data-conditional-value"); } else if ($(".option_type_id_" + $(this).attr("data-field-num")).hasClass("rb_render") == true) { field_value = $(".hulkapps_option_" + $(this).attr("data-field-num") + ":checked").data("conditional-value"); } else if ($(".option_type_id_" + $(this).attr("data-field-num")).hasClass("swatch_render") == true) { field_value = $(".hulkapps_option_" + $(this).attr("data-field-num") + ".swatch_selected").data("conditional-value"); } else if ($(".option_type_id_" + $(this).attr("data-field-num")).hasClass("button_render") == true) { field_value = $(".hulkapps_option_" + $(this).attr("data-field-num") + ".button_selected").data("conditional-value"); } else { field_value = $("#" + $(this).attr("data-field-num") + "").val(); } condition_rule = condition_rule.replace("**value11**", field_value); if (condition_rule.indexOf("==") >= 0) { var condition_rule = condition_rule.split("=="); if (condition_rule[0] == condition_rule[1]) { pass = true; } else { pass = false; } } else { var condition_rule = condition_rule.split("!="); if (condition_rule[0] != condition_rule[1]) { pass = true; } else { pass = false; } } pass_array.push(pass); } }); var type_rule = $(this).attr("data-verify-all"); var condition_id = $(this).attr("name"); if (type_rule == "0") { var res = pass_array.join(' || '); } else { var res = pass_array.join(' && '); } res = eval(res); if (res) { var updated_is = true $("." + condition_id + "_show").removeClass("conditional"); $("." + condition_id + "_hide").addClass("conditional"); ; } }); $("#hulkapps_custom_options_" + prod_id + " #conditional_rules").children().each(function () { var condition_id = $(this).attr("name"); $("." + condition_id + "_hide.conditional").find('.hulkapps_option_child').each(function () { conditional_change($(this)); }) $("." + condition_id + "_show.conditional").find('.hulkapps_option_child').each(function () { conditional_change($(this)); }); }); calc_options_total(prod_id); // border_bottom = $(".hulkapps_option:visible").css("border-bottom"); // $(".hulkapps_option:visible").css("border-bottom",border_bottom); // $(".hulkapps_option:visible:last").css("border-bottom","none"); } window.conditional_change = function (obj) { if (obj.prop("type") == "select-one" || obj.prop("type") == "select-multiple") { if (obj.val()) { obj.val(''); obj.parent().removeClass("selected"); } } else if (obj.prop("type") == "radio") { if (obj.prop("checked")) { obj.prop("checked", false); // obj.val(''); obj.parent().find('.radio_selected').removeClass("radio_selected"); } } else if (obj.prop("type") == "file") { obj.val(""); obj.parent(".hulkapps_option_value").find(".upload_h_cls").val(""); } else if (obj.prop("type") == "textarea" || obj.prop("type") == "number" || obj.prop("type") == "text" || obj.prop("type") == "hidden" || obj.prop("type") == "file" || obj.prop("type") == "email" || obj.prop("type") == "date_picker" || obj.prop("type") == "color_picker") { if (obj.val()) { obj.val('').change(); obj.parents('.hulkapps_option_value').find('.tb_property_val').val(''); obj.parents('.hulkapps_option_value').find('#valid-msg').remove(); } } else if (obj.prop("type") == "color") { obj.val(""); obj.parents('.hulkapps_option_value').find('.cp_property_val').val(''); } else if (obj.prop("type") == "checkbox") { if (obj.prop("checked")) { obj.prop("checked", false); obj.parent().removeClass("swatch_selected"); } } else if (obj.prop("tagName") == "DIV") { if (obj.find('.swatch_radio').prop("checked")) { obj.find('.swatch_radio').prop("checked", false); obj.removeClass("swatch_selected"); } } } window.calc_options_total = function (product_id) { var i; var total = 0; var format = window.hulkapps.money_format; checked_variant = $("#hulkapps_option_list_" + product_id + ":visible .price-change:checked, #hulkapps_option_list_" + product_id + ":visible .price-change:selected, .hulkapps_swatch_option .swatch_selected,.textarea_selected,.textbox_selected,.emailbox_selected,.datepicker_selected,.numberfield_selected,.colorpicker_selected,.button_selected"); for (i = 0; i < checked_variant.length; i++) { if (!$(checked_variant[i]).parents(".hulkapps_option").hasClass('conditional')) { total = Number($(checked_variant[i]).attr("data-price")) + Number(total); } } $("#hulkapps_options_" + product_id + " #raw_option_total").val(total); $("#hulkapps_options_" + product_id + " #calculated_option_total").html(total.toFixed(2)); if (total > 0 && 1) { $('#hulkapps_options_' + product_id + ' #option_total').slideDown(); } else { $('#hulkapps_options_' + product_id + ' #option_total').slideUp(); } } window.checkPlan = function (slug, type, current_plan_id, plans_features, is_on_trial_period) { // function checkPlan(slug,type,current_plan_id,plans_features) { is_allowed = true if (current_plan_id == null && is_on_trial_period == true) { is_allowed = true } else { if (slug && type && plans_features && current_plan_id && plans_features[current_plan_id]) { if ($.type(plans_features) == "string") { plans_features = JSON.parse(plans_features) } if (plans_features[current_plan_id][slug] == false && type == "boolean") { is_allowed = false } } else { is_allowed = false } } return is_allowed } window.check_character_limit = function (chartotal, product_id, remain_char_msg) { var text_length = $('.hulkapps_option_value .hulkapps_option_' + product_id + '').val().length; var text_remaining = chartotal - text_length; $('#char_count_' + product_id + '').html(text_remaining + ' ' + remain_char_msg); } window.validate_options = function (product_id) { var good = true; $(".hulkapps_option:visible").each(function () { if ($(this).hasClass("validation_error")) { good = false; } }); $('#hulkapps_options_' + product_id + ' #error_text').html(''); var hulkapps_req = $("#hulkapps_option_list_" + product_id + ":visible .required:visible"); var i; for (i = 0; i < hulkapps_req.length; i++) { if (hulkapps_jQuery(hulkapps_req[i]).find("select[name^='properties']").length == 1 && !hulkapps_jQuery(hulkapps_req[i]).find("select[name^='properties']").val()) { hulkapps_jQuery(hulkapps_req[i]).addClass("validation_error"); good = false; } else if ($(hulkapps_req[i]).find(".hulkapps_radio_option").length && !$(hulkapps_req[i]).find("input[name^='properties']:checked").length) { $(hulkapps_req[i]).addClass("validation_error"); good = false; } else if ($(hulkapps_req[i]).find(".hulkapps_buton_option").length && !$(hulkapps_req[i]).find("input[name^='properties']:checked").length) { $(hulkapps_req[i]).addClass("validation_error"); good = false; } else if ($(hulkapps_req[i]).find(".hulkapps_swatch_option").length && !$(hulkapps_req[i]).find("input[name^='properties']:checked").length) { $(hulkapps_req[i]).addClass("validation_error"); good = false; } else if ($(hulkapps_req[i]).find(".hulkapps_button_option").length && !$(hulkapps_req[i]).find("input[name^='properties']:checked").length) { $(hulkapps_req[i]).addClass("validation_error"); good = false; } else if ($(hulkapps_req[i]).find("input[type='text']").length > 1) { $(hulkapps_req[i]).find("input[type='text']").each(function () { if ($(this).val() == '') { $(hulkapps_req[i]).addClass("validation_error"); good = false; } }); } else if ($(hulkapps_req[i]).find("input[type='text']").length && !$(hulkapps_req[i]).find("input[name^='properties']").val()) { $(hulkapps_req[i]).addClass("validation_error"); good = false; } else if ($(hulkapps_req[i]).find("input[type='email']").length && !$(hulkapps_req[i]).find("input[name^='properties']").val()) { $(hulkapps_req[i]).addClass("validation_error"); good = false; } else if ($(hulkapps_req[i]).find("input[type='color']").length && !$(hulkapps_req[i]).find("input[name^='properties']").val()) { $(hulkapps_req[i]).addClass("validation_error"); good = false; } else if ($(hulkapps_req[i]).find(".hulkapps_check_option").length && !$(hulkapps_req[i]).find("input[name^='properties']").val()) { $(hulkapps_req[i]).addClass("validation_error"); good = false; } else if ($(hulkapps_req[i]).find("input[type='file']").length && !$(hulkapps_req[i]).find("input[name^='properties']").val()) { $(hulkapps_req[i]).addClass("validation_error"); good = false; } else if ($(hulkapps_req[i]).hasClass("cb_render") && $(hulkapps_req[i]).find("input[type='checkbox']:checked").length && !$(hulkapps_req[i]).find("input[name^='properties']").length) { $(hulkapps_req[i]).addClass("validation_error"); good = false; } else if ($(hulkapps_req[i]).hasClass("multiswatch_render") && $(hulkapps_req[i]).find("input[type='checkbox']:checked").length && !$(hulkapps_req[i]).find("input[name^='properties']").length) { $(hulkapps_req[i]).addClass("validation_error"); good = false; } else if ($(hulkapps_req[i]).find("textarea").length && !$(hulkapps_req[i]).find("input[name^='properties']").val()) { $(hulkapps_req[i]).addClass("validation_error"); good = false; } else if ($(hulkapps_req[i]).find("select[multiple]").length && !$(hulkapps_req[i]).find("input[name^='properties']").val()) { $(hulkapps_req[i]).addClass("validation_error"); good = false; } else if ($(hulkapps_req[i]).find("input[type='number']").length && !$(hulkapps_req[i]).find("input[name^='properties']").val()) { $(hulkapps_req[i]).addClass("validation_error"); good = false; } else if ($(hulkapps_req[i]).hasClass("dp_render") && $(hulkapps_req[i]).find("input[type='date']").length && !$(hulkapps_req[i]).find("input[name^='properties']").val()) { $(hulkapps_req[i]).addClass("validation_error"); good = false; } else { $(hulkapps_req[i]).removeClass("validation_error"); } } $("#hulkapps_option_list_" + product_id + " .cb_render:visible").each(function () { if ($(this).hasClass('required')) { if ($(this).find("input[type='checkbox']").length) { if ($(this).find("input[name^='properties']").val()) { if ($(this).find('.error_span').length > 0) { $(this).addClass("validation_error"); good = false; } else { $(this).removeClass("validation_error"); } } else { $(this).addClass("validation_error"); good = false; } } else { if ($(this).find('.error_span').length > 0) { $(this).addClass("validation_error"); good = false; } else { $(this).removeClass("validation_error"); } } } else { if ($(this).find('.error_span').length > 0) { $(this).addClass("validation_error"); good = false; } else { $(this).removeClass("validation_error"); } } }); $("#hulkapps_option_list_" + product_id + " .multiswatch_render:visible").each(function () { if ($(this).hasClass('required')) { if ($(this).find("input[type='checkbox']").length) { if ($(this).find("input[name^='properties']").val()) { if ($(this).find('.error_span').length > 0) { $(this).addClass("validation_error"); good = false; } else { $(this).removeClass("validation_error"); } } else { $(this).addClass("validation_error"); good = false; } } else { if ($(this).find('.error_span').length > 0) { $(this).addClass("validation_error"); good = false; } else { $(this).removeClass("validation_error"); } } } else { if ($(this).find('.error_span').length > 0) { $(this).addClass("validation_error"); good = false; } else { $(this).removeClass("validation_error"); } } }); $("#hulkapps_option_list_" + product_id + " .dd_multi_render:visible").each(function () { if ($(this).hasClass('required')) { if ($(this).find("select[multiple]").length) { if ($(this).find("input[name^='properties']").val()) { if ($(this).find('.error_span').length > 0) { $(this).addClass("validation_error"); good = false; } else { $(this).removeClass("validation_error"); } } else { $(this).addClass("validation_error"); good = false; } } else { if ($(this).find('.error_span').length > 0) { $(this).addClass("validation_error"); good = false; } else { $(this).removeClass("validation_error"); } } } else { if ($(this).find('.error_span').length > 0) { $(this).addClass("validation_error"); good = false; } else { $(this).removeClass("validation_error"); } } }); $("#hulkapps_option_list_" + product_id + " .et_render.required:visible").each(function () { if ($(this).find("input[type='email']").length && ((!$(this).find("input[name^='properties']").val() && $(this).hasClass('required')) || (($(this).find("input[type='email']").val()) != ''))) { var userEmail = $(this).find("input[type='email']").val(); var filter = /^([\w-\.]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([\w-]+\.)+))([a-zA-Z]{2,5}|[0-9]{1,3})(\]?)$/; if (!filter.test(userEmail)) { $(this).addClass("validation_error"); good = false; } else { $(this).removeClass("validation_error"); } } }); $("#hulkapps_option_list_" + product_id + " .pn_render.required:visible").each(function () { if ($(this).find("input[type='textbox']").length && ((!$(this).find("input[name^='properties']").val() && $(this).hasClass('required')))) { $(this).addClass("validation_error"); good = false; } else { if ($(this).find(".phone_number").hasClass('error')) { $(this).addClass("validation_error"); good = false; } else { $(this).removeClass("validation_error"); } } }); $("#hulkapps_option_list_" + product_id + " .dp_render:visible").each(function () { if ($(this).find('.error_span').length > 0) { $(this).addClass("validation_error"); good = false; } else { $(this).removeClass("validation_error"); } }); $("#hulkapps_option_list_" + product_id + " .dp_render.required:visible").each(function () { if ($(this).find("input[type='date']").length && ((!$(this).find("input[name^='properties']").val() && $(this).hasClass('required')))) { $(this).addClass("validation_error"); good = false; } else { if ($(this).find('.error_span').length > 0) { $(this).addClass("validation_error"); good = false; } else { $(this).removeClass("validation_error"); } } }); return good; } window.validate_single_option = function (option_type_id, option_type) { if (option_type == 'dd_render') { if ($('.' + option_type_id).find("select[name^='properties']").length == 1 && !$('.' + option_type_id).find("select[name^='properties']").val() && $('.' + option_type_id).hasClass('required')) { $('.' + option_type_id).addClass("validation_error"); } else { $('.' + option_type_id).removeClass("validation_error"); } } else if (option_type == 'dd_multi_render') { if ($('.' + option_type_id).find("select[multiple]").length && !$('.' + option_type_id).find("input[name^='properties']").val() && $('.' + option_type_id).hasClass('required')) { $('.' + option_type_id).addClass("validation_error"); } else { $('.' + option_type_id).removeClass("validation_error"); } } else if (option_type == 'swatch_render') { // if ($('.'+option_type_id).find(".hulkapps_swatch_option").length && !$('.'+option_type_id).find("input[name^='properties']:checked").length && $('.'+option_type_id).hasClass('required')) { // $('.'+option_type_id).addClass("validation_error"); // }else { $('.' + option_type_id).removeClass("validation_error"); // } } else if (option_type == 'multiswatch_render') { if ($('.' + option_type_id).find(".hulkapps_swatch_option").length && !$('.' + option_type_id).find("input[name^='properties']").val() && $('.' + option_type_id).hasClass('required')) { $('.' + option_type_id).addClass("validation_error"); } else { $('.' + option_type_id).removeClass("validation_error"); } } else if (option_type == 'button_render') { if ($('.' + option_type_id).find(".hulkapps_buton_option").length && !$('.' + option_type_id).find("input[name^='properties']").val() && $('.' + option_type_id).hasClass('required')) { $('.' + option_type_id).addClass("validation_error"); } else { $('.' + option_type_id).removeClass("validation_error"); } } else if (option_type == 'cp_render') { if ($('.' + option_type_id).find("input[type='text']").length && !$('.' + option_type_id).find("input[name^='properties']").val() && $('.' + option_type_id).hasClass('required')) { $('.' + option_type_id).addClass("validation_error"); } else { $('.' + option_type_id).removeClass("validation_error"); } } else if (option_type == 'cb_render') { if ($('.' + option_type_id).find(".hulkapps_check_option").length && !$('.' + option_type_id).find("input[name^='properties']").val() && $('.' + option_type_id).hasClass('required')) { $('.' + option_type_id).addClass("validation_error"); } else { $('.' + option_type_id).removeClass("validation_error"); } } else if (option_type == 'tb_render') { if ($('.' + option_type_id).find("input[type='text']").length && !$('.' + option_type_id).find("input[name^='properties']").val() && $('.' + option_type_id).hasClass('required')) { $('.' + option_type_id).addClass("validation_error"); } else { $('.' + option_type_id).removeClass("validation_error"); } } else if (option_type == 'nf_render') { if ($('.' + option_type_id).find("input[type='number']").length && !$('.' + option_type_id).find("input[name^='properties']").val() && $('.' + option_type_id).hasClass('required')) { $('.' + option_type_id).addClass("validation_error"); } else { $('.' + option_type_id).removeClass("validation_error"); } } else if (option_type == 'dp_render') { if ($('.' + option_type_id).find("input[type='date']").length && $('.' + option_type_id).find("input[name^='properties']").val()) { var rxDatePattern = /^(\d{1,2})(\/|-)(\d{1,2})(\/|-)(\d{4})$/; //Declare Regex var option_date = $('.' + option_type_id).find("input[type='date']").val() if (option_date.includes("-")) { var dateParts = option_date.split("-"); option_date = dateParts[1] + "/" + dateParts[2] + "/" + dateParts[0] } var dtArray = option_date.match(rxDatePattern); // is format OK? // month is 0-based, that's why we need dataParts[1] - 1 if (dtArray == null) { $('.' + option_type_id).addClass("validation_error"); $('.' + option_type_id).find('.validation_error').remove(); $('.' + option_type_id).find("input[type='date']").after('Enter valid date format mm/dd/yyyy'); } else { //Checks for dd/mm/yyyy format. dtMonth = dtArray[1]; dtDay = dtArray[3]; dtYear = dtArray[5]; if (dtMonth < 1 || dtMonth > 12) { $('.' + option_type_id).addClass("validation_error"); $('.' + option_type_id).find('.validation_error').remove(); $('.' + option_type_id).find("input[type='date']").after('Enter valid date format mm/dd/yyyy') } else if (dtDay < 1 || dtDay > 31) { $('.' + option_type_id).addClass("validation_error"); $('.' + option_type_id).find('.validation_error').remove(); $('.' + option_type_id).find("input[type='date']").after('Enter valid date format mm/dd/yyyy') } else if ((dtMonth == 4 || dtMonth == 6 || dtMonth == 9 || dtMonth == 11) && dtDay == 31) { $('.' + option_type_id).addClass("validation_error"); $('.' + option_type_id).find('.validation_error').remove(); $('.' + option_type_id).find("input[type='date']").after('Enter valid date format mm/dd/yyyy') } else if (dtMonth == 2) { var isleap = (dtYear % 4 == 0 && (dtYear % 100 != 0 || dtYear % 400 == 0)); if (dtDay > 29 || (dtDay == 29 && !isleap)) { $('.' + option_type_id).addClass("validation_error"); $('.' + option_type_id).find('.validation_error').remove(); $('.' + option_type_id).find("input[type='date']").after('Enter valid date format mm/dd/yyyy') } else { $('.' + option_type_id).removeClass("validation_error"); $('.' + option_type_id).find('.validation_error').remove(); } } else if (dtArray[2] !== "/" || dtArray[4] !== "/") { $('.' + option_type_id).addClass("validation_error"); $('.' + option_type_id).find('.validation_error').remove(); $('.' + option_type_id).find("input[type='date']").after('Enter valid date format mm/dd/yyyy') } else { $('.' + option_type_id).removeClass("validation_error"); $('.' + option_type_id).find('.validation_error').remove(); } } } else { if ($('.' + option_type_id).find("input[type='date']").length && !$('.' + option_type_id).find("input[name^='properties']").val() && $('.' + option_type_id).hasClass('required')) { $('.' + option_type_id).addClass("validation_error"); $('.' + option_type_id).find('.validation_error').remove(); } else { $('.' + option_type_id).find('.validation_error').remove(); $('.' + option_type_id).removeClass("validation_error"); } } } else if (option_type == 'ta_render') { if ($('.' + option_type_id).find("textarea").length && !$('.' + option_type_id).find("input[name^='properties']").val() && $('.' + option_type_id).hasClass('required')) { $('.' + option_type_id).addClass("validation_error"); } else { $('.' + option_type_id).removeClass("validation_error"); } } else if (option_type == 'rb_render') { // if ($('.'+option_type_id).find(".hulkapps_radio_option").length && !$('.'+option_type_id).find("input[name^='properties']:checked").length && $('.'+option_type_id).hasClass('required')) { // $('.'+option_type_id).addClass("validation_error"); // }else { $('.' + option_type_id).removeClass("validation_error"); // } } else if (option_type == 'fu_render') { if ($('.' + option_type_id).find("input[type='file']").length && !$('.' + option_type_id).find("input[name^='properties']").val() && $('.' + option_type_id).hasClass('required')) { $('.' + option_type_id).addClass("validation_error"); } else { $('.' + option_type_id).removeClass("validation_error"); } } else if (option_type == 'pn_render') { if ($('.' + option_type_id).find("input[type='textbox']").length && ((!$('.' + option_type_id).find("input[name^='properties']").val() && $('.' + option_type_id).hasClass('required')))) { $('.' + option_type_id).addClass("validation_error"); good = false; } else { if ($('.' + option_type_id).find(".phone_number").hasClass('error')) { $('.' + option_type_id).addClass("validation_error"); good = false; } else { $('.' + option_type_id).removeClass("validation_error"); } } } else if (option_type == 'et_render') { if ($('.' + option_type_id).find("input[type='email']").length && (($('.' + option_type_id).find("input[name^='properties']").val() && $('.' + option_type_id).hasClass('required')) || (($('.' + option_type_id).find("input[type='email']").val().length) != ''))) { var userEmail = $('.' + option_type_id).find("input[type='email']").val(); var filter = /^([\w-\.]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([\w-]+\.)+))([a-zA-Z]{2,5}|[0-9]{1,3})(\]?)$/; if (!filter.test(userEmail)) { $('.' + option_type_id).addClass("validation_error"); } else { $('.' + option_type_id).removeClass("validation_error"); } } else { $('.' + option_type_id).removeClass("validation_error"); } } } var hulk_flag = 0; $(document).on("click", ".hulkapps_submit_cart", function (e) { if (hulk_flag == 0) { e.preventDefault(); var res = true; if (validate_options(window.hulkapps.product_id)) { $("[name^='properties']").each(function () { if ($(this).val() == '') { $(this).attr('disabled', true); } }); hulk_flag = 1; $('.hulkapps_submit_cart').click(); if (hulk_flag == 1) { $("[name^='properties']").each(function () { if ($(this).val() == '') { $(this).attr('disabled', false); } }); hulk_flag = 0; } } } }); } // } // }); if (typeof window.hulkapps !== 'undefined') { if ((typeof (jQuery) == 'undefined') || (parseInt(jQuery.fn.jquery) == 3 && parseFloat(jQuery.fn.jquery.replace(/^1\./, "")) < 2.1)) { hulkLoadScript('//ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js', function () { hulkapps_jQuery = jQuery.noConflict(true); checkAppInstalled(hulkapps_jQuery); }); } else { hulkapps_jQuery = jQuery checkAppInstalled(hulkapps_jQuery); } } }