PageSourceSearch

https://editoraurutau.com/wp-content/plugins/side-cart-for-woocommerce/js/scfw_front_script.js?ver=1.0.0

js editoraurutau.com collected 2026-10-02 07:11:37 UTC 10,545 bytes, 335 lines download raw bytes

1function wfcUpdateRefreshFragments( response ) {
2
3    if( response.fragments ) {
4
5        //Set fragments
6        jQuery.each( response.fragments, function( key, value ) {
7            jQuery( key ).replaceWith( value );
8        });
9
10        if( ( 'sessionStorage' in window && window.sessionStorage !== null ) ) {
11
12            sessionStorage.setItem( wc_cart_fragments_params.fragment_name, JSON.stringify( response.fragments ) );
13            localStorage.setItem( wc_cart_fragments_params.cart_hash_key, response.cart_hash );
14            sessionStorage.setItem( wc_cart_fragments_params.cart_hash_key, response.cart_hash );
15
16            if ( response.cart_hash ) {
17                sessionStorage.setItem( 'wc_cart_created', ( new Date() ).getTime() );
18            }
19        }
20
21        jQuery( document.body ).trigger( 'wc_fragments_refreshed' );
22    }
23}
24
25
26function wfcGetRefreshedFragments(){
27
28    jQuery.ajax({
29        url: ajax_postajax.ajaxurl,
30        type: 'POST',
31        data: {
32            action: 'wfc_get_refresh_fragments',
33        },
34        success: function( response ) {
35            wfcUpdateRefreshFragments(response);
36        }
37    })
38
39}
40
41
42jQuery(document).ready(function() {
43	jQuery( document.body ).trigger( 'wc_fragment_refresh' );
44
45    setTimeout(function() {
46        wfcGetRefreshedFragments();
47    }, 100);
48
49    scfw_sidecart_width = scfw_sidebar_width.scfw_width;
50
51    jQuery('body').on( 'added_to_cart', function() {
52       jQuery(".wfc_container").css("opacity", "1");
53	   jQuery(".wfc_container").animate({width: scfw_sidecart_width, right: '0px'});
54	   jQuery("body").addClass("scfw_overlay");
55	   jQuery(".wfc_container_overlay").addClass('active');
56    });
57
58    jQuery(".wfc_close_cart").click(function() {
59	  	var boxWidth = jQuery(".wfc_container").width();
60	   	jQuery(".wfc_container").animate({
61            right: '-'+scfw_sidecart_width
62        });
63        jQuery("body").removeClass("scfw_overlay");
64        jQuery(".wfc_container_overlay").removeClass('active');
65	});
66
67	jQuery(".wfc_container_overlay").click(function() {
68		jQuery(".wfc_close_cart").click();
69	});
70
71	jQuery(".wfc_cart_basket").click(function() {
72		jQuery(".wfc_container").css("opacity", "1");
73		jQuery(".wfc_container").animate({width: scfw_sidecart_width,right: '0px'});
74		jQuery("body").addClass("scfw_overlay");
75		jQuery(".wfc_container_overlay").addClass('active');
76	});
77
78	jQuery('body').on('click', '#wfc_apply_coupon', function() { 
79		jQuery(".wfc_apply_coupon_link").css("display","none");
80		jQuery(".wfc_coupon_field").css("display","block");
81		return false;
82	});
83
84    jQuery('body').on('click', '.wfc_coupon_submit', function() { 
85
86        var couponCode = jQuery("#wfc_coupon_code").val();
87
88        jQuery.ajax({
89            url:ajax_postajax.ajaxurl,
90            type:'POST',
91            data:'action=coupon_ajax_call&coupon_code='+couponCode,
92            success : function(response) {
93                jQuery("#wfc_cpn_resp").html(response.message);
94                if(response.result == 'not valid' || response.result == 'already applied') {
95                	jQuery("#wfc_cpn_resp").css('background-color', '#e2401c');
96                } else {
97                	jQuery("#wfc_cpn_resp").css('background-color', '#0f834d');
98                }
99                jQuery(".wfc_coupon_response").fadeIn().delay(2000).fadeOut();
100                jQuery( document.body ).trigger( 'wc_fragment_refresh' );
101            }
102        });
103    });
104
105    jQuery('body').on('click', '.wfc_remove_cpn', function() {
106
107        var removeCoupon = jQuery(this).attr('cpcode');
108
109        jQuery.ajax({
110            url:ajax_postajax.ajaxurl,
111            type:'POST',
112            data:'action=remove_applied_coupon_ajax_call&remove_code='+removeCoupon,
113            success : function(response) {
114                jQuery("#wfc_cpn_resp").html(response);
115                jQuery(".wfc_coupon_response").fadeIn().delay(2000).fadeOut();
116                jQuery( document.body ).trigger( 'wc_fragment_refresh' );
117            }
118        });
119
120    });
121
122	jQuery('body').on('change', 'input[name="update_qty"]', function() {
123	    var pro_id = jQuery(this).closest('.wfc_cart_prods').attr('product_id');
124	    var qty = jQuery(this).val();
125	    var c_key = jQuery(this).closest('.wfc_cart_prods').attr('c_key');
126		var pro_ida = jQuery(this);
127		pro_ida.prop('disabled', true);
128	    
129        jQuery.ajax({
130	        url:ajax_postajax.ajaxurl,
131	        type:'POST',
132	        data:'action=change_qty&c_key='+c_key+'&qty='+qty,
133	        success : function(response) {
134	        	pro_ida.prop('disabled', false);
135	            jQuery( document.body ).trigger( 'wc_fragment_refresh' );
136	        }
137	    });
138	});
139
140
141    var leftArrow = scfw_urls.pluginsUrl + '/images/left-arrow.svg';
142    var rightArrow = scfw_urls.pluginsUrl + '/images/right-arrow.svg';
143
144    jQuery('.wfc_slider_inn').owlCarousel({
145        loop:true,
146        margin:10,
147        nav:true,
148        navText:["<img src='"+ leftArrow +"'>", "<img src='"+ rightArrow +"'>"],
149        navClass:['owl-prev', 'owl-next'],
150        dots: false,
151        autoplay:true,
152        autoplayTimeout:3000,
153        autoplayHoverPause:true,
154        responsive:{
155            0:{
156                items:1
157            },
158            600:{
159                items:1
160            },
161            1000:{
162                items:1
163            }
164        }
165    })
166
167
168    jQuery('body').on( 'click', 'button.wfc_plus, button.wfc_minu
168s', function() {
169        
170        jQuery('.wfc_body').addClass('wfc_loader');
171        // Get current quantity values
172        var qty  = jQuery( this ).closest( '.wfc_cart_prods' ).find( '.wfc_update_qty' );
173        var val  = parseFloat(qty.val());
174        var max  = 100000000000000;
175        var min  = 1;
176        var step = 1;
177
178        // Change the value if plus or minus
179        if ( jQuery( this ).is( '.wfc_plus' ) ) {
180           if ( max && ( max <= val ) ) {
181              qty.val( max );
182           } else {
183              qty.val( val + step );
184           }
185        } else {
186           if ( min && ( min >= val ) ) {
187              qty.val( min );
188           } else if ( val > 1 ) {
189              qty.val( val - step );
190           }
191        }
192
193        var updateQty  = jQuery( this ).closest( '.wfc_cart_prods' ).find( '.wfc_update_qty' );
194        var updateVal  = parseFloat(updateQty.val());
195        var pro_id = jQuery(this).closest('.wfc_cart_prods').attr('product_id');
196        var c_key = jQuery(this).closest('.wfc_cart_prods').attr('c_key');
197        var pro_ida = jQuery(this);
198        pro_ida.prop('disabled', true);
199        
200        jQuery.ajax({
201            url:ajax_postajax.ajaxurl,
202            type:'POST',
203            data:'action=change_qty&c_key='+c_key+'&qty='+updateVal,
204            success : function(response) {
205                pro_ida.prop('disabled', false);
206                jQuery( document.body ).trigger( 'wc_fragment_refresh' );
207                jQuery('.wfc_body').addClass('wfc_loader');
208            }
209        });
210    });
211})
212
213
214jQuery(document).on('click', '.wfc_body a.wfc_remove', function (e) {
215    e.preventDefault();
216
217    jQuery('.wfc_body').addClass('wfc_loader');
218
219    var product_id = jQuery(this).attr("data-product_id"),
220        cart_item_key = jQuery(this).attr("data-cart_item_key"),
221        product_container = jQuery(this).parents('.wfc_body');	
222
223    jQuery.ajax({
224        type: 'POST',
225        dataType: 'json',
226        url: ajax_postajax.ajaxurl,
227        data: {
228            action: "product_remove",
229            product_id: product_id,
230            cart_item_key: cart_item_key
231        },
232        success: function(response) {
233
234            if ( ! response || response.error )
235                return;
236
237            var fragments = response.fragments;
238
239            // Replace fragments
240            if ( fragments ) {
241                jQuery.each( fragments, function( key, value ) {
242                    jQuery( key ).replaceWith( value );
243                });
244            }
245
246            jQuery('.wfc_body').removeClass('wfc_loader');
247        }
248    });
249});
250
251
252jQuery(document).on('click', '.add_to_cart_button', function () {
253    var cart = jQuery('.wfc_cart_basket');
254    var imgtodrag = jQuery(this).parent('.product').find("img").eq(0);
255    if (imgtodrag) {
256        var imgclone = imgtodrag.clone()
257            .offset({
258            top: imgtodrag.offset().top,
259            left: imgtodrag.offset().left
260        })
261            .css({
262            'opacity': '0.8',
263            'position': 'absolute',
264            'height': '150px',
265            'width': '150px',
266            'z-index': '100'
267        })
268            .appendTo(jQuery('body'))
269            .animate({
270            'top': cart.offset().top + 10,
271            'left': cart.offset().left + 10,
272            'width': 75,
273            'height': 75
274        }, 1000, 'easeInOutExpo');
275        
276        setTimeout(function () {
277            cart.effect("shake", {
278            times: 2
279            }, 200);
280        }, 1500);
281
282        imgclone.animate({
283            'width': 0,
284            'height': 0
285        }, function () {
286            jQuery(this).detach()
287        });
288    } 
289});
290
291
292(function ($) {
293
294    $(document).on('click', '.wfc_pslide_atc', function (e) {
295        e.preventDefault();
296
297        var $thisbutton = $(this),
298            product_id = $thisbutton.attr('data-product_id'),
299            product_qty =  $thisbutton.attr('data-quantity'),
300            variation_id = $thisbutton.attr('variation-id'),
301            product_container = $(this).parents('.wfc_body');
302
303        var data = {
304            action: 'wfc_prod_slider_ajax_atc',
305            product_id: product_id,
306            product_sku: '',
307            quantity: product_qty,
308            variation_id: variation_id,
309        };
310
311        $(document.body).trigger('adding_to_cart', [$thisbutton, data]);
312
313        $.ajax({
314            type: 'post',
315            url: ajax_postajax.ajaxurl,
316            data: data,
317            beforeSend: function (response) {
318                $('.wfc_body').addClass('wfc_loader');
319            },
320            complete: function (response) {
321            },
322            success: function (response) {
323                if (response.error & response.product_url) {
324                    window.location = response.product_url;
325                    return;
326                } else {
327                    $(document.body).trigger('added_to_cart', [response.fragments, response.cart_hash, $thisbutton]);
328                }
329                $('.wfc_body').removeClass('wfc_loader');
330            },
331        });
332
333        return false;
334    });
335})(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.