PageSourceSearch

https://www.artestampaedizioni.it/wp-content/plugins/add-to-cart-d…/public/js/pi-dcw-public.x77440.js

js artestampaedizioni.it collected 2026-09-24 21:23:36 UTC 4,450 bytes, 158 lines download raw bytes

1(function ($) {
2	'use strict';
3
4	/**
5	 * All of the code for your public-facing JavaScript source
6	 * should reside in this file.
7	 *
8	 * Note: It has been assumed you will write jQuery code here, so the
9	 * $ function reference has been prepared for usage within the scope
10	 * of this function.
11	 *
12	 * This enables you to define handlers, for when the DOM is ready:
13	 *
14	 * $(function() {
15	 *
16	 * });
17	 *
18	 * When the window is loaded:
19	 *
20	 * $( window ).load(function() {
21	 *
22	 * });
23	 *
24	 * ...and/or other possibilities.
25	 *
26	 * Ideally, it is not considered best practise to attach more than a
27	 * single DOM-ready or window-load handler for a particular page.
28	 * Although scripts in the WordPress core, Plugins and Themes may be
29	 * practising this, we should strive to set a better example in our own work.
30	 */
31
32	jQuery(document).ready(function ($) {
33
34		var variation_obj = new variation()
35		variation_obj.init();
36		function variation() {
37			this.is_variable = false;
38
39			this.init = function () {
40				this.is_variable = this.checkIfVariable();
41				this.checkAddToCart();
42				this.variationChange();
43				this.buttonChange();
44				this.addHidden();
45				this.buttonChange();
46				this.blockAddToCart();
47			}
48
49			this.checkIfVariable = function () {
50				var $ = jQuery;
51				if ($("input[name='variation_id']").length) {
52					return true;
53				}
54				return false;
55			}
56
57			this.variationChange = function () {
58				var parent = this;
59				jQuery("body").on('change', "input[name='variation_id']", function () {
60					parent.checkAddToCart();
61				});
62			}
63
64			this.checkAddToCart = function () {
65				if (this.is_variable) {
66					var id = parseInt($("input[name='variation_id']").val());
67					var parentForm = $("input[name='variation_id']").closest("form.variations_form");
68					if(parentForm.length > 0){
69						var button = parentForm.find(".pisol_single_buy_now"); 
70					}else{
71						var button = $("button.pisol_single_buy_now");
72					}
73					if (id > 0 && id != "") {
74						this.statusBuyNow(button, true);
75					} else {
76						this.statusBuyNow(button, false);
77					}
78				}
79			}
80
81			this.buttonChange = function () {
82				var parent = this;
83
84				$(".single_variation_wrap").on("show_variation", function (event, variation) {
85					var button = jQuery(".pisol_single_buy_now", this);
86					if (variation['is_in_stock']) {
87						parent.statusBuyNow(button, true);
88					} else {
89						parent.statusBuyNow(button, false, true);
90					}
91				});
92			}
93
94			this.statusBuyNow = function (button, status, out_of_stock = false) {
95				var $ = jQuery;
96				if (status) {
97					//$(".pisol_single_buy_now").attr("disabled", false);
98					$(".pisol_single_buy_now").removeClass('disabled');
99					button.removeAttr('data-message');
100				} else {
101					//$(".pisol_single_buy_now").attr("disabled", true);
102					$(".pisol_single_buy_now").addClass('disabled');
103
104					var message  = '';
105					if(out_of_stock){
106						if(typeof wc_add_to_cart_variation_params != 'undefined'){
107							message = wc_add_to_cart_variation_params.i18n_unavailable_text ?? '';
108						}
109					}else{
110						if(typeof wc_add_to_cart_variation_params != 'undefined'){
111							message = wc_add_to_cart_variation_params.i18n_make_a_selection_text ?? '';
112						}
113					}
114					button.attr('data-message', message);
115				}
116			}
117
118			this.addHidden = function () {
119				var $ = jQuery;
120				var parent = this;
121				$(document).on("click", ".pisol_single_buy_now", function (e) {
122					/*
123					$(this).after('<input type="hidden" name="pi_quick_checkout" value="true"/>');
124					*/
125					if($(this).hasClass('disabled')){
126						e.preventDefault();
127						parent.showWarning($(this));
128						return;
129					}
130
131					$(this).off('click', function () {
132						$(this).trigger('click');
133					});
134
135					/** this prevents ajax add to cart added by other plugins */
136					$(document).trigger('pisol_dtt_buy_now_clicked', [this]);
137					jQuery(document.body).off('submit', 'form.cart');
138				});
139			}
140
141			this.showWarning = function (button) {
142				var message = button.attr("data-message");
143				if(message){
144					alert(message);
145				}
146			}
147
148			this.blockAddToCart = function (){
149				$(document).on('wc-blocks_added_to_cart', function(e, data){
150					if(pisol_dcw_setting.redirect_url){
151						window.location = pisol_dcw_setting.redirect_url
152					}
153				})
154			}
155		}
156	});
157
158})(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.