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