PageSourceSearch

https://contempojewelers.com/wp-content/themes/blance/assets/js/dev/ajax_mn_addtocart.min.js?ver=6.1.14

js contempojewelers.com collected 2026-10-05 22:46:28 UTC 5,588 bytes, 130 lines download raw bytes

1jQuery(document).on('ready', function ($) {
2    "use strict";
3    
4             /**
5             *-------------------------------------------------------------------------------------------------------------------------------------------
6             * WooCommerce adding to cart
7             *-------------------------------------------------------------------------------------------------------------------------------------------
8             */
9
10            function addToCartAllTypes() {
11                // AJAX add to cart for all types of products
12                    $('body').on('added_to_cart', function () {
13            			$( 'body' ).addClass( 'widget-panel-open' );
14                        $('#jws-widget-panel-overlay').addClass('show');
15                        $('body').removeClass('modal-open');
16                        $.magnificPopup.close();  
17    		
18                    });
19                    $('body').on('click', '.cart-contents', function (e) {
20                        e.preventDefault();
21                        $('body').addClass('widget-panel-open');
22                        $('#jws-widget-panel-overlay').addClass('show');
23                    });
24
25                    $('body').on('click', '.jws-page-overlay', function (e) {
26                        e.preventDefault();
27                        $('body').removeClass('widget-panel-open');
28                        $('.jws-page-overlay').removeClass('show');
29            
30                    });
31                    
32                    $('.close-cart').click(function(e) {
33                           e.preventDefault();
34                        $('body').removeClass('widget-panel-open');
35                        $('.jws-page-overlay').removeClass('show');
36                        
37                    });
38
39                $('body').on('submit', 'form.cart', function(e) {
40                    e.preventDefault();
41        
42                    var $form = $(this),
43                        $thisbutton = $form.find('.button[type="submit"]'),
44                        data = $form.serialize();
45
46                    data += '&action=blance_ajax_add_to_cart';
47
48                    if( $thisbutton.val() ) {
49                        data += '&add-to-cart=' + $thisbutton.val();
50                    }
51
52                    $thisbutton.removeClass( 'added not-added' );
53                    $thisbutton.addClass( 'loading' );
54
55                    // Trigger event
56                    $( document.body ).trigger( 'adding_to_cart', [ $thisbutton, data ] );
57
58                    $.ajax({
59                        url: MS_Ajax.ajaxurl,
60                        data: data,
61                        method: 'POST',
62                        success: function(response) {
63                            if ( ! response ) {
64                                return;
65                            }
66
67                            var this_page = window.location.toString();
68
69                            this_page = this_page.replace( 'add-to-cart', 'added-to-cart' );
70
71                            if ( response.error && response.product_url ) {
72                                window.location = response.product_url;
73                                return;
74                            }
75
76                            // Redirect to cart option
77                            if ( wc_add_to_cart_params.cart_redirect_after_add === 'yes' ) {
78
79                                window.location = wc_add_to_cart_params.cart_url;
80                                return;
81
82                            } else {
83
84                                $thisbutton.removeClass( 'loading' );
85
86                                var fragments = response.fragments;
87                                var cart_hash = response.cart_hash;
88
89
90                                // Block fragments class
91                                if ( fragments ) {
92                                    $.each( fragments, function( key ) {
93                                        $( key ).addClass( 'updating' );
94                                    });
95                                }
96
97                                // Replace fragments
98                                if ( fragments ) {
99                                    $.each( fragments, function( key, value ) {
100                                        $( key ).replaceWith( value );
101                                    });
102                                }
103
104                                // Show notices
105                                if( response.notices.indexOf( 'error' ) > 0 ) {
106                                    $('body').append(response.notices);
107                                    $thisbutton.addClass( 'not-added' );
108                                } else {
109
110                                    // Changes button classes
111                                    $thisbutton.addClass( 'added' );
112                                    // Trigger event so themes can refresh other areas
113                                    $( document.body ).trigger( 'added_to_cart', [ fragments, cart_hash, $thisbutton ] );
114                                }
115
116                            }
117                        },
118                        error: function() {
119                            console.log('ajax adding to cart error');
120                        },
121                        complete: function() {},
122                    });
123
124                });
125
126            }
127            addToCartAllTypes();
128    
129    
130}(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.