1/** 2 * Setup (required for Joomla! 3) 3 */ 4if(typeof(j2store) == 'undefined') { 5 var j2store = {}; 6} 7if(typeof(j2store.jQuery) == 'undefined') { 8 j2store.jQuery = jQuery.noConflict(); 9} 10 11function doFlexiAjaxPrice(product_id, id) { 12 (function($) { 13 /* Get input values from form */ 14 var form = $(id).closest('form'); 15 //sanity check 16 if(form.data('product_id') != product_id) return; 17 18 var values = form.serializeArray(); 19 //pop these params from values-> task : add & view : mycart 20 values.pop({ 21 name : "task", 22 value : 'addItem' 23 }); 24 25 values.pop({ 26 name : "view", 27 value : 'carts' 28 }); 29 30 values.push({ 31 name : "product_id", 32 value :product_id 33 }); 34 35 var arrayClean = function(thisArray) { 36 "use strict"; 37 $.each(thisArray, function(index, item) { 38 if (item.name == 'task' || item.name == 'view') { 39 delete values[index]; 40 } 41 }); 42 }; 43 arrayClean(values); 44 45 values = values.filter(function( element ) { 46 return element !== undefined; 47 }); 48 $( 'body' ).trigger( 'before_doAjaxPrice', [ form, values ] ); 49 $('.j2error').remove(); 50 $.ajax({ 51 url : j2storeURL+ 'index.php?option=com_j2store&view=product&task=update', 52 type : 'get', 53 data : values, 54 dataType : 'json', 55 success : function(response) { 56 57 var $product = $('.product-'+ product_id); 58 59 if ($product.length 60 && typeof response.error == 'undefined' ) { 61 //SKU 62 if (response.sku) { 63 $product.find('.sku').html(response.sku); 64 } 65 //base price 66 if (response.pricing.base_price) { 67 $product.find('.base-price').html(response.pricing.base_price); 68 if(response.pricing.class){ 69 if(response.pricing.class == 'show'){ 70 $product.find('.base-price').show(); 71 $product.find('.base-price').addClass('strike') 72 }else{ 73 $product.find('.base-price').hide() 74 } 75 } 76 } 77 //price 78 if (response.pricing.price) { 79 $product.find('.sale-price').html(response.pricing.price); 80 } 81 //afterDisplayPrice 82 if (response.afterDisplayPrice) { 83 $product.find('.afterDisplayPrice').html(response.afterDisplayPrice); 84 } 85 //qty 86 if (response.quantity) { 87 $product.find('input[name="product_qty"]').val(response.quantity); 88 if(form.data('product_type') == 'variable' || form.data('product_type') == 'advancedvariable' || form.data('product_type') == 'variablesubscriptionproduct') { 89 $product.find('input[name="product_qty"]').attr({ 90 value: response.quantity 91 }); 92 } 93 } 94 if(response.main_image){ 95 96 $product.find('.j2store-product-thumb-image-'+product_id).attr("src", response.main_image); 97 j2store.jQuery('.j2store-product-thumb-image-'+product_id).attr("src", response.main_image); 98 j2store.jQuery('.j2store-product-main-image-'+product_id).attr("src", response.main_image); 99 $product.find('.j2store-mainimage .j2store-img-responsive').attr("src", response.main_image); 100 $product.find('.j2store-product-additional-images .additional-mainimage').attr("src", response.main_image); 101 } 102 //stock status 103 104 if (typeof response.stock_status != 'undefined') { 105 if (response.availability == 1) { 106 $product.find('.product-stock-container').html('<span class="instock">' + response.stock_status + '</span>'); 107 }else { 108 $product.find('.product-stock-container').html('<span class="outofstock">' + response.stock_status + '</span>'); 109 } 110 } 111 112 //dimensions 113 if (response.dimensions) { 114 $product.find('.product-dimensions').html(response.dimensions); 115 } 116 117 //weight 118 if (response.weight) { 119 $product.find('.product-weight').html(response.weight); 120 } 121 // discount text 122 $product.find('.discount-percentage').html(response.pricing.discount_text); 123 124 // Trigger event 125 $( 'body' ).trigger( 'after_doAjaxFilter', [ $product, response ] ); 126 $( 'body' ).trigger( 'after_doAjaxPrice', [ $product, response ] ); 127 }else { 128 $product.find('#variable-options-'+product_id).after('<div class="j2error">'+response.error+'</div>'); 129 } 130 }, 131 error : function(xhr, ajaxOptions, thrownError) { 132 console.log(thrownError + "\r\n" + xhr.statusText + "\r\n" 133 + xhr.responseText); 134 } 135 }); 136 })(j2store.jQuery); 137}
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.