1BX.ready(function(){ 2 if(!BX.Sale || !BX.Sale.BasketComponent) 3 return; 4 5 logictimBasket('first'); 6}); 7 8BX.addCustomEvent('onAjaxSuccess', function(command,params) {logictimBasket(params);}); 9 10 11function logictimBasket(params) { 12 13 if(!BX.Sale || !BX.Sale.BasketComponent) 14 return; 15 16 if(!BX.Sale.BasketComponent.result) 17 return; 18 19 if(!BX.Sale.BasketComponent.result.GRID.ROWS && BX.Sale.BasketComponent.result.BASKET_ITEM_RENDER_DATA) //DLYA ASPRO 20 BX.Sale.BasketComponent.result.GRID.ROWS = BX.Sale.BasketComponent.result.BASKET_ITEM_RENDER_DATA; 21 if(!BX.Sale.BasketComponent.result.GRID.ROWS) 22 return; 23 24 if(params.url == '/bitrix/components/logictim/bonus.ajax/bonus_cart_ajax.php') 25 return; 26 27 //CHECK CAN_BUY 28 var rows = []; 29 for(id in BX.Sale.BasketComponent.result.GRID.ROWS) { 30 var row = BX.Sale.BasketComponent.result.GRID.ROWS[id]; 31 if(row['CAN_BUY'] != 'N' && row['NOT_AVAILABLE'] != true) 32 rows[id] = row; 33 } 34 35 var data = new Object(); 36 if(arLogictimBonusCart) 37 { 38 data["SITE_ID"] = arLogictimBonusCart.SITE_ID; 39 data["LANGUAGE_ID"] = arLogictimBonusCart.LANGUAGE_ID; 40 } 41 data["ROWS"] = rows; 42 BX.ajax({ 43 url: '/bitrix/components/logictim/bonus.ajax/bonus_cart_ajax.php', 44 method: 'POST', 45 data: data, 46 dataType: 'json', 47 onsuccess: function(result) { 48 setBonusInBasket(result); 49 } 50 }); 51} 52 53function setBonusInBasket(result) { 54 55 //for standart template of cart 56 if(BX.findChild(BX('basket-root'), {'tag': 'div', 'class': 'basket-checkout-block-total-price-inner'}, true)) 57 var itog_block = BX.findChild(BX('basket-root'), {'tag': 'div', 'class': 'basket-checkout-block-total-price-inner'}, true); 58 else 59 { 60 //for template of Aspro.Max 'V2' 61 if(BX.findChild(BX('basket-root'), {'tag': 'div', 'class': 'basket-coupon-block-total-price-current'}, true)) 62 var itog_block = BX.findChild(BX('basket-root'), {'tag': 'div', 'class': 'basket-coupon-block-total-price-current'}, true); 63 } 64 65 var bonus_all = BX.create('DIV', {props: {id: 'bonus_all', className: 'lt_cart_bonus_all'}, style: {order: '10', fontWeight: 'normal'}, html: result.ALL_BONUS_FORMAT}); 66 BX.remove(BX('bonus_all')); 67 68 if(parseFloat(result.ALL_BONUS) > 0) 69 itog_block.appendChild(bonus_all); 70 71 for(id in result.ITEMS) { 72 var item = result.ITEMS[id]; 73 var product_block = BX('basket-item-'+item.BASKET_ITEM_ID); 74 75 if(!product_block) 76 continue; 77 78 BX.remove(BX('bonus_item_'+item.BASKET_ITEM_ID)); 79 var bonus_item = BX.create('DIV', {props: {id: 'bonus_item_'+item.BASKET_ITEM_ID, className: 'bonus bonus_item_cart'}, style: {order: '10', fontWeight: 'normal'}, html: item.ADD_BONUS_FORMAT}); 80 81 //NEW CART VERSION 82 if(BX('basket-item-sum-price-'+item.BASKET_ITEM_ID)) 83 { 84 var price_for_item = BX('basket-item-sum-price-'+item.BASKET_ITEM_ID); 85 if(parseFloat(item.ADD_BONUS) > 0) 86 price_for_item.appendChild(bonus_item); 87 } 88 //OLD CART VERSION 89 else 90 { 91 var price_blocks = BX.findChild(product_block, {'tag': 'div', 'class': 'basket-item-block-price'}, true, true); 92 var price_for_one = price_blocks[0]; 93 var price_for_item = price_blocks[1]; 94 95 if(parseFloat(item.ADD_BONUS) > 0) 96 price_for_item.appendChild(bonus_item); 97 } 98 99 //console.log(price_for_one); 100 } 101 102 103}
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.