PageSourceSearch

https://cmbv.fr/sites/all/modules/_ssks_projects/cmbv/js/matomo-update-cart.js?tm662r

js cmbv.fr collected 2026-10-02 04:03:19 UTC 2,300 bytes, 71 lines download raw bytes

1(function ($) {
2
3	Drupal.behaviors.matomo_update_cart = {
4		initOk : false,
5
6		attach: function (context, settings) {
7			if (Drupal.behaviors.matomo_update_cart.initOk) return;
8			Drupal.behaviors.matomo_update_cart.initOk = true;
9
10			// -----------------------------------------------------
11			// --------- UPDATE_CART
12			// -----------------------------------------------------
13
14			// Au chargement de la page panier
15			const $btnUpdateCart = $('.commerce-line-item-actions #edit-submit');
16			if ($btnUpdateCart.length > 0) {
17				Drupal.behaviors.matomo_update_cart.matomo('update_cart');
18			}
19
20			// -----------------------------------------------------
21			// --------- REMOVE_FROM_CART
22			// -----------------------------------------------------
23
24			const $deleteBtn = $('[name^="delete-line-item"]');
25			$deleteBtn.once('init-matomo-remove-from-cart').on('mousedown', function () {
26				const item_line = $(this).attr('name').replace('delete-line-item-', '');
27				Drupal.behaviors.matomo_update_cart.matomo('remove_from_cart', {item_line : item_line});
28			})
29
30			// -----------------------------------------------------
31			// --------- PURCHASE
32			// -----------------------------------------------------
33
34			const $orderCompleteForm = $('#commerce-checkout-form-complete');
35			if ($orderCompleteForm.length > 0) {
36				// on récupère l'id de la commande dans l'action
37				const match = $orderCompleteForm.attr('action').match(/\/checkout\/(\d+)\//);
38
39				if (match) {
40					const order_id = match[1];
41
42					// on vérifie si la commande a déjà été transmise à matomo
43					if (localStorage.getItem('order_id_matomo_' + order_id))
44					{
45						return;
46					}
47					Drupal.behaviors.matomo_update_cart.matomo('purchase', {order_id: order_id});
48					localStorage.setItem('order_id_matomo_' + order_id, 'true');
49				}
50			}
51		},
52
53		matomo: function (action, data) {
54			$.ajax({
55				url: '/matomo/' + action,
56				method: 'POST',
57				data: data,
58				success: function(response) {
59					window._mtm = window._mtm || [];
60					window._mtm.push({ecommerce: null});  // Clear the previous ecommerce object.
61					window._mtm.push({
62						event: action,
63						ecommerce: response,
64					});
65					window._mtm.push({ecommerce: null});  // Clear the previous ecommerce object.
66				},
67			});
68		},
69	}
70
71})(jQuery);

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.