PageSourceSearch

https://mdvskin.com/wp-content/themes/medovie-new/js/shop.js?ver=3.8

js mdvskin.com collected 2026-10-09 21:38:15 UTC 25,182 bytes, 654 lines download raw bytes

1(function($) {
2
3    var currencySymbol = $("#helper").attr("data-currency");
4
5    // one time <--> subscription
6
7    /* $("body").on("click", "#one-time-subscription-panel .on-left .item", function(){
8        let target = $(this).attr("data-target");
9        $("#one-time-subscription-panel").attr("data-state", target);
10        $("#one-time-subscription-panel .on-left .item").removeClass("active");
11        $(this).addClass("active");
12        $("#one-time-subscription-panel .on-right .view").removeClass("active");
13        $("#one-time-subscription-panel .on-right #view-"+target).addClass("active");
14        let price = $("#one-time-subscription-panel .on-right #view-"+target).find(".option.active").attr("data-price");
15        let id = $("#one-time-subscription-panel .on-right #view-"+target).find(".option.active").attr("data-id");
16        let quantity = $("#one-time-subscription-panel .on-right #view-"+target).find(".option.active").attr("data-quantity");
17        $("#add-to-cart-price").text(currencySymbol+price);
18        $("#add-to-cart-price-2").text(currencySymbol+price);
19        $(".add-to-cart-single").attr("data-id", id).attr("data-quantity", quantity);
20        
21        // datalayer stuff
22        if (target == "one-time") {
23            $(".dl-add-to-cart").attr("data-type", "One Time");
24            $(".cart-bf-message.in-product.of-sub").show();
25        } else if (target == "subscribe") {
26            $(".dl-add-to-cart").attr("data-type", "Subscribe");
27            $(".cart-bf-message.in-product.of-sub").hide();
28        }
29        let singlePrice = $("#one-time-subscription-panel .on-right #view-"+target).find(".option.active").attr("data-price-single");
30        let sku = $("#one-time-subscription-panel .on-right #view-"+target).find(".option.active").attr("data-sku");
31        $(".dl-add-to-cart").attr("data-price", singlePrice);
32        $(".dl-add-to-cart").attr("data-sku", sku);
33        //
34        if (target == "subscribe") {
35            var targetName = "Subscribe";
36            var name = $("#one-time-subscription-panel .on-right #view-"+target).find(".option.active").attr("data-name");
37        } else if (target == "one-time") {
38            var targetName = "One Time";
39            var name = $("#one-time-subscription-panel").attr("data-name");
40        }
41        $(".dl-add-to-cart").attr("data-name", name);
42        dataLayer.push({
43            'PlanChange': targetName,
44            'ProductName': name,
45            'event': 'PlanChange'
46        });
47
48    });
49
50    $("body").on("click", "#one-time-subscription-panel .on-right .view .option", function(){
51        let option = $(this);
52        let price = option.attr("data-price");
53        let id = option.attr("data-id");
54        let quantity = option.attr("data-quantity");
55        let name = $("#one-time-subscription-panel").attr("data-name");
56        let state = $("#one-time-subscription-panel").attr("data-state");
57        //
58        option.siblings(".option").removeClass("active");
59        option.addClass("active");
60        //
61        $("#add-to-cart-price").text(currencySymbol+price);
62        $("#add-to-cart-price-2").text(currencySymbol+price);
63        //
64        $(".add-to-cart-single").attr("data-id", id).attr("data-quantity", quantity);
65
66        // datalayer stuff
67        let singlePrice = option.attr("data-price-single");
68        let sku = option.attr("data-sku");
69        $(".dl-add-to-cart").attr("data-price", singlePrice);
70        $(".dl-add-to-cart").attr("data-sku", sku);
71        //
72        if (state == "one-time") {
73            $(".dl-add-to-cart").attr("data-name", name);
74            dataLayer.push({
75                'QuantityChange': quantity,
76                'ProductName': name,
77                'event': 'ProductQuantityChange'
78            });
79        } else if (state == "subscribe") {
80            var optionName = option.attr("data-name");
81            $(".dl-add-to-cart").attr("data-name", optionName);
82            dataLayer.push({
83                'PlanChange': 'Subscribe',
84                'ProductName': optionName,
85                'event': 'PlanChange'
86            });
87        }
88    }); */
89
90    $("body").on("click", "#one-time-subscription-panel .on-left .item", function(){
91
92        let target = $(this).attr("data-target");
93        let panel = $("#one-time-subscription-panel");
94        let button = $(".add-to-cart-single");
95
96        panel.attr("data-state", target);
97        panel.find(".on-left .item").removeClass("active");
98        $(this).addClass("active");
99
100        let quantity = 1;
101        let price = panel.attr("data-price");
102        let sku = "";
103
104        if (target == "one-time") {
105            var targetName = "One Time";
106            var id = panel.attr("data-id");
107            var name = panel.attr("data-name");
108            button.text("Add to Cart - " + currencySymbol + price);
109        } else if (target == "subscribe") {
110            var targetName = "Subscribe";
111            var id = panel.attr("data-subscription-id");
112            var name = panel.attr("data-subscription-name");
113            button.text("Add to Cart - " + currencySymbol + price + " / Month");
114        }
115
116        //console.log(id);
117        //console.log(name);
118        //console.log(targetName);
119
120        $(".dl-add-to-cart").attr("data-type", targetName).attr("data-price", price).attr("data-sku", sku).attr("data-name", name);
121        //$("#add-to-cart-price").text(currencySymbol+price);
122        //$("#add-to-cart-price-2").text(currencySymbol+price);
123        button.attr("data-id", id).attr("data-quantity", quantity);
124
125        /* dataLayer.push({
126            'PlanChange': targetName,
127            'ProductName': name,
128            'event': 'PlanChange'
129        }); */
130
131    });
132
133    // one time <--> subscription in cat
134
135    /* $("body").on("click", ".one-time-subscription-panel.in-cat.reg .on-left .item", function(){
136        console.log("hi");
137        let item = $(this);
138        let parent = item.parents(".one-time-subscription-panel.in-cat");
139        let button = parent.siblings(".add-to-cart-single");
140        let target = item.attr("data-target");
141        parent.attr("data-state", target);
142        parent.find(".item").removeClass("active");
143        item.addClass("active");
144        parent.find(".on-right").find(".view").removeClass("active");
145        parent.find(".on-right").find(".view-"+target).addClass("active");
146        let price = parent.find(".on-right").find(".view-"+target).find(".option.active").attr("data-price");
147        let id = parent.find(".on-right").find(".view-"+target).find(".option.active").attr("data-id");
148        let quantity = parent.find(".on-right").find(".view-"+target).find(".option.active").attr("data-quantity");
149        button.find(".add-to-cart-price").text(currencySymbol+price);
150        button.attr("data-id", id).attr("data-quantity", quantity);
151
152        // datalayer stuff
153        if (target == "one-time") {
154            button.attr("data-type", "One Time");
155            parent.siblings(".cart-bf-message.in-product.in-popup.of-sub").show();
156        } else if (target == "subscribe") {
157            button.attr("data-type", "Subscribe");
158            parent.siblings(".cart-bf-message.in-product.in-popup.of-sub").hide();
159        }
160        let singlePrice = parent.find(".on-right").find(".view-"+target).find(".option.active").attr("data-price-single");
161        let sku = parent.find(".on-right").find(".view-"+target).find(".option.active").attr("data-sku");
162        button.attr("data-price", singlePrice);
163        button.attr("data-sku", sku);
164        //
165        if (target == "subscribe") {
166            var targetName = "Subscribe";
167            var name = parent.find(".on-right").find(".view-"+target).find(".option.active").attr("data-name");
168        } else if (target == "one-time") {
169            var targetName = "One Time";
170            var name = parent.attr("data-name");
171        }
172        button.attr("data-name", name);
173        dataLayer.push({
174            'PlanChange': targetName,
175            'ProductName': name,
176            'event': 'PlanChange'
177        });
178    });
179
180    $("body").on("click", ".one-time-subscription-panel.in-cat.reg .on-right .view .option", function(){
181        console.log("bye");
182        let option = $(this);
183        let parent = option.parents(".one-time-subscription-panel.in-cat");
184        let button = parent.siblings(".add-to-cart-single");
185        let price = option.attr("data-price");
186        let id = option.attr("data-id");
187        let quantity = option.attr("data-quantity");
188        let name = parent.attr("data-name");
189        let state = parent.attr("data-state");
190        //
191        option.siblings(".option").removeClass("active");
192        option.addClass("active");
193        //
194        button.find(".add-to-cart-price").text(currencySymbol+price);
195        button.attr("data-id", id).attr("data-quantity", quantity);
196
197        // datalayer stuff
198        let singlePrice = option.attr("data-price-single");
199        let sku = option.attr("data-sku");
200        button.attr("data-price", singlePrice);
201        button.attr("data-sku", sku);
202        //
203        if (state == "one-time") {
204            button.attr("data-name", name);
205            dataLayer.push({
206                'QuantityChange': quantity,
207                'ProductName': name,
208                'event': 'ProductQuantityChange'
209            });
210        } else if (state == "subscribe") {
211            var optionName = option.attr("data-name");
212            button.attr("data-name", optionName);
213            dataLayer.push({
214                'PlanChange': 'Subscribe',
215                'ProductName': optionName,
216                'event': 'PlanChange'
217            });
218        }
219    }); */
220
221    $("body").on("click", ".one-time-subscription-panel.in-cat.reg .on-left .item", function(){
222
223        let item = $(this);
224        let parent = item.parents(".one-time-subscription-panel.in-cat");
225        let button = parent.siblings(".add-to-cart-single");
226        let target = item.attr("data-target");
227        parent.attr("data-state", target);
228        parent.find(".item").removeClass("active");
229        item.addClass("active");
230
231        let quantity = 1;
232        let currency = parent.attr("data-currency");
233        let price = parent.attr("data-price");
234
235        // datalayer stuff
236        if (target == "one-time") {
237            var targetName = "One Time";
238            var id = parent.attr("data-id");
239            var name = parent.attr("data-name");
240            button.text("Add to Cart - " + currency + price);
241        } else if (target == "subscribe") {
242            var targetName = "Subscribe";
243            var id = parent.attr("data-subscription-id");
244            var name = parent.attr("data-subscription-name");
245            button.text("Add to Cart - " + currency + price + " / Month");
246        }
247
248        //console.log(id);
249        //console.log(name);
250        //console.log(targetName);
251
252        button.attr("data-id", id).attr("data-quantity", quantity).attr("data-name", name).attr("data-type", targetName);
253
254        /* dataLayer.push({
255            'PlanChange': targetName,
256            'ProductName': name,
257            'event': 'PlanChange'
258        }); */
259
260    });
261
262    // subscription <--> one time
263
264    $("body").on("click", "#one-time-subscription-panel-of-plan .on-left .item", function(){
265        $("#one-time-subscription-panel-of-plan .on-left .item").removeClass("active");
266        $(this).addClass("active");
267        let price = $(this).attr("data-price");
268        let id = $(this).attr("data-id");
269        let quantity = $(this).attr("data-quantity");
270        $("#add-to-cart-price").text(currencySymbol+price);
271        $("#add-to-cart-price-2").text(currencySymbol+price);
272        //
273        $(".add-to-cart-single").attr("data-id", id).attr("data-quantity", quantity);
274        
275        // datalayer stuff
276        let type = $(this).attr("data-type");
277        let singlePrice =  $(this).attr("data-price-single");
278        let sku =  $(this).attr("data-sku");
279        $(".dl-add-to-cart").attr("data-type", type);
280        $(".dl-add-to-cart").attr("data-price", singlePrice);
281        $(".dl-add-to-cart").attr("data-sku", sku);
282        //
283        if (type == "Subscribe") {
284            var targetName = "Subscribe";
285            var name = $("#one-time-subscription-panel-of-plan").attr("data-name");
286        } else if (type == "One Time") {
287            var targetName = "One Time";
288            var name = $("#one-time-subscription-panel-of-plan").attr("data-sub-name");
289        }
290        $(".dl-add-to-cart").attr("data-name", name);
291       /*  dataLayer.push({
292            'PlanChange': targetName,
293            'ProductName': name,
294            'event': 'PlanChange'
295        }); */
296        //
297        if ($(".cart-bf-message.in-product").length>0) {
298            if (type == "Subscribe") {
299                $(".cart-bf-message.in-product.of-sub").css("display", "inline-block");
300                $(".cart-bf-message.in-product.of-one").css("display", "none");
301            } else {
302                $(".cart-bf-message.in-product.of-sub").css("display", "none");
303                $(".cart-bf-message.in-product.of-one").css("display", "inline-block");
304            }
305        }
306    });
307
308    // subscription <--> one time in cat
309
310    $("body").on("click", ".one-time-subscription-panel.in-cat.of-plan .on-left .item", function(){
311        $(this).siblings(".item").removeClass("active");
312        $(this).addClass("active");
313        let price = $(this).attr("data-price");
314        let id = $(this).attr("data-id");
315        let quantity = $(this).attr("data-quantity");
316        let parent = $(this).parents(".one-time-subscription-panel.in-cat");
317        let button = parent.siblings(".add-to-cart-single");
318        button.find(".add-to-cart-price").text(currencySymbol+price);
319        button.attr("data-id", id).attr("data-quantity", quantity);
320
321        // datalayer stuff
322        let type = $(this).attr("data-type");
323        let singlePrice =  $(this).attr("data-price-single");
324        let sku =  $(this).attr("data-sku");
325        button.attr("data-type", type);
326        button.attr("data-price", singlePrice);
327        button.attr("data-sku", sku);
328        //
329        if (type == "Subscribe") {
330            var targetName = "Subscribe";
331            var name = parent.attr("data-name");
332        } else if (type == "One Time") {
333            var targetName = "One Time";
334            var name = parent.attr("data-sub-name");
335        }
336        button.attr("data-name", name);
337
338        //
339        if ($(this).parents(".one-time-subscription-panel").siblings(".cart-bf-message").length>0) {
340            if (type == "Subscribe") {
341                $(this).parents(".one-time-subscription-panel").siblings(".cart-bf-message.of-sub").show();
342                $(this).parents(".one-time-subscription-panel").siblings(".cart-bf-message.of-one").hide();
343            } else {
344                $(this).parents(".one-time-subscription-panel").siblings(".cart-bf-message.of-sub").hide();
345                $(this).parents(".one-time-subscription-panel").siblings(".cart-bf-message.of-one").show();
346            }
347        }
348        //
349        /* dataLayer.push({
350            'PlanChange': targetName,
351            'ProductName': name,
352            'event': 'PlanChange'
353        }); */
354    });
355
356    // add to cart
357
358    function addToCart(prodId, qty, prodName, prodSku, prodPrice) {
359        $.ajax({
360            url: add_to_cart.ajaxurl,
361            type: "post",
362            dataType: "json",
363            data: {
364                action: "add_to_cart",
365                productId: prodId,
366                qty: qty,
367            },
368            success: function (response) {
369                //console.log(response);
370                if (response.status == "added") {
371                    if (response.prodId == "76" || response.prodId == "77" || response.prodId == "115" || response.prodId == "114") {
372                        //window.location.href = baseUrl + "/checkout/";
373                        getMiniCart("yes");
374                        //openCart();
375                        //hideLoader();
376                    } else {
377                        window.location.href = baseUrl + "/checkout/";
378                    }
379                } else if (response.status == "disabled") {
380                    if (response.reason == "sub") {
381                        openPopup("purchase-disabled");
382                    } else if (response.reason == "starter") {
383                        openPopup("purchase-disabled-starter");
384                    } else if (response.reason == "free_trial") {
385                        openPopup("purchase-disabled-free-trial");
386                    } else if (response.reason == "free_trial_in_cart") {
387                        openPopup("purchase-disabled-free-trial-in-cart");
388                    }
389                    hideLoader();
390                } else {
391                    location.reload();
392                }
393            },
394        });
395    }
396    
397    $("body").on("click", ".add-to-cart", function () {
398        let that = $(this);
399        let prodId = that.attr("data-id");
400        let qty = 1;
401        let prodName = that.attr("data-name");
402        let prodSku = that.attr("data-sku");
403        let prodPrice = that.attr("data-price");
404        showLoader();
405        //
406        addToCart(prodId, qty, prodName, prodSku, prodPrice);
407    });
408
409    function getUpsell(upsellRow) {
410        console.log("hi?");
411        $.ajax({
412            url: get_upsell.ajaxurl,
413            type: "post",
414            data: {
415                action: "get_upsell",
416                upsellRow: upsellRow,
417            },
418            success: function (response) {
419                console.log(response);
420                $("#upsell-content").html(response);
421                openPopup("upsell");
422                hideLoader();
423            },
424        });
425    }
426
427    function addToCartSpecial(prodId, qty) {
428        $.ajax({
429            url: add_to_cart_special.ajaxurl,
430            type: "post",
431            dataType: "json",
432            data: {
433                action: "add_to_cart_special",
434                productId: prodId,
435                qty: qty,
436            },
437            success: function (response) {
438                //console.log(response);
439                if (response.status == "added") {
440                    if ($("#checkout-wrapper").length>0) {
441                        location.reload();
442                    } else {
443                        if (response.showUpsell == true) {
444                            getUpsell(response.upsellRow);
445                        } else {
446                            getMiniCart("yes");
447                        }
448                    }
449                } else {
450                    location.reload();
451                }
452            },
453        });
454    }
455
456    function addToCartAlijaz(prodId, qty) {
457        $.ajax({
458            url: add_to_cart_alijaz.ajaxurl,
459            type: "post",
460            dataType: "json",
461            data: {
462                action: "add_to_cart_alijaz",
463                productId: prodId,
464                qty: qty,
465            },
466            success: function (response) {
467                //console.log(response);
468                if (response.status == "added") {
469                    if ($("#checkout-wrapper").length>0) {
470                        location.reload();
471                    } else {
472                        if (response.showUpsell == true) {
473                            getUpsell(response.upsellRow);
474                        } else {
475                            getMiniCart("yes");
476                        }
477                    }
478                } else {
479                    location.reload();
480                }
481            },
482        });
483    }
484
485    $("body").on("click", ".add-to-cart-single", function () {
486        let that = $(this);
487        let prodId = that.attr("data-id");
488        let qty = that.attr("data-quantity");
489        showLoader();
490        //
491        if (that.hasClass("add-to-cart-alijaz")) {
492            addToCartAlijaz(prodId, qty);
493        } else {
494            addToCartSpecial(prodId, qty);
495        }
496    });
497
498    $("body").on("click", ".add-to-cart-fsl", function () {
499        let that = $(this);
500        showLoader();
501        //
502        $.ajax({
503            url: add_to_cart_stae.ajaxurl,
504            type: "post",
505            dataType: "json",
506            data: {
507                action: "add_to_cart_stae",
508            },
509            success: function (response) {
510                //console.log(response);
511                if (response.status == "added") {
512                    window.location.href = baseUrl + "/checkout/";
513                } else {
514                    location.reload();
515                }
516            },
517        });
518    });
519
520    // get mini cart
521
522    function getMiniCart(shouldOpen) {
523        $.ajax({
524            url: update_minicart.ajaxurl,
525            type: 'post',
526            data: {
527                action: 'update_minicart'
528            },  
529            success: function( response ) {
530                $("#side-cart-content").html(response);
531                var cartCount = parseInt($("#cart-title").attr("data-count"));
532                $("#header-cart-number").text(cartCount).attr("data-count", cartCount);
533                if (cartCount > 0) {
534                    $("#header-cart-number").addClass("show");
535                    $("#sticky-goto-checkout").addClass("show");
536                } else {
537                    $("#header-cart-number").removeClass("show");
538                    $("#sticky-goto-checkout").removeClass("show");
539                }
540                if (shouldOpen == "yes") {
541                    openCart();
542                } else {
543                    hideLoader();
544                }
545            }
546        });
547    }
548
549    // remove product
550
551	function removeFromCart(prodId) {
552		$.ajax({
553			url: remove_item.ajaxurl,
554			type: 'post',
555			data: {
556				action: 'remove_item',
557				'productId': prodId
558			},
559			success: function( response ) {
560				//console.log(response);
561                if ($("#checkout-wrapper").length>0) {
562                    location.reload();
563                } else {
564                    getMiniCart("no");
565                }
566			}
567		});
568	}
569
570	$("body").on("click", ".remove-prod", function(e) {
571		e.preventDefault();
572		var prodId = $(this).attr("data-id");
573        showLoader();
574		removeFromCart(prodId);
575    });
576
577    // quantities on cart
578
579    function addToCartItem(key, qty) {
580        $.ajax({
581            url: add_to_cart_item.ajaxurl,
582            dataType: "json",
583            type: "post",
584            data: {
585                action: "add_to_cart_item",
586                key: key,
587                qty: qty,
588            },
589            success: function (response) {
590                //console.log(response);
591                if ($("#checkout-wrapper").length>0) {
592                    location.reload();
593                } else {
594                    getMiniCart("no");
595                }
596            },
597        });
598    }
599
600    $("body").on("click", ".qty-plus", function () {
601        let key = $(this).parents(".desc").attr("data-key");
602        let currentQty = parseInt($(this).parents(".desc").attr("data-quantity"));
603        if (currentQty < 6) {
604            let qty = currentQty + 1;
605            showLoader();
606            addToCartItem(key, qty);
607            //
608            let name = $(this).parents(".mini_cart_item").attr("data-name");
609            /* dataLayer.push({
610                'QuantityChange': qty,
611                'ProductName': name,
612                'event': 'ProductQuantityChange'
613            }); */
614        } else {
615            $("#popup-message-text").html("You can add a maximum of 6 items per product. If you want to order more, please <span class='link-line switch-popup' data-open='contact' data-close='message'>contact us</span>.");
616            openPopup("message");
617        }
618    });
619
620    $("body").on("click", ".qty-minus", function () {
621        let key = $(this).parents(".desc").attr("data-key");
622        let currentQty = parseInt($(this).parents(".desc").attr("data-quantity"));
623        let qty = currentQty - 1;
624        showLoader();
625        addToCartItem(key, qty);
626        //
627        let name = $(this).parents(".mini_cart_item").attr("data-name");
628        /* dataLayer.push({
629            'QuantityChange': qty,
630            'ProductName': name,
631            'event': 'ProductQuantityChange'
632        }); */
633    });
634
635    // quantities on single product page
636
637    $("body").on("click", "#quantity-boxes .box.plus", function(){
638        let currentVal = parseInt($("#quantity-boxes .box.val").attr("data-val"));
639        let updatedVal = currentVal+1;
640        $("#quantity-boxes .box.val").attr("data-val", updatedVal).text(updatedVal);
641        $("#add-to-cart-single").attr("data-quantity", updatedVal);
642    });
643
644    $("body").on("click", "#quantity-boxes .box.minus", function(){
645        let currentVal = parseInt($("#quantity-boxes .box.val").attr("data-val"));
646        if (currentVal > 1) {
647            let updatedVal = currentVal-1;
648            $("#quantity-boxes .box.val").attr("data-val", updatedVal).text(updatedVal);
649            $("#add-to-cart-single").attr("data-quantity", updatedVal);
650        }
651    });
652    
653})(jQuery);
654  

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.