1$(window).on('load', function() { 2 (function ($, waTheme, data) { 3 if (data == undefined) { 4 data = {}; 5 6 //console.log('INIT PRODUCT GROUP MODIFICATION'); 7 8 $(document).on('shown.bs.modal', '.modal', function () { 9 $(this).find('.product-groups input[name=skus]').first().trigger('change'); 10 }); 11 12 $(document).on('change', '.product-groups input[name=skus]', function(e) { 13 if (data.value != $(this).val()) { 14 data = $(this).data(), 15 data.value = $(this).val(), 16 data.sku = data.skus[data.value]; 17 18 var wrapper; 19 20 var form = $(this).parents('form'); 21 var submit = $(form).find('button[type=submit]'); 22 var quantity = $(form).find('input[name=quantity]'); 23 var quantity_section = $(form).find('.s-quantity-section'); 24 25 var price_wrapper = $(form).find('.price-wrapper'); 26 var currency = $(price_wrapper).find('.currency'); 27 //var ruble = $(price_wrapper).find('.ruble'); 28 var unit = $(price_wrapper).find('.unit'); 29 30 var product = $(form).find('input[name=product_id]'); 31 var sku = $(form).find('input[name=sku_id]'); 32 33 var ruble = '<span class="ruble">â½</span>'; 34 //console.log("ruble - "+$(ruble).prop('outerHTML')); 35 //if(typeof ruble === 'undefined') {ruble = '<span class="ruble">â½</span>'; } 36 37 38 39 $(product).val(data.product); 40 $(sku).val(data.value); 41 42 43 44 var $input = $('input[name="affiliate_percentage"]'); 45 let $span = $('.flexdiscount-discounts-affiliate'); 46 let $spanfd = $('.flexdiscount-product-discount .flexdiscount').text(); 47 48 49 50 if ($input.length > 0) { 51 var affiliateValue = $input.val(); 52 var affiliate_v = data.sku.flexdiscount_item_affiliate; 53 54 if (affiliate_v === null || affiliate_v === "") { affiliate_v = affiliateValue;} 55 56 57 var price = data.sku.price; 58 59 60 61 let result = Math.floor((price * affiliate_v) / 100); 62 if ($span.length > 0) { 63 // ФÑнкÑÐ¸Ñ Ð´Ð»Ñ Ð¿Ð¾Ð´Ð±Ð¾Ñа пÑавилÑного ÑÐºÐ»Ð¾Ð½ÐµÐ½Ð¸Ñ 64 function getBonusWord(number) { 65 let absNumber = Math.abs(number) % 100; 66 let lastDigit = absNumber % 10; 67 68 if (absNumber > 10 && absNumber < 20) return 'бонÑÑов'; 69 if (lastDigit > 1 && lastDigit < 5) return 'бонÑÑа'; 70 if (lastDigit === 1) return 'бонÑÑ'; 71 return 'бонÑÑов'; 72 } 73 74 // ФоÑмиÑÑем новÑÑ ÑÑÑÐ¾ÐºÑ (напÑимеÑ: "21 бонÑÑ") 75 let newText = result + ' ' + getBonusWord(result); 76 77 78 $span.text(newText); 79 if (affiliate_v != null || affiliate_v != "") { 80 81 var cleanPercent = parseFloat(affiliate_v); 82 $('.flexdiscount-product-discount .flexdiscount').text(cleanPercent + '%'); 83 } 84 85 86 87 88 89 } 90 91 92 } 93 94 95 96 if ((wrapper = $(this).parents('.s-product-wrapper')) && wrapper.length) { 97 console.log('LIST'); 98 99 $(quantity_section).off(); 100 $(quantity).off(); 101 102 waTheme["productsQuantity_".concat(data.product)] = { 103 $wrapper: $(quantity_section), 104 denominator: "1", 105 step: "1", 106 min: "1", 107 max: parseInt(data.sku.count) + "", 108 locales: { min: "мин. %s", max: "макÑ. %s" }, 109 }; 110 new waTheme.init.shop.Quantity(waTheme["productsQuantity_".concat(data.product)]); 111 112 $(quantity).on('change', function () { 113 114 var value = $(this).val(); 115 $(price_wrapper).html( 116 '<span class="price">' + parseFloat(data.price * value) + '</span>' + 117 ' <span class="currency">' + $(ruble).prop('outerHTML') + '/</span>' + $(unit).prop('outerHTML') 118 ); 119 if (data.comparePrice != 0 && data.price != data.comparePrice) { 120 $(price_wrapper).append( 121 '<br><span class="font-size-xs text-muted mb-2 mt-2 compare-at-price"><s>' + 122 parseFloat(data.comparePrice) + ' <span class="currency">' + $(ruble).prop('outerHTML') + 123 '/</span>' + $(unit).prop('outerHTML') + '</s></span>' 124 ); 125 } 126 127 // --- ÐÐЧÐÐÐ ÐÐÐÐ ÐÐЯ ÐЫÐÐÐÐ ÐÐÐУСР--- 128 129 130 // 1. ÐолÑÑаем маÑÑив из вÑÐµÑ Ð²Ð½ÑÑÑÐµÐ½Ð½Ð¸Ñ Ð¾Ð±ÑекÑов 131 var skuDataArray = Object.values(data.skus); 132 if (skuDataArray) { 133 var activeSku = Object.values(skuDataArray)[0]; 134 135 if (activeSku) { 136 137 138 139 // --- ÐСÐÐ ÐÐÐÐÐÐЫРÐÐÐÐ ÐÐЪЯÐÐÐÐÐЯ ÐÐÐ ÐÐÐÐÐЫХ --- 140 var bonusPercent = parseFloat(activeSku.flexdiscount_item_affiliate || 0
140); 141 var skuPrice = parseFloat(activeSku.price || 0); 142 var baseBonus = 0; 143 144 // РаÑÑÐµÑ Ð±Ð°Ð·Ð¾Ð²Ð¾Ð³Ð¾ бонÑÑа в ÑÑблÑÑ Ð¾Ñ Ð¿ÑоÑенÑа 145 if (bonusPercent > 0 && skuPrice > 0) { 146 baseBonus = Math.round((skuPrice * bonusPercent) / 100); 147 } 148 // ------------------------------------------------ 149 150 var currentForm = $(this).closest('form'); 151 var bonus_wrapper = currentForm.find('.bonus-wrapper'); 152 var bonus_badge = bonus_wrapper.find('.s-compare_price_saving'); 153 154 if (baseBonus > 0) { 155 var qtyInput = currentForm.find('input[name="quantity"], .quantity-input'); 156 var qty = parseFloat(qtyInput.val()) || 1; 157 158 var totalBonus = Math.round(baseBonus * qty); 159 160 // Ðогика ÑÐºÐ»Ð¾Ð½ÐµÐ½Ð¸Ñ 161 var bonusWord = 'бонÑÑов'; 162 var m10 = totalBonus % 10; 163 var m100 = totalBonus % 100; 164 if (m100 >= 11 && m100 <= 19) { bonusWord = 'бонÑÑов'; } 165 else if (m10 == 1) { bonusWord = 'бонÑÑ'; } 166 else if (m10 >= 2 && m10 <= 4) { bonusWord = 'бонÑÑа'; } 167 168 bonus_badge.html('ÐÑÑбÑк <b>' + totalBonus + '</b> ' + bonusWord); 169 bonus_wrapper.removeClass('is-hidden').show(); 170 } else { 171 bonus_wrapper.addClass('is-hidden').hide(); 172 } 173 174 } 175 } 176 177 }).trigger('change'); 178 179 var title = $(wrapper).find('.s-product-header'); 180 var article = $(wrapper).find('.s-product-sku__sku'); 181 var compare = $(wrapper).find('.js-compare-product'); 182 183 } else if ((wrapper = $(this).parents('.s-product-page')) && wrapper.length) { 184 $(form).off(); 185 $(submit).off(); 186 187 var compare = $(wrapper).find('.js-compare-product'); 188 189 if ($(wrapper).hasClass('s-product-dialog')) { 190 console.log('DIALOG'); 191 192 var title = $(wrapper).find('.s-product-name'); 193 var article = $(wrapper).find('.s-sku'); 194 var submit_button = $(wrapper).find('.s-submit-button'); 195 196 $(price_wrapper).html( 197 '<span class="price">' + parseFloat(data.price) + '</span>' + 198 ' <span class="currency">' + $(ruble).prop('outerHTML') + '/</span>' + $(unit).prop('outerHTML') 199 ); 200 if (data.comparePrice != 0 && data.price != data.comparePrice) { 201 $(price_wrapper).append( 202 '<br><span class="font-size-xs text-muted mb-2 mt-2 compare-at-price"><s>' + 203 parseFloat(data.comparePrice) + ' <span class="currency">' + $(ruble).prop('outerHTML') 204 + '/</span>' + $(unit).prop('outerHTML') + '</s></span>' 205 ); 206 } 207 208 $(submit_button).attr('href', data.href); 209 210 } else { 211 console.log('PAGE'); 212 213 if ('history' in window && 'pushState' in history) { 214 history.pushState(null, '', data.href); 215 } 216 217 new waTheme.init.shop.Product({ 218 $wrapper: $(wrapper).find('.s-product-cart'), 219 is_dialog: false, 220 currency: waTheme.productData.currency, 221 currency_info: waTheme.productData.currency_info, 222 services: waTheme.productData.services, 223 features: waTheme.productData.features, 224 product: { 225 sku_id: data.value, 226 skus: data.skus, 227 stock_unit_id: waTheme.productData.product.stock_unit_id, 228 base_unit_id: waTheme.productData.product.base_unit_id 229 }, 230 ignore_stock_count: waTheme.productData.ignore_stock_count, 231 fractional_config: { 232 frac_enabled: "1", 233 stock_units_enabled: "1", 234 base_units_enabled: "1" 235 }, 236 units: waTheme.productData.units, 237 locales: waTheme.productData.locales 238 }); 239 240 $.get(data.href, null, function(data) { 241 $('.s-product-info').html($(data).find('.s-product-info').html()); 242 $('.s-features-short').html($(data).find('.s-features-short').html()); 243 $('.s-summary').html($(data).find('.s-summary').html()); 244 }); 245 246 var title = $('title, .breadcrumb > .active > span, .global-header__title, .header-fixed .text-black'); 247 var article = $(wrapper).find('.s-sku'); 248 var compare_price = $(wrapper).find('.js-compare-price'); 249 250 compare = $(compare).add($('header').find('.js-compare-product')); 251 252 $(compare_price).css('display', 'none'); 253 if (data.comparePrice != 0 && data.price != data.comparePrice) { 254 $(compare_price).css('display', 'block').removeClass('is-hidden'); 255 } 256 } 257 } 258 259 var badge = $(wrapper).find('.s-compare'); 260 var wishlist = $(wrapper).find('.js-wishlist-product'); 261 var autobadge = $(wrapper).find('.autobadge-inited'); 262 263 $(title).text(data.title); 264 $(article).text(data.article); 265 266 $(badge).css('display', 'none'); 267 if (data.comparePrice != 0 && data.price != data.comparePrice) { 268 $(badge).css('display', 'block').removeClass('is-hidden'); 269 badge_compare_price = '- ' + Math.round(((data.comparePrice - data.price) / (data.comparePrice / 100))) + ' %'; 270 badge_compare_saving = 'ÐÐºÐ¾Ð½Ð¾Ð¼Ð¸Ñ '+ Math.round(data.comparePrice - data.price) + ' â½'; 271 $(badge).children().first().text(badge_compare_price);
272 $(badge).children().last().text(badge_compare_saving); 273 } 274 275 $(wishlist).removeClass("active").attr('data-product', data.product).removeData(); 276 if ($.cookie("shop_product_wishlist") != undefined) { 277 if ($.cookie("shop_product_wishlist").split(',').indexOf(data.product + "") >= 0) { 278 $(wishlist).addClass("active"); 279 } 280 } 281 282 $(compare).removeClass("active").attr('data-product', data.product).removeData(); 283 if ($.cookie("shop_compare") != undefined) { 284 if ($.cookie("shop_compare").split(',').indexOf(data.product + "") >= 0) { 285 $(compare).addClass("active"); 286 } 287 } 288 289 $(autobadge).addClass('product-id-' + data.product).attr('product-id', data.product).removeData(); 290 291 $(submit).removeClass('is-added'); 292 $(submit).children().first().text(waTheme.locales.add2cart); 293 if (Object.values(waTheme.cart_items).find(item => item.sku_id == data.value)) { 294 $(submit).addClass('is-added'); 295 $(submit).children().first().text(waTheme.locales.added2cart); 296 } 297 } 298 }); 299 300 301 } 302 })(jQuery, window.waTheme, window.productGroupModification); 303});
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.