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 36 BX.ajax({ 37 url: '/bitrix/components/logictim/bonus.ajax/bonus_cart_ajax.php', 38 method: 'POST', 39 data: rows, 40 dataType: 'json', 41 onsuccess: function(result) { 42 setBonusInBasket(result); 43 } 44 }); 45} 46 47function setBonusInBasket(result) { 48 49 //for standart template of cart 50 if(BX.findChild(BX('basket-root'), {'tag': 'div', 'class': 'basket-checkout-block-total-price-inner'}, true)) 51 var itog_block = BX.findChild(BX('basket-root'), {'tag': 'div', 'class': 'basket-checkout-block-total-price-inner'}, true); 52 else 53 { 54 //for template of Aspro.Max 'V2' 55 if(BX.findChild(BX('basket-root'), {'tag': 'div', 'class': 'basket-coupon-block-total-price-current'}, true)) 56 var itog_block = BX.findChild(BX('basket-root'), {'tag': 'div', 'class': 'basket-coupon-block-total-price-current'}, true); 57 } 58 59 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}); 60 BX.remove(BX('bonus_all')); 61 62 if(parseFloat(result.ALL_BONUS) > 0) 63 itog_block.appendChild(bonus_all); 64 65 for(id in result.ITEMS) { 66 var item = result.ITEMS[id]; 67 var product_block = BX('basket-item-'+item.BASKET_ITEM_ID); 68 69 if(!product_block) 70 continue; 71 72 BX.remove(BX('bonus_item_'+item.BASKET_ITEM_ID)); 73 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}); 74 75 //NEW CART VERSION 76 if(BX('basket-item-sum-price-'+item.BASKET_ITEM_ID)) 77 { 78 var price_for_item = BX('basket-item-sum-price-'+item.BASKET_ITEM_ID); 79 if(parseFloat(item.ADD_BONUS) > 0) 80 price_for_item.appendChild(bonus_item); 81 } 82 //OLD CART VERSION 83 else 84 { 85 var price_blocks = BX.findChild(product_block, {'tag': 'div', 'class': 'basket-item-block-price'}, true, true); 86 var price_for_one = price_blocks[0]; 87 var price_for_item = price_blocks[1]; 88 89 if(parseFloat(item.ADD_BONUS) > 0) 90 price_for_item.appendChild(bonus_item); 91 } 92 93 //console.log(price_for_one); 94 } 95 96 97}
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.