PageSourceSearch

https://elcon.ru/local/templates/elcon_adaptive/js/eCommerce.js?1791150970

js elcon.ru collected 2026-10-04 21:57:20 UTC 3,839 bytes, 144 lines download raw bytes

1// eCommerce
2var eCommerce = {
3	
4	// Первый запуск
5	init: function(){
6		eCommerce.getBasket();
7		
8		$(document).on('click', '.order_table_del', function(e){
9			e.preventDefault();
10			
11			var elem = $(this);
12			eCommerce.removeBasketItemId(elem.attr('href').split('id=')[1], function(){
13				setTimeout(function(){
14					if(elem.attr('data-onclick')){
15						$('#click').remove();
16						elem.after('<span id="click" onclick="'+ elem.attr('data-onclick') +'"></span>');
17						$('#click').click();
18					} else {
19						location.href = elem.attr('href');
20					}
21				}, 1000);
22			});
23			
24			return false;
25		});
26		
27		$(document).on('mousedown', '.order_table_del', function(e){
28			if($(this).attr('onclick')){
29				$(this).attr('data-onclick', $(this).attr('onclick'));
30				$(this).removeAttr('onclick');
31			}
32		});
33	},
34	
35	// Получить корзину
36	bakset: [],
37	bakset_allSum: 0,
38	getBasket: function(callback){
39		$.post('/local/templates/elcon_adaptive/components/bitrix/sale.basket.basket/basket/ajax/ajax.php', {
40			'sessid': BX.bitrix_sessid(),
41			'site_id': BX.message('SITE_ID'),
42			'select_props': 'NAME,PRICE,QUANTITY',
43			'action_var': 'basketAction',
44			'basketAction': 'recalculate'
45		}, function(result){
46			eCommerce.bakset_allSum = result.BASKET_DATA.allSum;
47			
48			if(result && result.BASKET_DATA && result.BASKET_DATA.GRID && typeof result.BASKET_DATA.GRID.ROWS === 'object' && result.BASKET_DATA.GRID.ROWS){
49				$.each(result.BASKET_DATA.GRID.ROWS, function(i, item){
50					eCommerce.bakset.push({
51						price: item.PRICE,
52						quantity: item.QUANTITY,
53						name: item.NAME,
54						id: (item.PRODUCT_XML_ID.indexOf('#') > -1 ? item.PRODUCT_XML_ID.split('#')[0] : item.PRODUCT_XML_ID),
55					});
56				});
57			}
58			
59			if(callback) callback(result);
60		}, 'json');
61	},
62	
63	// Удалить по basketItemId
64	removeBasketItemId: function(basketItemId, callback){
65		eCommerce.getProductBasketId(basketItemId, function(obj){
66			eCommerce.getBasket(function(result){
67				obj.price = result.BASKET_DATA.GRID.ROWS[basketItemId].PRICE;
68				obj.quantity = result.BASKET_DATA.GRID.ROWS[basketItemId].QUANTITY;
69				eCommerce.remove(obj);
70				if(callback) callback();
71			});
72		});
73	},
74	
75	// Получить информацию о продукте по BasketId
76	getProductBasketId: function(basketId, callback){
77		$.post('/ajax/getProduct.php', {basketId: basketId}, callback, 'json');
78	},
79	
80	// Получить информацию о продукте по sku_id
81	getProductSku: function(sku_id, callback){
82		$.post('/ajax/getProduct.php', {sku_id: sku_id}, callback, 'json');
83	},
84	
85	// Получить информацию о продукте
86	getProduct: function(id, callback){
87		$.post('/ajax/getProduct.php', {product_id: id}, callback, 'json');
88	},
89
90	// eCommerce.add({'id': '', 'name': '', 'price': '', 'quantity': '1'});
91	add: function(obj){
92		dataLayer.push({
93			"event": "AddToCart",
94            "ecommerce": {
95                "add": {
96                    "products": [obj]
97                }
98            }
99        });
100	},
101	
102	// eCommerce.detail({'id': '', 'name': '', 'price': ''});
103	detail: function(obj){
104		 dataLayer.push({
105			"event": "Detail",
106            "ecommerce": {
107                "detail": {
108                    "products": [obj]
109                }
110            }
111        });
112	},
113	
114	// eCommerce.remove({'id': '', 'name': '', 'quantity': '1'});
115	remove: function(obj){
116		dataLayer.push({
117			"event": "removeFromCart",
118			'ecommerce': {
119				'remove': {
120					'products': [obj]
121				}
122			}
123		});
124	},
125	
126	// eCommerce.purchase(order_id);
127	purchase: function(id){
128		dataLayer.push({
129			"event": "Purchase",
130			"ecommerce": {
131				"purchase": {
132					"actionField": {
133						'id': id,
134						'revenue': eCommerce.bakset_allSum
135					},
136					"products": eCommerce.bakset
137				}
138			}
139		});
140	}
141	
142};
143
144$(eCommerce.init);

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.