function OCTgeturlparam(param) { var urlParams = new URLSearchParams(window.location.search); return urlParams.get(param) !== null ? param+'='+urlParams.get(param) : ''; } var OCT4_GET_LANG = ''; var prcrngopt_ur1201 = 'index.php?route=module/prcrngopt/'; var prcrngopt_url230 = 'index.php?route=extension/module/prcrngopt/'; var prcrngopt_url401 = 'index.php?route=extension/prcrngopt/module/prcrngopt|'; var prcrngopt_url402 = 'index.php?route=extension/prcrngopt/module/prcrngopt.'; var prcrngopt = { 'atgrid': function() { var product_ids = []; $(".productoption [onclick*='cart.add'], [onclick*='addToCart'], .product-thumb form input[name='product_id']").each(function() { if($(this).closest('form').find("[name*='product_id']").length) { var target = $(this).closest('.product-thumb, .product-wrapper'); var product_id = $(this).val(); } else { var target = $(this).closest('.product-thumb, .product-wrapper'); var product_id = $(this).attr('onclick').match(/[0-9]+/).toString(); } if(target.length && target.hasClass('prcrngopt_atgrid') == false) { target.addClass('prcrngopt_atgrid').addClass('prcrngopt_atgrid'+product_id); product_ids.push(product_id); } }); if(product_ids.length) { //console.log(product_ids.length); $.ajax({ url: prcrngopt_url230 + 'getcache' + OCT4_GET_LANG, type: 'post', data: {product_ids:product_ids}, cache: true, complete: function() { }, success: function(json) { if(json) { //console.log(json); $(".productoption [onclick*='cart.add'], [onclick*='addToCart'], .product-thumb form input[name='product_id']").each(function() { if($(this).closest('form').find("[name*='product_id']").length) { var target = $(this).closest('.product-thumb, .product-wrapper'); var product_id = $(this).val(); } else { var target = $(this).closest('.product-thumb, .product-wrapper'); var product_id = $(this).attr('onclick').match(/[0-9]+/).toString(); } //alert(json[product_id]); if(json[product_id] && target.length) { target.find('.price').html(json[product_id]); } }); } } }); } }, 'prodpage': function() { var product_ids = []; var product_id = false; if($(".button-group-page input[name='product_id']").length) { product_id = $(".button-group-page input[name='product_id']").val(); product_ids.push(product_id); } else if($('#input-product-id').length) { product_id = $('#input-product-id').val(); product_ids.push(product_id); } else if($(".product-info input[name='product_id']").length) { product_id = $(".product-info input[name='product_id']").val(); product_ids.push(product_id); } else if($("#product input[name='product_id']").length) { product_id = $("#product input[name='product_id']").val(); product_ids.push(product_id); } if (product_ids.length) { $.ajax({ url: prcrngopt_url230 + 'getcache' + OCT4_GET_LANG, type: 'post', data: {product_ids:product_ids}, cache: true, complete: function() { }, success: function(json) { if(json) { if(json[product_id]) { $('#product').parent().find('ul li h2').html(json[product_id]); $('.product-info .price').html(json[product_id]); $("#product ul.price").html(json[product_id]); $('#product .price-wrapper').html(json[product_id]); } } } }); } }, 'initjson': function() { prcrngopt.atgrid(); $(document).ajaxStop(function() { prcrngopt.atgrid(); //$(".price, .col-sm-4 ul.list-unstyled, #product-info ul.list-unstyled, #product ul.price, #product .price-wrapper").attr('style','opacity:1;'); }); prcrngopt.prodpage(); } } $(document).ready(function() { prcrngopt.initjson(); });