PageSourceSearch

https://mehring.com/wp-content/plugins/frequently-bought-together-…bought-together-for-woo-public.js?ver=1.6.0

js mehring.com collected 2026-10-02 10:22:17 UTC 4,313 bytes, 120 lines download raw bytes

1(function ($) {
2	'use strict';
3
4	$(function () {
5		var calculate_data = function() {
6			var returnArray = new Object();
7			var totalPrice = 0;
8			var pid, price;
9			var productIds = [];
10			var totalProducts = 0;
11			var button_text = '';
12
13			$("#frequently_bought_together_form :checkbox:checked").each(function (i) {
14				pid = $(this).val();
15				productIds[i] = pid;
16				price = $(this).closest(".frequently_bought_product").attr("price");
17				totalPrice = Number(totalPrice) + Number(price);
18				totalProducts = i + 1;
19			});
20
21			totalPrice = totalPrice.toFixed(labels.number_of_decimal);
22
23			// To handle case if decimal separator is not dot.
24			if ( labels.decimal_separator == ',' ) {
25				var parts = totalPrice.split('.');
26				var part1 = parts[0];
27				var part2 = parts[1];
28				totalPrice = part1 + ',' + part2;
29			}
30
31			returnArray['totalProducts'] = totalProducts;
32			returnArray['totalPrice'] = totalPrice;
33			returnArray['productIds'] = productIds;
34
35			return returnArray;
36		};
37
38		var display_total_price = function(productIds, totalPrice) {
39			$(".frequently_bought_product_price_total").html(labels.currency + totalPrice);
40			$("#frequently_bought_together_selected_product_id").val(productIds);
41		};
42
43		var add_button_text = function(totalProducts) {
44			$(".frequently_bought_add_to_cart").show();
45			if (totalProducts == 0) {
46				var button_text = labels.zero_item;
47				$(".frequently_bought_add_to_cart").hide();
48			} else if (totalProducts == 1) {
49				var button_text = labels.one_item;
50			} else if (totalProducts == 2) {
51				var button_text = labels.two_items;
52			} else {
53				var button_text = labels.n_items;
54			}
55
56			$(".frequently_bought_add_to_cart .single_add_to_cart_button").html(button_text);
57			$("#total_products").text(totalProducts);
58		};
59
60		var show = function () {
61			var calculate_data_array = calculate_data();
62			var productIds = calculate_data_array['productIds'];
63			var totalPrice = calculate_data_array['totalPrice'];
64			var totalProducts = calculate_data_array['totalProducts'];
65			display_total_price(productIds, totalPrice);
66			add_button_text(totalProducts);
67
68		};
69		$("#frequently_bought_together_form input:checkbox").on('click', function () {
70			show();
71		});
72
73		$(".single_add_to_cart_button").on('click', function () {
74			var addtocarturl = labels.site_url;
75			var product_ids = $("#frequently_bought_together_selected_product_id").val();
76			if (product_ids) {
77				addtocarturl = addtocarturl + product_ids;
78				$("a.single_add_to_cart_button").attr("href", addtocarturl);
79			}
80
81			var variation_id = $("#frequently_bought_together_selected_variation_id").val();
82			addtocarturl = addtocarturl + "&variation_id=" + variation_id;
83			$("a.single_add_to_cart_button").attr("href", addtocarturl);
84		});
85
86		$(document).on('found_variation', function (e, data) {
87			var is_variation_visible = data.variation_is_visible;
88			if(is_variation_visible == true) {
89				var variation_id = data.variation_id;
90
91				$("#frequently_bought_product_1").attr('price',  data.display_price);
92
93				// Set Image.
94				$('#frequently_bought_product_1 img.attachment-shop_thumbnail').attr('src', data.image_src);
95				$('#frequently_bought_product_1 img.attachment-shop_thumbnail').attr('srcset', data.image_src);
96
97				// Set Variation ID.
98				$('#frequently_bought_product_1 .frequently_bought_product_title input').attr('value', variation_id);
99
100				// Set Price.
101				var priceSpan = '<span class="woocommerce-Price-currencySymbol">' + labels.currency + '</span>' + data.display_price.toFixed(2);
102				$('#frequently_bought_product_price_1 span.woocommerce-Price-amount').html(priceSpan);
103
104				var { variations_data } = labels;
105				if ( typeof labels.variations_data !== 'undefined' && labels.variations_data !== null ) {
106					var variations = JSON.parse(labels.variations_data);
107					// Set ID.
108					$('#frequently_bought_product_1 div.frequently_bought_product_title input').attr('value', variation_id);
109					// Set URL.
110					$('#frequently_bought_product_1 div.frequently_bought_product_title a').attr('href', variations[variation_id].url);
111					// Set Title.
112					$('#frequently_bought_product_1 div.frequently_bought_product_title a').text( variations[variation_id].title);
113				}
114			} else {
115				$("#frequently_bought_product_1").attr('price',  0);
116			}
117			show();
118		});
119	});
120})(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.