if(typeof jQuery=='undefined') { var headTag = document.getElementsByTagName("head")[0]; var jqTag = document.createElement('script'); jqTag.type = 'text/javascript'; jqTag.src = '//ajax.googleapis.com/ajax/libs/jquery/3.1.0/jquery.min.js'; jqTag.onload = myJQueryCode; headTag.appendChild(jqTag); } else { myJQueryCode(); } function myJQueryCode() { var myshopid = $('html').find('.xgen-description-theme').text(); if (myshopid != '') { function getUrlVars() { var vars = [], hash; var hashes = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&'); for(var i = 0; i < hashes.length; i++) { hash = hashes[i].split('='); vars.push(hash[0]); vars[hash[0]] = hash[1]; } return vars; } var old_v_id = getUrlVars()["variant"]; $('form[action="/cart/add"], fieldset :input[type="radio"], input[type="checkbox"], select').change(function(e) { //get the value of the selected index. var p_id = $(".xgen-description-theme").attr("dataid"); var v_id = $(".xgen-description-theme").attr("datavariant"); var shopname = $(".xgen-description-theme").attr("datashop"); $("#description").html("

"); var v_id = getUrlVars()["variant"]; if(v_id == undefined) { v_id = $("select[name='id']").val(); } if(v_id == undefined) { v_id = $("input[name='id']").val(); } if(v_id != '') { if(v_id == old_v_id) { $.ajax({ url: 'https://apps.xgentech.net/variantdiscription/get_matafield.php', type: 'POST', data: {product_id: p_id, variant_id: old_v_id, defaulthost: shopname}, dataType: 'html', beforeSend: function() { // Show image container $("#loader").show(); }, success:function(response) { $("#description").html(response); }, complete:function(response) { // Hide image container $("#loader").hide(); } }); } else { $.ajax({ url: 'https://apps.xgentech.net/variantdiscription/get_matafield.php', type: 'POST', data: {product_id: p_id, variant_id: v_id, defaulthost: shopname}, dataType: 'html', beforeSend: function() { // Show image container $("#loader").show(); }, success:function(response) { $("#description").html(response); }, complete:function(response) { // Hide image container $("#loader").hide(); } }); } } else { var va_id = $("select[name='id']").val(); if(va_id == undefined) { va_id = $("input[name='id']").val(); } if(va_id == old_v_id) { $.ajax({ url: 'https://apps.xgentech.net/variantdiscription/get_matafield.php', type: 'POST', data: {product_id: p_id, variant_id: old_v_id, defaulthost: shopname}, dataType: 'html', beforeSend: function() { // Show image container $("#loader").show(); }, success:function(response) { $("#description").html(response); }, complete:function(response) { // Hide image container $("#loader").hide(); } }); } else { $.ajax({ url: 'https://apps.xgentech.net/variantdiscription/get_matafield.php', type: 'POST', data: {product_id: p_id, variant_id: va_id, defaulthost: shopname}, dataType: 'html', beforeSend: function() { // Show image container $("#loader").show(); }, success:function(response) { $("#description").html(response); }, complete:function(response) { // Hide image container $("#loader").hide(); } }); } } }); } else { // application is unpublished } }