PageSourceSearch

https://westernusc.store/wp-content/plugins/woo-product-table/assets/js/custom.js?ver=6.1.3.0

js westernusc.store collected 2026-09-29 00:50:55 UTC 104,695 bytes, 2,310 lines download raw bytes

1/* 
2 * Only for Fronend Section
3 * @since 1.0.0
4 */
5
6
7jQuery(function($) {
8    'use strict';
9    $(document).ready(function() {
10
11        var notice_timeout = 2000; //In mili second
12        if(WPT_DATA.notice_timeout){
13            notice_timeout = WPT_DATA.notice_timeout;
14        }
15        
16        if(typeof $('.wpt-wrap .search_select').select2 === 'function' && $('.wpt-wrap .search_select').length > 0 && WPT_DATA.select2 !== 'disable' ){
17            var select2Object = {};
18            var multiple = $('.wpt-wrap .search_select').attr('multiple');
19            if( WPT_DATA.search_select_placeholder !== '' && multiple == 'multiple' ){
20                select2Object = {
21                    placeholder: WPT_DATA.search_select_placeholder,
22                    allowClear: true,
23                };
24            }
25            
26            $('.wpt-wrap .search_select.query').select2(select2Object);
27
28            // $('select.filter_select').select2();
29            $('.keyword-s-wrapper select').select2();
30
31        }
32        var windowWidth = $(window).width();
33
34        $(window).resize(function() {
35            
36          //to disable Reload based on Screenshize use filter wpto_localize_data
37          if( windowWidth != $(window).width()  && WPT_DATA.resize_loader) {
38            location.reload();
39            return;
40          }
41        });
42        
43        $('.item_inside_cell').each(function(){
44            var style = $(this).attr('style');
45            $(this).children('a').attr('style',style);
46            $(this).attr('style','');
47        });
48        
49        /**
50         * Checking wpt_pro_table_body class available in body tag
51         * 
52         * @since 4.3 we have added this condition. 
53         */
54        if(!$('div.wpt-wrap .wpt-table-tag').hasClass('wpt_product_table')){ //div wpt-wrap 
55            return false; 
56        }        
57        
58            
59        var plugin_url = WPT_DATA.plugin_url;
60        var include_url = WPT_DATA.include_url;
61        var content_url = WPT_DATA.content_url;
62        
63        var ajax_url = WPT_DATA.ajax_url;
64        var site_url = WPT_DATA.site_url;
65        
66        //console.log(WPT_DATA);//Only for Developer
67        if( ajax_url === 'undefined'  ){
68            //console.log( 'WOO PRODUCT TABLE is not Available to this page \nOR:::SORRY!!!!: woocommerce_params is Undefine also ajax_url also undefined. So ajax will not work not. Contact with [email protected]' );
69            return false;
70        }
71
72        
73        $('body').on('click','.wpt_table_pagination.pagination_loading a',function(e){
74            e.preventDefault();
75            return false;
76        });
77        
78                
79        setTimeout(function(){
80			$('.wpt-table-tag.wpt_product_table .wpt-td-tag select').trigger('change');
81		}, 4000);
82        function fixAfterAjaxLoad() {
83            $('.wpt-table-tag.wpt_product_table .wpt-td-tag select').trigger('change');
84            //$.getScript(include_url + "/js/mediaelement/mediaelement-and-player.min.js");
85            $.getScript(include_url + "/js/mediaelement/wp-mediaelement.min.js");
86            $.getScript(plugin_url + "/woocommerce/assets/js/frontend/add-to-cart.js");
87            $.getScript(plugin_url + "/woocommerce/assets/js/frontend/woocommerce.js");
88            $.getScript(plugin_url + "/woocommerce/assets/js/frontend/add-to-cart-variation.min.js");
89        }
90        
91        $(document.body).on('wpt_ajax_loaded',function(){
92            var variableProducts,musicProducts;
93            setTimeout(function(){
94                variableProducts = $('.wpt-tr-tag.product_type_variable').length;
95                musicProducts = $('audio,.wp-audio-shortcode').length;
96                if(variableProducts > 0){
97                    // $.getScript(include_url + "/js/mediaelement/wp-mediaelement.min.js");
98                    // $.getScript(plugin_url + "/woocommerce/assets/js/frontend/add-to-cart.js");
99                    // $.getScript(plugin_url + "/woocommerce/assets/js/frontend/woocommerce.js");
100                    $.getScript(plugin_url + "/woocommerce/assets/js/frontend/add-to-cart-variation.min.js");
101                }
102                if(musicProducts > 0){
103                    
104                    $.getScript(include_url + "/js/mediaelement/wp-mediaelement.min.js");
105                    $( window.wp.mediaelement.initialize );
106                }
107            },100);
108
109        });
110    
111    
112        /**
113         * Getting object for config_json from #wpt_table table.
114         * Can be any table. because all table will be same config json data
115         * 
116         * @returns {Objectt}
117         */        
118        var config_json = $('#wpt_table').data('config_json');
119        if ( typeof config_json === 'undefined' ){
120            return false;
121        }
122        /**
123         * Config Generate part
124         * Mainly getting config_json value based on table id. To get new value if available in inside any function, Use like following
125         * config_json = getConfig_json( temp_number );
126         * 
127         * @param {type} temp_number Table ID
128         * @returns {Objectt} Json Object, Mainly getting config_json value based on table id.
129         */
130        function getConfig_json( temp_number ){
131           var temp_cjson = $('div#table_id_' + temp_number + ' #wpt_table').data('config_json');
132           if ( typeof temp_cjson === 'undefined' ){
133                temp_cjson = config_json;
134            }
135            return temp_cjson;
136        }
137
138        var footer_cart = config_json.footer_cart;
139        var footer_cart_size = config_json.footer_cart_size;
140        var footer_possition = config_json.footer_possition;
141        var footer_bg_color = config_json.footer_bg_color;
142        //Adding Noticeboard and Footer CartBox Div tag at the bottom of page
143        $('body').append("<div class='wpt_notice_board'></div>");
144        $('body').append('<div style="height: ' + footer_cart_size + 'px;width: ' + footer_cart_size + 'px;" class="wpt-footer-cart-wrapper '+ footer_possition +' '+ footer_cart +'"><a target="_blank" href="#" class="wpt-footer-cart-wrapper-sssss"></a></div>');
145        
146        /**
147         * NoticeBoard Notice
148         * To get/collect Notice after click on add to cart button 
149         * or after click on 
150         * 
151         * @returns {undefined}
152         */
153        function WPT_NoticeBoard(){
154            
155            var noticeBoard = $('div.wpt_notice_board');
156            $.ajax({
157                type: 'POST',
158                url: ajax_url,
159                data: {
160                    action: 'wpt_print_notice'
161                },
162                success: function(response){
163                    if( config_json.popup_notice !== '1' || config_json.popup_notice == 'no' ) return;
164                    var eachNoticeInnter = $(response);
165                    eachNoticeInnter.css('display','none');
166                    if(response !== ''){
167                        noticeBoard.append(eachNoticeInnter);
168                        eachNoticeInnter.fadeIn();  
169                        setTimeout(function(){
170                            eachNoticeInnter.fadeOut('medium');
171                            eachNoticeInnter.remove(); 
172                        },notice_timeout); //Detault 3000
173                    }
174                },
175                error: function(){
176                    console.log("Unable to load Notice");
177                    return false;
178                }
179            });
180            
181        }
182        
183        $('body').on('click','div.wpt_notice_board>div',function(){
184            $(this).fadeOut('medium');
185        });
186        
187        /**
188         * Auto Checked checkbox Trigger 
189         */
190        $('div.wpt_checked_table').each(function(){
191            var temp_number = $(this).data('temp_number');
192            $('div.wpt_checked_table .all_check_header input.wpt_check_universal.wpt_check_universal_header').trigger('click');
193            $('div.wpt_checked_table th input.wpt_check_universal').trigger('click');
194            $('body.wpt_table_body .wpt-wrap input.enabled.wpt_tabel_checkbox.wpt_td_checkbox').trigger('click');
195            updateCheckBoxCount(temp_number);//
196
197        });
198        function WPT_MiniCart(){
199
200        }
201        
202        
203        //wc_fragments_refreshed,wc_fragments_refresh,wc_fragment_refresh,removed_from_cart
204        $( document.body ).trigger( 'updated_cart_totals' );
205        $( document.body ).trigger( 'wc_fragments_refreshed' );
206        $( document.body ).trigger( 'wc_fragments_refresh' );
207        $( document.body ).trigger( 'wc_fragment_refresh' );
208
209        WPT_MiniCart();
210        
211        //if(config_json.thumbs_lightbox === '1' || config_json.thumbs_lightbox === 1){
212        /**
213         * Popup Image 
214         */
215        $('body').on('click', '.wpt-wrap .wpt_thumbnails_popup img', function() {
216            
217            // return;
218            var thisImg = $(this);
219            var image_width, final_image_url, variation_id,imgSize;
220            //For vatiation management
221            variation_id = $(this).attr('data-variation_id');
222
223            if('undefined' !== typeof variation_id){
224
225                var data_objec = $(this).closest('.wpt-tr-tag.wpt-row').data('product_variations');
226                var finalImgObject,fullObject;
227                
228                $.each(data_objec,function(index,eachObj){
229                    if( variation_id == eachObj['variation_id'] ){
230                        fullObject = eachObj;
231                        finalImgObject = eachObj['image'];
232                    }
233                    
234                });
235
236                if('undefined' !== typeof finalImgObject){
237                    final_image_url = finalImgObject.full_src;
238                    image_width = finalImgObject.full_src_w;
239                    IMG_Generator(thisImg,final_image_url, image_width);
240                }
241
242            }else{
243                image_width = $(this).parent().data('width');
244                final_image_url = $(this).parent().data('url');
245                IMG_Generator(thisImg,final_image_url, image_width);
246            }
247
248
249        });
250
251        /**
252         * Image Generator for Variation product based on Variation ID
253         * Variation Wise Image Generator
254         * Added at 4.0.20
255         * 
256         * @param {type} thisImg Getting Current Image Event
257         * @param {type} final_image_url 
258         * @param {type} image_width
259         * @returns {undefined}
260         */
261        function IMG_Generator(thisImg,final_image_url, image_width){
262
263            var image_height, product_title,placeholder_image,wrapper_style;
264
265            image_height = 'auto';
266
267            if('undefined' === typeof final_image_url){
268                placeholder_image = $(thisImg).attr('src');
269                console.log("No Thumbnail Image found");
270                final_image_url = placeholder_image;//Set final image size to place holder image when not found
271                wrapper_style = '';//Default blank value for style of wrapper, when not found any image
272            }else{
273                //Setting style of height width
274                wrapper_style = "style='width: " + image_width + "px; height:" + image_height + "px'";
275            }
276            product_title = $(thisImg).closest('.wpt-tr-tag.wpt-row').find('.wpt_product_title_in_td').text();
277            if(!product_title){
278                product_title = '';
279            }
280            var html = '<div id="wpt_thumbs_popup" class="wpt_thumbs_popup"><div class="wpt_popup_image_wrapper" ' + wrapper_style + '><span title="Close" id="wpt_popup_close">&times;</span><h2 class="wpt_wrapper_title">' + product_title + '</h2><div class="wpt_thums_inside">';
281            html += '<img class="wpt_popup_image" src="' + final_image_url + '">';
282
283            html += '</div></div></div>';
284            if ($('body').append(html)) {
285                var PopUp = $('.wpt_thumbs_popup, #wpt_thumbs_popup');
286                PopUp.fadeIn('slow');
287                var Wrapper = $('div.wpt_popup_image_wrapper');
288                Wrapper.fadeIn();
289            }
290        }
291
292        $('body').on('click', '.wpt_popup_image_wrapper', function() {
293            return false;
294
295        });
296        $('body').on('click', '#wpt_thumbs_popup span#wpt_popup_close, #wpt_thumbs_popup', function() {
297            $('#wpt_thumbs_popup').fadeOut(function(){
298                $(this).remove();
299            });
300
301        });
302        //}
303
304        $('body').on('click','a.button.wpt_woo_add_cart_button.outofstock_add_to_cart_button.disabled',function(e){
305            e.preventDefault();
306            var temp_number = $(this).closest( '.wpt_action' ).data('temp_number');
307            config_json = getConfig_json( temp_number );
308            showAlert(config_json.sorry_out_of_stock);
309            return false;
310        });
311        
312        
313        function footerCartAnimation(){
314            $('a.wpt-view-n .wpt-bag').addClass('wpt-spin4 animate-spin');
315            $('.wpt-new-footer-cart').addClass('wpt-fcart-anim');
316            $('.wpt-fcart-coll-expand').addClass('animated');
317        }
318        function footerCartAnimationStop(){
319            $('a.wpt-view-n .wpt-bag').removeClass('wpt-spin4 animate-spin');
320            $('.wpt-new-footer-cart').removeClass('wpt-fcart-anim');
321            $('.wpt-fcart-coll-expand').removeClass('animated');
322        }
323
324        /**
325         * Add to cart button Action 
326         * for Ajax add to cart
327         * for Variation product
328         */
329        $(document.body).on('click', 'a.ajax_active.wpt_variation_product.single_add_to_cart_button.button.enabled, a.add_to_cart_button.ajax_add_to_cart, a.ajax_active.add_to_cart_button.wpt_woo_add_cart_button', function(e) {
330            
331            e.preventDefault();
332            
333            var thisButton = $(this);
334
335            if(thisButton.hasClass('disabled')){
336                return;
337            }
338
339            //Adding disable and Loading class
340            thisButton.addClass('disabled');
341            // thisButton.addClass('loading');
342            
343            var data = {};
344            $.each( thisButton.data(), function( key, value ) {
345                    data[ key ] = value;
346            });
347
348            // Trigger event.
349            $( document ).trigger( 'adding_to_cart', [ thisButton, data ] );
350            
351            
352            var thisRow = $(this).closest('.wpt_row');
353            var messageBox = thisRow.find('.wpt_custom_message');
354            var product_id = thisRow.data('product_id');
355
356            var temp_number = $(this).closest('#product_id_' + product_id).data('temp_number');
357            config_json = getConfig_json( temp_number ); //Added at V5.0
358            var qtyElement = $('#table_id_' + temp_number + ' #product_id_' + product_id + ' input.input-text.qty.text');
359            var min_quantity = qtyElement.attr('min');//.val();
360            
361            if( typeof min_quantity === 'undefined' && !WPT_DATA.return_zero ){
362                min_quantity = 1;
363            }
364            if(WPT_DATA.return_zero === '1'){
365                min_quantity = 0;
366            }
367            //For Direct Checkout page and Quick Button Features
368            var checkoutURL = WPT_DATA.checkout_url;//$('#table_id_' + temp_number).data('checkout_url');
369
370            //For Direct cart page and Quick Button Features
371            var cartURL = WPT_DATA.cart_url;//$('#table_id_' + temp_number).data('cart_url');
372
373            //Changed at2.9
374            var quantity = $(this).attr('data-quantity');
375            var wpt_custom_message = $('#table_id_' + temp_number + ' #wpt_table.wpt-table-tag .wpt_row_product_id_' + product_id + ' .wpt_message .message').val();
376            var variation_id = $(this).attr('data-variation_id');
377            var variation = $(this).attr('data-variation');
378            if(variation){
379                variation = JSON.parse(variation);
380            }
381            if(! quantity || quantity === '0'){
382                thisButton.removeClass('disabled');
383                alert("Sorry! 0 Quantity");
384                
385                return;
386            }
387            footerCartAnimation();
388            var Bubble = thisRow.find('.wpt_ccount');
389            if(Bubble.length == 0){
390                thisRow.find('a.add_to_cart_button').append('<span class="wpt_ccount wpt_ccount_' + product_id + '"><i class="wpt-spin5 animate-spin"></span>');
391            }else{
392                Bubble.html('<i class="wpt-spin5 animate-spin">');
393            }
394            var get_data = $(this).attr('href') + '&quantity=' + quantity;
395            
396            var additional_json = $('#table_id_' + temp_number + ' #wpt_table.wpt-table-tag .wpt-tr-tag.wpt_row_product_id_' + product_id).attr('additional_json');
397
398            var data = {
399                action:     'wpt_ajax_add_to_cart',
400                variation:  variation, 
401                variation_id:   variation_id,
402                product_id: product_id,
403                quantity:   quantity,
404                wpt_custom_message: wpt_custom_message,
405                additional_json: additional_json,
406            };
407
408            $.ajax({
409                type: 'POST',
410                url: ajax_url,// + get_data,
411                data: data,
412                complete: function(){
413                    $( document ).trigger( 'wc_fragment_refresh' );
414                    $( document ).trigger( 'cart_page_refreshed' );
415                    $( document ).trigger( 'cart_totals_refreshed' );
416                    $( document ).trigger( 'wc_fragments_refreshed' );
417                    $('.wpt_row_product_id_' + product_id + ' .input-text').trigger('change');
418
419                    //It's need to update checkout page Since 3.3.3.1
420                    $( document.body ).trigger( 'update_checkout' );
421                },
422                success: function(response) {
423                    // $('.wpt_edit_table').html(response); return;
424                    thisButton.removeClass('disabled');
425                    
426                    thisButton.addClass('added');
427                    messageBox.val('');
428                    /**
429                     * Adding Trigger for WPT
430                     * At the Beggining of Success Adding to cart
431                     * 
432                     * Already Added to cart Successfully. It's just for front-end Version
433                     * 
434                     * @type type
435                     */
436                    var argStats = {};
437                    argStats['status'] = true;
438                    argStats['product_id'] = product_id;
439                    argStats['variation_id'] = variation_id;
440                    argStats['variation'] = variation;
441                    argStats['temp_number'] = temp_number;
442                    argStats['table_id'] = temp_number;
443                    $(document.body).trigger('wpt_adding_to_cart',argStats);
444
445
446                    $( document.body ).trigger( 'updated_cart_totals' );
447                    $( document.body ).trigger( 'wc_fragments_refreshed' );
448                    $( document.body ).trigger( 'wc_fragments_refresh' );
449                    $( document.body ).trigger( 'wc_fragment_refresh' );
450                    $( document.body ).trigger( 'added_to_cart' ); //Trigger and sent added_to_cart event
451                    
452                    /**
453                     * If anyone want that Quantity will not return to min qty,
454                     * Then use following filter
455                     * add_filter( 'wpto_qty_return_quanity', '__return_false' );
456                     */
457                    if(WPT_DATA.return_quanity){
458                        qtyElement.val(min_quantity);
459                        thisButton.attr('data-quantity',min_quantity);
460                    }
461                    
462                    WPT_NoticeBoard();
463
464                    //Quick Button Active here and it will go Directly to checkout Page
465                    if(config_json.product_direct_checkout === 'yes'){
466                        window.location.href = checkoutURL;
467                    }
468                    //Quick cart Button Active here and it will go Directly to cart Page
469                    if(config_json.product_direct_checkout === 'cart'){
470                        window.location.href = cartURL;
471                    }
472                    
473                    /**
474                     * After Completely added to cart and after change of front-end change
475                     * 
476                     * User able to do anything by using following even
477                     */
478                    var argStats = {};
479                    argStats['status'] = true;
480                    argStats['product_id'] = product_id;
481                    argStats['variation_id'] = variation_id;
482                    argStats['variation'] = variation;
483                    argStats['temp_number'] = temp_number;
484                    argStats['table_id'] = temp_number;
485                    $(document.body).trigger('wpt_added_to_cart',argStats);
486                },
487                error: function() {
488                    alert('Failed - Unable to add by ajax');
489                },
490            });
491        });
492
493        function showAlert(alertMessage){
494            if(typeof alertMessage == 'string'){
495                var tempMsg = alertMessage.trim();
496                if(tempMsg.length !== 0){
497                    // alert(alertMessage);
498                    WPTControl.showNotification(alertMessage, 'error', 'top_right', 4000);
499                }
500            }else{
501                let errMsgErr = "You have inserted " + typeof alertMessage + " Variable. But should be a String.";
502                WPTControl.showNotification(errMsgErr, 'error', 'top_right', 2000);
503                console.log(errMsgErr);
504            }
505        }
506        $('body').on('click', 'a.wpt_variation_product.single_add_to_cart_button.button.disabled,a.disabled.yith_add_to_quote_request.button', function(e) {
507            e.preventDefault();
508            var temp_number = $(this).closest( '.wpt_action' ).data('temp_number');
509            config_json = getConfig_json( temp_number );
510            showAlert(config_json.no_right_combination);
511            return false;
512            
513        });
514        //Alert of out of stock 
515
516        $('body').on('click', 'a.wpt_woo_add_cart_button.button.disabled.loading,a.disabled.yith_add_to_quote_request.button.loading', function(e) {
517            e.preventDefault();
518            var temp_number = $(this).closest( '.wpt_action' ).data('temp_number');
519            config_json = getConfig_json( temp_number ); //Added vat V5.0
520            showAlert(config_json.adding_in_progress);
521            return false;
522
523        });
524        
525        /**
526         * On change Product Variation
527         * Vairation Change
528         */
529        $(document.body).on('change','.wpt_varition_section',function() {
530            
531            var product_id = $(this).data('product_id');
532            var temp_number = $(this).data('temp_number');
533            config_json = getConfig_json( temp_number ); //Added vat V5.0
534            var target_class = '#product_id_' + product_id;
535            
536            //Added at Version2.6 for Quote Request Button
537            var quoted_target = 'yith_request_temp_' + temp_number + '_id_' + product_id;
538            //Please choose right combination.//Message
539            var targetRightCombinationMsg = config_json.right_combination_message;
540            var selectAllItemMessage = config_json.select_all_items_message;
541            var outOfStockMessage = config_json.out_of_stock_message;
542            
543
544            /**
545             * Finally targetPriceSelectorTd has removed becuase we have creaed a new function
546             * for targetting any TD of selected Table.
547             * This function is targetTD(td_name)
548             * @type @call;$
549             */
550            var targetThumbs = $('#table_id_' + temp_number + ' #product_id_' + product_id + ' .wpt_thumbnails img'); //wpt_thumbnail_common will add after get
551            var targetThumbsTd = $('#table_id_' + temp_number + ' #product_id_' + product_id + ' .wpt_thumbnails'); //wpt_thumbnail_common will add after get
552            
553            var htmlStored = targetThumbsTd.attr('data-html_stored');
554            var targetThumbsText,targetThumbsTextSRCSET;
555            if(htmlStored !== 'added'){
556               targetThumbsText = targetThumbs.attr('src'); //Added at 4.0.21 
557               targetThumbsTextSRCSET = targetThumbs.attr('srcset'); //Added at 4.0.21 
558               targetThumbsTd.attr('data-html',targetThumbsText);
559               targetThumbsTd.attr('data-html_srcset',targetThumbsTextSRCSET);
560            }
561            targetThumbsTd.attr('data-html_stored','added');
562            var targetThumbsSRC = targetThumbsTd.attr('data-html');
563            var targetThumbsSRCSET = targetThumbsTd.attr('data-html_srcset');
564            
565            var variations_data = $(this).closest(target_class).data('product_variations');
566            var messageSelector = $(this).children('div.wpt_message');
567            var addToCartSelector = $('#table_id_' + temp_number + ' #product_id_' + product_id + ' a.wpt_variation_product.single_add_to_cart_button');
568            
569            var rowSelector = $('#table_id_' + temp_number + ' #product_id_' + product_id);
570            var addToQuoteSelector = $('.' + quoted_target);
571            
572            //Checkbox Selector
573            var checkBoxSelector = $('.wpt_check_temp_' + temp_number + '_pr_' + product_id); 
574            var autoCheckBoxObj = $('div.wpt_checked_table input.wpt_check_temp_' + temp_number + '_pr_' + product_id );
575            
576            /**
577             * Targetting Indivisual TD Element from Targeted Table. Our Targeted Table will come by temp_number
578             * As we have used temp_number and product_id in inside function, So this function obvisoulsy shoud
579             * declear after to these variable.
580             * 
581             * @param {String} td_name Actually it will be column names keyword. Suppose, we want to rarget .wpt_price td, than we will use only price as perameter.
582             * @returns {$}
583             */
584            function targetTD(td_name) {
585                var targetElement = $('#table_id_' + temp_number + ' #product_id_' + product_id + ' .wpt_' + td_name);
586                return targetElement;
587            }
588            
589            /**
590             * Set Variations value to the targetted column's td
591             * 
592             * @param {type} target_td_name suppose: weight,description,serial_number,thumbnails etc
593             * @param {type} gotten_value Suppose: variations description from targatted Object
594             * @returns {undefined}
595             */
596            function setValueToTargetTD_IfAvailable(target_td_name, gotten_value){
597                if (gotten_value !== "") {
598                    targetTD(target_td_name).html(gotten_value);
599                }
600            }
601            
602            /**
603             * set value for without condition
604             * 
605             * @param {type} target_td_name for any td
606             * @param {type} gotten_value Any valy
607             * @returns {undefined}
608             */
609            function setValueToTargetTD(target_td_name, gotten_value){
610                targetTD(target_td_name).html(gotten_value);
611            }
612            /**
613             * 
614             * @param {type} target_td_name suppose: weight,description,serial_number,thumbnails etc
615             * @param {type} datas_name getting data value from data-something attribute. example: <td data-product_description='This is sample'> s</td>
616             * @returns {undefined}
617             */
618            function getValueFromOldTD(target_td_name, datas_name){
619                //Getting back Old Product Description from data-product_description attribute, which is set 
620                var product_descrition_old = targetTD(target_td_name).data(datas_name);
621                targetTD(target_td_name).html(product_descrition_old);
622            }
623
624            var current = {};
625            var additionalAddToCartUrl = '';
626            //Defining No Ajax Action for when put href to variation product's add to cart button
627            
628
629            var quote_data = '';
630            $(this).find('select').each(function() {
631                var attribute_name = $(this).data('attribute_name');
632                var attribute_value = $(this).val();
633                current[attribute_name] = attribute_value;
634                additionalAddToCartUrl += '&' + attribute_name + '=' + attribute_value;
635            });
636            
637            //If not found variations Data, if not set properly
638            if($.isEmptyObject(variations_data)){
639                targetRightCombinationMsg = config_json.right_combination_message_alt;//"Product variations is not set Properly. May be: price is not inputted. may be: Out of Stock.";
640            }
641
642            var targetVariationIndex = 'not_found';
643            var selectAllItem = true;
644            try{
645                variations_data.forEach(function(attributesObject, objectNumber) {
646                    $.each(current,function(key,value){
647                        if(value === "0"){
648                            selectAllItem = false;
649                        }
650                    });
651                    var total_right_combination=0, total_combinationable=0;
652                    if(selectAllItem){
653                        $.each(attributesObject.attributes,function(key,value){
654                            if(value === "" || value === current[key]){
655                                total_right_combination++;
656                            }
657                            total_combinationable++;
658                        });
659                        if(total_right_combination === total_combinationable){
660                            targetVariationIndex = parseInt(objectNumber);
661
662                        }
663
664                    }else{
665                        targetRightCombinationMsg = selectAllItemMessage; //"Please select all Items.";
666                    }
667
668                });
669
670                
671            }catch(e){
672                //e.getMessage();
673            }
674            
675            var price_markup_backup = targetTD('price').attr('data-price_markup');
676            if( ! price_markup_backup ){
677                var targetPriceHTML = targetTD('price').find('span').prop('innerHTML');
678                targetTD('price').attr('data-price_markup', targetPriceHTML);
679            }
680
681            var wptMessageText = false;
682            if (targetVariationIndex !== 'not_found') {
683                var targetAttributeObject = variations_data[targetVariationIndex];
684                additionalAddToCartUrl += '&variation_id=' + targetAttributeObject.variation_id;
685                quote_data = additionalAddToCartUrl;
686                //Link Adding
687                additionalAddToCartUrl = addToCartSelector.data('add_to_cart_url') + additionalAddToCartUrl;
688                addToCartSelector.attr('href', additionalAddToCartUrl);
689
690                //Class adding/Removing to add to cart button
691                if (targetAttributeObject.is_in_stock) {
692                    disbale_enable_class();
693                } else {
694                    targetRightCombinationMsg = outOfStockMessage; //"Out of Stock";
695                    enable_disable_class();
696                }
697
698                //Set variation Array to addToCart Button
699                addToCartSelector.attr('data-variation', JSON.stringify(current)); //current_object //targetAttributeObject.attributes //It was before 2.8 now we will use 'current' object whic will come based on current_selection of variations
700                addToCartSelector.attr('data-variation_id', targetAttributeObject.variation_id);
701                
702
703                rowSelector.attr('data-variation', JSON.stringify(current)); //current_object //targetAttributeObject.attributes //It was before 2.8 now we will use 'current' object whic will come based on current_selection of variations
704                rowSelector.attr('data-variation_id', targetAttributeObject.variation_id);
705                
706                /**
707                 * For add to Queto Button
708                 * @since 2.6
709                 * @date 20.7.2018
710                 */
711                addToQuoteSelector.attr('data-variation', JSON.stringify(current)); //targetAttributeObject.attributes //It was before 2.8 now we will use 'current' object whic will come based on current_selection of variations
712                addToQuoteSelector.attr('data-variation_id', targetAttributeObject.variation_id);
713                addToQuoteSelector.attr('data-quote_data', quote_data);
714                
715                /*
716                //Set stock Message
717                if (targetAttributeObject.availability_html === "") {
718                    wptMessageText = '<p class="stock in-stock">' + config_json.table_in_stock + '</p>';
719                } else {
720                    wptMessageText = targetAttributeObject.availability_html;
721                }
722                */
723                wptMessageText = targetAttributeObject.availability_html;
724                //Setup Price Live
725                setValueToTargetTD_IfAvailable('price', targetAttributeObject.price_html);
726                
727                //Set Image Live for Thumbs
728                targetThumbs.attr('src', targetAttributeObject.image.gallery_thumbnail_src);
729                if(targetAttributeObject.image.srcset && 'false' !== targetAttributeObject.image.srcset) {
730                    targetThumbs.attr('srcset', targetAttributeObject.image.srcset);
731                };
732
733                //Set SKU live based on Variations
734                setValueToTargetTD_IfAvailable('sku', targetAttributeObject.sku);
735                
736                // Set live stock status based onChange variation
737                setValueToTargetTD_IfAvailable('stock', targetAttributeObject.availability_html);
738                
739                //Set Total Price display_price
740                var targetQty = $('#table_id_' + temp_number + ' #product_id_' + product_id + ' input.input-text.qty.text').val();
741                if(!targetQty){
742                    targetQty = 1;
743                }
744                var targetCurrency = targetTD('total_item').data('currency');
745                var targetPriceDecimalSeparator = targetTD('total_item').data('price_decimal_separator');
746                var targetPriceThousandlSeparator = targetTD('total_item').data('thousand_separator');
747                var targetNumbersPoint = targetTD('total_item').data('number_of_decimal');
748                var totalPrice = parseFloat(targetQty) * parseFloat(targetAttributeObject.display_price);
749                totalPrice = totalPrice.toFixed(targetNumbersPoint);
750
751                var priceFormat = WPT_DATA.priceFormat;
752                
753                var newPrice;
754
755                switch (priceFormat) {
756                    case 'left': // left
757                        //newPrice = targetCurrency + totalPrice.replace(".",targetPriceDecimalSeparator);
758                        newPrice = targetCurrency+ (totalPrice + '').replace(/\B(?=(?:\d{3})+\b)/g, targetPriceThousandlSeparator);
759                        break;
760                    case 'right': // right
761                        //newPrice = totalPrice.replace(".",targetPriceDecimalSeparator) + targetCurrency;
762                        newPrice = (totalPrice + '').replace(/\B(?=(?:\d{3})+\b)/g, targetPriceThousandlSeparator) + targetCurrency;
763                        break;
764                    case 'left-space': // left with space
765                        //newPrice = targetCurrency + ' ' + totalPrice.replace(".",targetPriceDecimalSeparator);
766                        newPrice = targetCurrency + ' ' +  (totalPrice + '').replace(/\B(?=(?:\d{3})+\b)/g, targetPriceThousandlSeparator);
767                        break;
768                    case 'right-space': // right with space
769                        //newPrice = totalPrice.replace(".",targetPriceDecimalSeparator) + ' ' + targetCurrency;
770                        newPrice =  (totalPrice + '').replace(/\B(?=(?:\d{3})+\b)/g, targetPriceThousandlSeparator) + ' ' + targetCurrency;
771                        break;
772                }
773
774                var totalPriceHtml = '<strong>' + newPrice + '</strong>';
775
776                setValueToTargetTD_IfAvailable('total_item',totalPriceHtml);
777                targetTD('total').attr('data-price', targetAttributeObject.display_price);
778                targetTD('total').addClass('total_general');
779                
780                //Set Description live based on Varitions's Description
781                
782                setValueToTargetTD_IfAvailable('description', targetAttributeObject.variation_description);
783
784                var finalWeightVal = targetAttributeObject.weight * targetQty;
785                finalWeightVal = finalWeightVal.toFixed(2);
786                if(finalWeightVal === 'NaN'){
787                    finalWeightVal = '';
788                }
789               targetTD('weight').attr('data-weight',targetAttributeObject.weight);
790                //Set Weight,Height,Lenght,Width
791                setValueToTargetTD_IfAvailable('weight', finalWeightVal);
792                setValueToTargetTD_IfAvailable('height', targetAttributeObject.dimensions.height);
793                setValueToTargetTD_IfAvailable('length', targetAttributeObject.dimensions.length);
794                setValueToTargetTD_IfAvailable('width', targetAttributeObject.dimensions.width);
795                
796                //Set Variation ID at Thumbs's td   //Added at 4.0.20
797                targetThumbs.attr('data-variation_id', targetAttributeObject.variation_id);
798                
799                
800                if(!autoCheckBoxObj.is(":checked")){
801                    autoCheckBoxObj.trigger('click');
802                }
803                updateCheckBoxCount(temp_number);
804                
805                //$(window).trigger('wpt_changed_variations');
806                targetAttributeObject['status'] = true;
807                targetAttributeObject['product_id'] = product_id;
808                targetAttributeObject['temp_number'] = temp_number;
809                targetAttributeObject['table_id'] = temp_number;
810                try{
811                    // console.log(targetAttributeObject);
812                    $(document.body).trigger('wpt_changed_variations',targetAttributeObject);
813                }catch(error){
814                    console.log("Variation ID not founded. To see error, Please console.log(error) here.");
815                }
816            } else {
817                //Return to Previous HTML Image
818
819                targetThumbs.attr('src', targetThumbsSRC);
820                targetThumbs.attr('srcset', '');
821                //Unset variation ID data //Added at 4.0.20
822                targetThumbs.removeAttr('data-variation_id');
823                
824                
825                
826                
827                addToCartSelector.attr('data-variation', false);
828                addToCartSelector.attr('data-variation_id', false);
829
830                //New add variation data at row
831                
832                rowSelector.attr('data-variation', false);
833                rowSelector.attr('data-variation_id', false);
834                
835                addToQuoteSelector.attr('data-variation', false);
836                addToQuoteSelector.attr('data-variation_id', false);
837                addToQuoteSelector.attr('data-quote_data', false);
838                
839                
840                wptMessageText = '<p class="wpt_warning warning">' + targetRightCombinationMsg + '</p>'; //Please choose right combination. //Message will come from targatted tables data attribute //Mainly for WPML issues
841
842
843                //Class adding/Removing to add to cart button
844                enable_disable_class();
845
846                //Reset Price Data from old Price, what was First time
847                targetPriceHTML = targetTD('price').attr('data-price_markup');
848                targetTD('price').html(targetPriceHTML);
849
850                getValueFromOldTD('sku', 'sku');
851                setValueToTargetTD('total_item', '');
852                targetTD('total_item').attr('data-price', '');
853                targetTD('total_item').removeClass('total_general');
854
855                //Getting back Old Product Description from data-product_description attribute, which is set 
856                getValueFromOldTD('description', 'product_description');
857
858                var oldBackupWeight = targetTD('weight').attr('data-weight_backup');
859                targetTD('weight').attr('data-weight',oldBackupWeight);
860                var oldWeightVal = oldBackupWeight * targetQty;
861                //Getting Back Old Weight,Lenght,Width,Height
862                setValueToTargetTD_IfAvailable('weight', oldWeightVal);
863                getValueFromOldTD('length', 'length');
864                getValueFromOldTD('width', 'width');
865                getValueFromOldTD('height', 'height');
866                
867                if(autoCheckBoxObj.is(":checked")){
868                    autoCheckBoxObj.prop("checked", false);;
869                }
870                updateCheckBoxCount(temp_number);
871                
872                var argStats= {};
873                argStats['status'] = false;
874                argStats['product_id'] = product_id;
875                argStats['temp_number'] = temp_number;
876                argStats['table_id'] = temp_number;
877                $(document.body).trigger('wpt_changed_variations',argStats);
878            }
879            //Set HTML Message to define div/box
880            messageSelector.html(wptMessageText);
881            
882            function enable_disable_class() {
883                addToCartSelector.removeClass('enabled');
884                addToCartSelector.addClass('disabled');
885                
886                rowSelector.removeClass('enabled');
887                rowSelector.addClass('disabled');
888                
889                /**
890                 * For Add to Quote
891                 */
892                addToQuoteSelector.removeClass('enabled');
893                addToQuoteSelector.addClass('disabled');
894                
895                checkBoxSelector.removeClass('enabled');
896                checkBoxSelector.addClass('disabled');
897
898            }
899            function disbale_enable_class() {
900                addToCartSelector.removeClass('disabled');
901                addToCartSelector.addClass('enabled');
902                
903                rowSelector.removeClass('disabled');
904                rowSelector.addClass('enabled');
905                
906                /**
907                 * For Add To Quote
908                 */
909                addToQuoteSelector.removeClass('disabled');
910                addToQuoteSelector.addClass('enabled');
911
912                checkBoxSelector.removeClass('disabled');
913                checkBoxSelector.addClass('enabled');
914            }
915            
916        });
917        
918        $('.wpt_varition_section').each(function(){
919            var current_value = $(this).children('select').val();
920            if(current_value !== '0'){
921                $(this).trigger('change');
922            }
923        });
924
925        /**
926         * Working for Checkbox of our Table
927         */
928        $('body').on('click', 'input.wpt_tabel_checkbox.wpt_td_checkbox.disabled', function(e) {
929            e.preventDefault();
930            var temp_number = $(this).data('temp_number');
931            config_json = getConfig_json( temp_number ); //Added vat V5.0
932            showAlert(config_json.sorry_plz_right_combination);
933            return false;
934        });
935
936        /**
937         * Add to cart All selected
938         * all selected product add to cart from here
939         */
940        $('div.normal_table_wrapper a.button.add_to_cart_all_selected').click(function() {
941            footerCartAnimation();
942            var temp_number = $(this).data('temp_number');
943            var allMessageBox = $('#table_id_' + temp_number + ' .wpt_custom_message');
944            config_json = getConfig_json( temp_number ); 
945            var checkoutURL = WPT_DATA.checkout_url;
946            var cartURL = WPT_DATA.cart_url;
947            //Add Looading and Disable class 
948            var currentAllSelectedButtonSelector = $('#table_id_' + temp_number + ' a.button.add_to_cart_all_selected');
949            var tableWrapperTag = $('#table_id_' + temp_number + ' .wpt_table_tag_wrapper');
950            
951            currentAllSelectedButtonSelector.addClass('disabled');
952            currentAllSelectedButtonSelector.addClass('loading');
953            tableWrapperTag.addClass('wpt-ajax-loading');
954
955            var add_cart_text = $('#table_id_' + temp_number).data('basic_settings').add_to_cart;
956
957            //Getting Data from all selected checkbox
958            var products_data = {};
959            var itemAmount = 0;
960            
961            $('#table_id_' + temp_number + ' input.enabled.wpt_tabel_checkbox.wpt_td_checkbox:checked').each(function() {
962                var thisRow = $(this).closest('.wpt-tr-tag');
963                var product_id = $(this).data('product_id');
964                var thisButton = thisRow.find('.wpt_action a.button.wpt_woo_add_cart_button');
965                thisButton.removeClass('added');
966                thisButton.addClass( 'disabled' );
967                thisButton.addClass( 'loading' );
968                
969                // Find quantity element relative to the row
970                var qtyElement = thisRow.find('input.qty, input[name="quantity"]');
971                var min_quantity = qtyElement.attr('min');
972                if(min_quantity === '0' || typeof min_quantity === 'undefined'){
973                    min_quantity = 1;
974                }
975                
976                var currentAddToCartSelector = thisRow.find('.wpt_action a.wpt_woo_add_cart_button');
977                var currentCustomMessage = thisRow.find('.wpt_message .message').val();
978                var additional_json = thisRow.attr('additional_json');
979                var currentVariaionId = thisRow.attr('data-variation_id');
980
981                var currentVariaion;
982                try{
983                        currentVariaion = $.parseJSON(thisRow.attr('data-variation'));
984                }catch(e){
985                        //Get error message
986                }
987
988                // Read quantity directly from the quantity input field inside thisRow
989                var currentQantity;
990                if(qtyElement.length > 0){
991                    currentQantity = parseFloat(qtyElement.val());
992                    // Sync data-quantity on the row
993                    thisRow.attr('data-quantity', currentQantity);
994                }else{
995                    currentQantity = parseFloat(thisRow.attr('data-quantity'));
996                }
997                if( isNaN(currentQantity) || currentQantity <= 0 ){
998                    currentQantity = 1;
999                }
1000                products_data[product_id] = {
1001                    product_id: product_id, 
1002                    quantity: currentQantity, 
1003                    variation_id: currentVariaionId, 
1004                    variation: currentVariaion,
1005                    wpt_custom_message: currentCustomMessage,
1006                    additional_json:additional_json
1007                };
1008                var items = currentQantity;
1009                items = parseFloat(items);
1010                if(items <= 0){
1011                    return;
1012                }
1013                
1014                var itemCountSystem = config_json.item_count;
1015                if(typeof itemCountSystem !== 'undefined' && itemCountSystem === 'all'){
1016                    itemAmount += items;
1017                }else{
1018                    itemAmount++;//To get Item Amount
1019                } 
1020
1021            });
1022
1023            //Return false for if no data
1024            if (itemAmount < 1) {
1025                currentAllSelectedButtonSelector.removeClass('disabled');
1026                currentAllSelectedButtonSelector.removeClass('loading');
1027                tableWrapperTag.removeClass('wpt-ajax-loading');
1028                footerCartAnimationStop();
1029                showAlert(config_json.please_choose_items);
1030                return false;
1031            }
1032
1033            uncheckAllCheck(temp_number);
1034            currentAllSelectedButtonSelector.html(add_cart_text + ' [ ' + config_json.loading_more_text + ' ]');
1035            $.ajax({
1036                type: 'POST',
1037                url: ajax_url,
1038                data: {
1039                    action: 'wpt_ajax_mulitple_add_to_cart',
1040                    products: products_data,
1041                },
1042                complete: function(){
1043                    $( document ).trigger( 'wc_fragments_refreshed' );
1044
1045                    //It's need to update checkout page Since 3.3.3.1
1046                    $( document.body ).trigger( 'update_checkout' );
1047                },
1048                success: function( response ) {
1049                    $( document.body ).trigger( 'updated_cart_totals' );
1050                    $( document.body ).trigger( 'wc_fragments_refreshed' );
1051                    $( document.body ).trigger( 'wc_fragments_refresh' );
1052                    $( document.body ).trigger( 'wc_fragment_refresh' );
1053                    currentAllSelectedButtonSelector.html(add_cart_text + ' [ ' + itemAmount + ' ' + config_json.add2cart_all_added_text + ' ]');
1054                    if(config_json.all_selected_direct_checkout === 'yes'){
1055                        window.location.href = checkoutURL;
1056                        return;
1057                    }else if(config_json.all_selected_direct_checkout === 'cart'){
1058                        window.location.href = cartURL;
1059                        return;                       
1060                    }
1061                    
1062                    currentAllSelectedButtonSelector.removeClass('disabled');
1063                    currentAllSelectedButtonSelector.removeClass('loading');
1064                    tableWrapperTag.removeClass('wpt-ajax-loading');
1065                    
1066                    WPT_NoticeBoard();
1067                     
1068                    //Added at v4.0.11
1069                    $('#table_id_' + temp_number + ' input.enabled.wpt_tabel_checkbox.wpt_td_checkbox:checked').each(function() {
1070                        var product_id = $(this).data('product_id');
1071
1072                        var qtyElement,min_quantity;
1073                        qtyElement = $('#table_id_' + temp_number + ' #product_id_' + product_id + ' input.input-text.qty.text');
1074                        min_quantity = qtyElement.attr('min');
1075                        if(min_quantity === '0' || typeof min_quantity === 'undefined'){
1076                            min_quantity = 1;
1077                        }
1078                        qtyElement.val(min_quantity);//Added at v4
1079                        var messageBox = $(this).closest('.wpt-row').find('.wpt_custom_message');
1080                        messageBox.val('');
1081                    });
1082                    
1083                    
1084                    // allMessageBox.val('');
1085                    
1086                },
1087                error: function() {
1088                    alert('Failed');
1089                },
1090            });
1091        });
1092        
1093
1094        $('body').append('<style>div.wpt-footer-cart-wrapper>a:after,div.wpt-footer-cart-wrapper>a{background-color: ' + footer_bg_color + ';}</style>');
1095        
1096        
1097        /**
1098         * Delay One Second Delay
1099         * To cal after some time, need this function
1100         * Althou its name onesecond delay, but default is 500ms delay
1101         * 
1102         * @param {type} f
1103         * @param {type} delay
1104         * @returns {Function} 
1105         */
1106        function oneSecondDelay(f, delay){
1107            var timer = null;
1108            return function(){
1109                var context = this, args = arguments;
1110                clearTimeout(timer);
1111                timer = window.setTimeout(function(){
1112                    f.apply(context, args);
1113                },
1114                delay || 500);
1115            };
1116        }
1117        //Neeeeeeeeeeeeeed Configuration 
1118        $('.query_box_direct_value').keyup(oneSecondDelay(function(){
1119            var thisID = $(this).attr('id');
1120            var temp_number = thisID.replace('single_keyword_','');
1121            $('#wpt_query_search_button_' + temp_number).trigger('click');
1122        }));
1123        $('body').on('change','.search_select',function(){
1124            var thisID = $(this).parents('.wpt-wrap').attr('id');
1125            var temp_number = thisID.replace('table_id_','');
1126           $('#wpt_query_search_button_' + temp_number).trigger('click');
1127        });
1128        $('body').on('change,focus','.query_box_direct_value',function(){
1129            var thisID = $(this).parents('.wpt-wrap').attr('id');
1130            var temp_number = thisID.replace('table_id_','');
1131           $('#wpt_query_search_button_' + temp_number).trigger('click');
1132        });
1133        
1134        $('body').on('change','select.query_box_direct_value',function(){
1135            var thisID = $(this).parents('.wpt-wrap').attr('id');
1136            var temp_number = thisID.replace('table_id_','');
1137           $('#wpt_query_search_button_' + temp_number).trigger('click');
1138        });
1139        
1140
1141        
1142
1143        
1144        
1145        /**
1146         * Link Generator Based On Query String
1147         * 
1148         * @since 2.8.9
1149         * @param {type} table_id
1150         * @returns {undefined}
1151         */
1152        function generate_url_by_search_query( table_id = 0, extra = '' ){
1153            config_json = getConfig_json( table_id ); //Added vat v2.9.3.0
1154            
1155            if(config_json.query_by_url !== '1'){
1156                return;
1157            }
1158            
1159            var key,value;
1160            var link = window.location.origin + window.location.pathname + "?table_ID=" + table_id + "&";
1161            $('.query_box_direct_value').each(function(){
1162                key = $(this).attr('data-key');
1163                if(key === 's'){
1164                    key = 'search_key';
1165                }
1166                value = $(this).val();
1167                if(value !== ''){
1168                    link += key + "=" + value + "&";
1169                }
1170                
1171            });
1172            var page_number = $('#table_id_' + table_id + ' table').attr('data-page_number');
1173            page_number = parseInt( page_number ) - 1;
1174            link += "page_number=" + page_number;
1175            $('a.search_box_reset').show();
1176            link += extra;
1177            window.history.pushState('data', null, link.replace(/(^&)|(&$)/g, ""));
1178        }
1179        
1180
1181        $(document.body).on('wpt_ajax_load_data',function(Event,data){
1182            var table_id = data.table_id;
1183
1184            var page_number = data.others.page_number;
1185            var extra_link_tax_cf = "";
1186
1187            if( typeof data.args.tax_query === 'object' && !$.isEmptyObject(data.args.tax_query)){
1188                extra_link_tax_cf = "&tax=" + convertToSimpleFormat(data.args.tax_query);
1189            }
1190            if( typeof data.args.meta_query === 'object'  && !$.isEmptyObject(data.args.meta_query)){
1191                extra_link_tax_cf = "&meta=" + convertToSimpleFormat(data.args.meta_query);
1192            }
1193
1194            generate_url_by_search_query(table_id, extra_link_tax_cf);
1195
1196            
1197        });
1198
1199        function convertToSimpleFormat(obj) {
1200            const parts = [];
1201
1202            for (const key in obj) {
1203                const terms = obj[key].terms;
1204                if (Array.isArray(terms)) {
1205                    parts.push(`${key}-${terms.join(',')}`);
1206                }else{
1207                    parts.push(`${key}-${terms}`);
1208                }
1209            }
1210
1211            return parts.join('__');
1212        }
1213
1214        
1215        /**
1216         * Handleling Filter Features
1217         */
1218        $('body').on('change','select.filter_select',function(){
1219            var temp_number = $(this).data('temp_number');
1220
1221            /**
1222             * I did it for specially Variable page's variation table.
1223             * If found .wpt-variable-product-options then then we will remove auto current page filter
1224             * because, this time we will load from page reload.
1225             */
1226            var paginatedMiniFilter = $('.wpt-variable-product-options').length;
1227            if( paginatedMiniFilter > 0 ){
1228                return;
1229            }
1230            filterTableRow(temp_number);
1231            
1232        });
1233        
1234        $('body').on('click','a.wpt_filter_reset',function(e){
1235            e.preventDefault();
1236            var temp_number = $(this).data('temp_number');
1237            $('#table_id_' + temp_number + ' select.filter_select').each(function(){
1238                $(this).prop('selectedIndex', 0);
1239
1240            });
1241            $('#table_id_' + temp_number + ' select.filter_select').trigger('change');
1242
1243            $('.wpt-my-pagination-' + temp_number).show();//wpt_filter_reset
1244        });
1245        
1246        
1247        function filterTableRow(temp_number){
1248            emptyInstanceSearchBox(temp_number);
1249            //Uncheck All for each Change of Filter
1250            uncheckAllCheck(temp_number);
1251            
1252            //Checking FilterBox
1253            var filterBoxYesNo = $('#table_id_' + temp_number + ' .wpt-mini-filter').html();
1254
1255            /**
1256             * Uncheck All, If any change on filter button
1257             * @version 2.0
1258             */
1259            let tableBodyobj = $('#table_id_' + temp_number + ' #wpt_table.wpt-table-tag tbody');
1260            
1261            var ClassArray =[];
1262            var serial = 0;
1263            $('#table_id_' + temp_number + ' .wpt-mini-filter select.filter_select').each(function(){
1264                var currentClass = $(this).val();
1265
1266                if(currentClass !==''){
1267                    ClassArray[serial] = '.' + currentClass;
1268                    serial++;
1269                }
1270            });
1271            var finalClassSelctor = '.filter_row' + ClassArray.join(''); //Test will keep
1272            var hideAbleClass = '#table_id_' + temp_number + ' table .wpt-tr-tag.wpt_row';
1273        
1274            let foundRow = $(finalClassSelctor);
1275            let foundFirstRow = foundRow.first();
1276            let colSpanCount = tableBodyobj.find('.wpt-tr-tag').first().find('td.td_or_cell').length;
1277            let foundRowCount = foundRow.length;
1278            let notFundMsg = config_json.product_not_founded;
1279            
1280            if(foundRowCount > 0){
1281                $('.wpt-my-pagination-' + temp_number).hide();//wpt_filter_reset
1282            }
1283            //if not found available from before, we will remove it first.
1284            $('#table_id_' + temp_number + ' #wpt_table.wpt-table-tag tbody .wpt-tr-tag.product-not-found-tr').remove();
1285            if(foundRowCount < 1){
1286                let newRotHtml = "<tr class='product-not-found-tr'><td colspan='" + colSpanCount + "'><div class='wpt_product_not_found'>" + notFundMsg + "</div></td></tr>";
1287                $('#table_id_' + temp_number + ' #wpt_table.wpt-table-tag tbody').append(newRotHtml)
1288            }
1289            //here was remove notFound on else. we remove it becuase, we have added at the begining always
1290           
1291
1292           if( filterBoxYesNo ){
1293                $(hideAbleClass + ' wpt_check input.enabled.wpt_tabel_checkbox').removeClass('wpt_td_checkbox');
1294                $(hideAbleClass).css('display','none');
1295                $(hideAbleClass).removeClass('visible_row');
1296
1297                $(finalClassSelctor).fadeIn();
1298                $(finalClassSelctor).addClass('visible_row');
1299                $(finalClassSelctor + ' wpt_check input.enabled.wpt_tabel_checkbox').addClass('wpt_td_checkbox');
1300            }
1301            
1302            /**
1303             * Updating Check Founting Here
1304             */
1305            updateCheckBoxCount(temp_number);
1306        }
1307        
1308        /**
1309         * Mainly for shortmessage field
1310         */
1311        $('body').on('change', '.wpt_row .message', function() {
1312                var temp_number = $(this).parents('.wpt-tr-tag.wpt_row').data('temp_number');
1313                var msg = $(this).val();
1314                var product_id = $(this).parents('.wpt-tr-tag').data('product_id');
1315            
1316                var thisRow = '#table_id_' + temp_number + ' .wpt-tr-tag.product_id_' + product_id;
1317                $( thisRow + ' .message').val(msg);
1318        });
1319        
1320
1321        $(document).on('keyup','.wpt_row input.input-text.qty.text', oneSecondDelay(inputBoxChangeHandle,1500));
1322 
1323        $(document.body).on('change', '.wpt_row input.input-text.qty.text', inputBoxChangeHandle);
1324        function inputBoxChangeHandle() {
1325
1326            var temp_number = $(this).parents('.wpt-tr-tag.wpt_row').data('temp_number');
1327            var Qty_Val = $(this).val();
1328            var product_id = $(this).parents('.wpt-tr-tag').data('product_id');
1329        
1330            var thisRow = '#table_id_' + temp_number + ' .wpt-tr-tag.product_id_' + product_id;
1331            var outofstockVal = $(thisRow).hasClass("stock_status_outofstock");
1332            if(outofstockVal){
1333                Qty_Val = 0;
1334            }
1335            $(thisRow).find('.yith-ywraq-add-to-quote input.input-text.qty.text').val(Qty_Val);
1336            // $( thisRow + ' input.input-text.qty.text').val(Qty_Val); // input.input-text.qty.text
1337            $( thisRow ).attr('data-quantity', Qty_Val);
1338            $( thisRow + ' .wpt_action a.wpt_woo_add_cart_button').attr('data-quantity', Qty_Val);
1339            $( thisRow + ' .wpt_action a.add_to_cart_button').attr('data-quantity', Qty_Val);
1340            $( thisRow + ' .wpt_buy_link a.add_to_cart_button').attr('data-quantity', Qty_Val);
1341            var Item_URL = '?add-to-cart=' + product_id + '&quantity=' + Qty_Val;
1342            $( thisRow + ' .wpt_action a.add_to_cart_button').attr('href', Item_URL);
1343            var targetTotalSelector = $('#table_id_' + temp_number + ' .product_id_' + product_id + ' .wpt_total_item.total_general');
1344             
1345        
1346            var targetWeightSelector = $('#table_id_' + temp_number + ' .product_id_' + product_id + ' .weight-box');
1347            var targetWeightAttr = $('#table_id_' + temp_number + ' .product_id_' + product_id + ' .weight-box').attr('data-weight');
1348            
1349            var totalWeight =  parseFloat(targetWeightAttr) * parseFloat(Qty_Val);
1350          
1351            totalWeight = totalWeight.toFixed(2);
1352            if(totalWeight === 'NaN'){
1353            totalWeight = '';
1354            }
1355            targetWeightSelector.html(totalWeight);
1356            
1357            var targetTotalStrongSelector = $('#table_id_' + temp_number + ' .product_id_' + product_id + ' .wpt_total_item.total_general strong');
1358            var targetPrice = targetTotalSelector.attr('data-price');
1359            var targetCurrency = targetTotalSelector.data('currency');
1360            var targetPriceDecimalSeparator = targetTotalSelector.data('price_decimal_separator');
1361            var targetPriceThousandlSeparator = targetTotalSelector.data('thousand_separator');
1362
1363            var targetNumbersPoint = targetTotalSelector.data('number_of_decimal');
1364            
1365            var totalPrice = parseFloat(targetPrice) * parseFloat(Qty_Val);
1366            
1367            totalPrice = totalPrice.toFixed(targetNumbersPoint);
1368            var priceFormat = WPT_DATA.priceFormat;
1369           
1370           totalPrice = totalPrice.replace('.', targetPriceDecimalSeparator);
1371            var newPrice;
1372            switch (priceFormat) {
1373            case 'left': // left
1374                //newPrice = targetCurrency + totalPrice.replace(".",targetPriceDecimalSeparator);
1375                newPrice = targetCurrency+ (totalPrice + '').replace(/\B(?=(?:\d{3})+\b)/g, targetPriceThousandlSeparator);
1376                break;
1377            case 'right': // right
1378                //newPrice = totalPrice.replace(".",targetPriceDecimalSeparator) + targetCurrency;
1379                newPrice = (totalPrice + '').replace(/\B(?=(?:\d{3})+\b)/g, targetPriceThousandlSeparator) + targetCurrency;
1380                break;
1381            case 'left-space': // left with space
1382                //newPrice = targetCurrency + ' ' + totalPrice.replace(".",targetPriceDecimalSeparator);
1383                newPrice = targetCurrency + ' ' +  (totalPrice + '').replace(/\B(?=(?:\d{3})+\b)/g, targetPriceThousandlSeparator);
1384                break;
1385            case 'right-space': // right with space
1386                //newPrice = totalPrice.replace(".",targetPriceDecimalSeparator) + ' ' + targetCurrency;
1387                newPrice =  (totalPrice + '').replace(/\B(?=(?:\d{3})+\b)/g, targetPriceThousandlSeparator) + ' ' + targetCurrency;
1388                break;
1389            }
1390
1391            $('.yith_request_temp_' + temp_number + '_id_' + product_id).attr('data-quantity', Qty_Val);
1392            $('#table_id_' + temp_number + ' .product_id_' + product_id + ' .wpt_total_item.total_general strong').html(newPrice);
1393
1394            updateCheckBoxCount(temp_number);
1395        }
1396
1397        upateGlobalCheckboxCount();
1398        function upateGlobalCheckboxCount(){
1399            
1400            var add_cart_text = $('.wpt-wrap').data('basic_settings').add_to_cart;
1401            var currentAllSelectedButtonSelector = $('body a.wpt-global-added-to-cart>span');
1402            var itemAmount = 0;
1403            var itemCountSystem = config_json.item_count;
1404            
1405            
1406            $('.wpt-wrap input.enabled.wpt_tabel_checkbox:checked').each(function() { //wpt_td_checkbox
1407                var product_id = $(this).data('product_id');
1408                var thisRow = $(this).closest('.wpt-tr-tag');
1409                var qtyInput = thisRow.find('input.qty, input[name="quantity"]');
1410                var items = qtyInput.length > 0 ? qtyInput.val() : thisRow.attr('data-quantity');
1411                items = parseFloat(items);
1412                if(items <= 0){
1413                    return;
1414                }
1415                if(typeof itemCountSystem !== 'undefined' && itemCountSystem === 'all'){
1416                    
1417
1418                    
1419                    itemAmount += items;
1420                }else{
1421                    itemAmount++;//To get Item Amount
1422                }
1423                
1424            });
1425            var checkBoxWrapper = $('a.wpt-global-added-to-cart');
1426            if(itemAmount > 0){
1427                checkBoxWrapper.fadeIn();
1428                checkBoxWrapper.removeClass('wpt-added-to-cart-empty');
1429            }else{
1430                checkBoxWrapper.fadeOut();
1431                checkBoxWrapper.addClass('wpt-added-to-cart-empty');
1432            }
1433            var itemText = config_json.items;//'Items';
1434
1435            if (itemAmount === 1 || itemAmount === 0) {
1436                itemText = config_json.item;//'Item';
1437            }
1438            if ( itemAmount > 0 || currentAllSelectedButtonSelector.hasClass('already_counted') ) {
1439                currentAllSelectedButtonSelector.addClass('already_counted');
1440                currentAllSelectedButtonSelector.html( add_cart_text + ' [ ' + itemAmount + ' ' + itemText + ' ]');
1441            }
1442
1443        }
1444        function updateCheckBoxCount(temp_number){
1445            upateGlobalCheckboxCount();
1446            config_json = getConfig_json( temp_number ); //Added vat V5.0
1447            var add_cart_text = $('#table_id_' + temp_number).data('basic_settings').add_to_cart;
1448            var currentAllSelectedButtonSelector = $('#table_id_' + temp_number + ' a.button.add_to_cart_all_selected');
1449            var itemAmount = 0;
1450            var itemCountSystem = config_json.item_count;
1451            
1452            $('table.wpt_temporary_table_' + temp_number + ' .wpt-tr-tag.wpt_row').removeClass('wpt_selected_tr');
1453            
1454            $('#table_id_' + temp_number + ' input.enabled.wpt_tabel_checkbox:checked').each(function() { //wpt_td_checkbox
1455                var product_id = $(this).data('product_id');
1456                var thisRow = $(this).closest('.wpt-tr-tag');
1457                $('table.wpt_temporary_table_' + temp_number + ' .wpt-tr-tag.wpt_row#product_id_' + product_id).addClass('wpt_selected_tr');
1458                var qtyInputCB = thisRow.find('input.qty, input[name="quantity"]');
1459                var items = qtyInputCB.length > 0 ? qtyInputCB.val() : thisRow.attr('data-quantity');
1460                items = parseFloat(items);
1461                if(items <= 0){
1462                    //$('#table_id_' + temp_number + ' tr#product_id_' + product_id + ' input:checkbox').attr('checked',false);
1463                    return;
1464                }
1465                if(typeof itemCountSystem !== 'undefined' && itemCountSystem === 'all'){
1466                    itemAmount += items;
1467                }else{
1468                    itemAmount++;//To get Item Amount
1469                }
1470                
1471            });
1472            var checkBoxWrapper = $('#table_id_' + temp_number + ' .all_check_header_footer');
1473            if(itemAmount > 0){
1474                checkBoxWrapper.addClass('product-selected');
1475            }else{
1476                checkBoxWrapper.removeClass('product-selected');
1477            }
1478            var itemText = config_json.items;//'Items';
1479
1480            if (itemAmount === 1 || itemAmount === 0) {
1481                itemText = config_json.item;//'Item';
1482            }
1483            if ( itemAmount > 0 || currentAllSelectedButtonSelector.hasClass('already_counted') ) {
1484                currentAllSelectedButtonSelector.addClass('already_counted');
1485                currentAllSelectedButtonSelector.html( add_cart_text + ' [ ' + itemAmount + ' ' + itemText + ' ]');
1486            }
1487            
1488            var argStats = {};
1489            argStats['temp_number'] = temp_number;
1490            argStats['table_id'] = temp_number;
1491            argStats['itemAmount'] = itemAmount;
1492            argStats['itemText'] = itemText;
1493            argStats['button_text'] = add_cart_text;
1494            argStats['button_object'] = currentAllSelectedButtonSelector;
1495            $(document.body).trigger('wpt_count_updated',argStats);
1496        }
1497        
1498        $(document.body).on('updateCheckBoxCount',function(temp_number){
1499            
1500            updateCheckBoxCount(temp_number);
1501        });
1502        
1503        
1504        $('body').on('click', 'input.wpt_check_universal,input.enabled.wpt_tabel_checkbox.wpt_td_checkbox', function() { //wpt_td_checkbox
1505            var temp_number = $(this).data('temp_number');
1506            var checkbox_type = $(this).data('type'); //universal_checkbox
1507            if (checkbox_type === 'universal_checkbox') {
1508                $('#table_id_' + temp_number + ' input.enabled.wpt_tabel_checkbox.wpt_td_checkbox:visible').prop('checked', this.checked); //.wpt_td_checkbox
1509                $('input#wpt_check_uncheck_column_' + temp_number).prop('checked', this.checked);
1510                $('input#wpt_check_uncheck_button_' + temp_number).prop('checked', this.checked);
1511            }
1512            var temp_number = $(this).data('temp_number');
1513            updateCheckBoxCount(temp_number);
1514        });
1515        
1516        function uncheckAllCheck(temp_number){
1517            var selectedCheckBox = $('#table_id_' + temp_number + ' .all_check_header input[type=checkbox],#table_id_' + temp_number + ' .wpt_table_tag_wrapper input[type=checkbox]');
1518            selectedCheckBox.each(function(){
1519                if($(this).is(':checked')){
1520                    $(this).trigger('click');
1521                }
1522            });
1523            updateCheckBoxCount(temp_number);
1524        }
1525        
1526        /**
1527         * For Instance Search
1528         * @since 2.5
1529         */
1530        $('.instance_search_input').keyup(function () {
1531            var text, value_size, serial;
1532            var temp = $(this).data('temp_number');
1533            var value = $(this).val();
1534            value = value.trim();
1535        
1536            value = value.split(' ');
1537            value = value.filter(function (eachItem) {
1538                return eachItem !== '';
1539            });
1540            value_size = value.length;
1541        
1542            var target_table = '#table_id_' + temp + ' #wpt_table';
1543            $(target_table + ' .wpt-tr-tag.visible_row').each(function () {
1544                text = $(this).text();
1545                text = text.replace(/[\u200B-\u200D\uFEFF]/g, ''); // Removing Zero Width Space
1546                text = text.toLowerCase();
1547                serial = 0;
1548        
1549                value.forEach(function (eachItem) {
1550                    if (eachItem.length === 1) {
1551                        // Match only at the start of words for single-character input
1552                        if (text.match(new RegExp('\\b' + eachItem, 'i'))) {
1553                            serial++;
1554                        }
1555                    } else {
1556                        // Match anywhere in the text for multi-character input
1557                        if (text.match(new RegExp(eachItem, 'i'))) {
1558                            serial++;
1559                        }
1560                    }
1561                });
1562        
1563                if (serial === value_size) { // All words must match
1564                    $(this).fadeIn(100);
1565                    $(this).addClass('instance_search_applied');
1566                } else {
1567                    $(this).fadeOut(100);
1568                    $(this).removeClass('instance_search_applied');
1569                }
1570            });
1571        });
1572        
1573        function emptyInstanceSearchBox(temp_number){
1574            $('#table_id_' + temp_number + ' .instance_search_input').val('');
1575        }
1576        
1577        /**
1578         * Quote Button Revert on Change Variation
1579         */
1580        $(window).on('wpt_changed_variations',function(e,Attrs){
1581            if( Attrs.status ){
1582                var product_id = Attrs.product_id;
1583                var quoteElm = $('.wpt-tr-tag.product_id_'+product_id + ' .wpt-td-tag.wpt_quoterequest a.wpt_yith_add_to_quote_request');
1584                try{
1585                    var response_msg = quoteElm.data('msg');
1586                    quoteElm.html(response_msg.text);
1587                    quoteElm.closest('div.quoterequest').find('.yith_ywraq_add_item_response_message').remove();
1588                    quoteElm.closest('div.quoterequest').find('.yith_browse_link').remove();
1589                }catch(e){
1590                    // nothing needed to print
1591                }
1592            }
1593        });
1594        /**
1595         * For Add to Quote Plugin
1596         * YITH add to Quote Request plugin
1597         * @since 2.6 
1598         * @date 20.7.2018
1599         */
1600        //ywraq_frontend
1601        $('body').on('click','a.wpt_yith_add_to_quote_request.enabled',function(e){
1602            e.preventDefault();
1603            var thisButton = $(this); //New added at 4.0.19 
1604            if ( typeof ywraq_frontend === 'undefined' ){
1605                alert("Quote Request plugin is not installed.");
1606                return false;
1607            }
1608            var msg = $(this).data('msg');
1609            var response_msg = $(this).attr('data-response_msg');
1610            var type = $(this).closest('.wpt-tr-tag.wpt_row').data('type')
1611            
1612            if(type !== 'variable' && response_msg !== ''){
1613                showAlert(response_msg);
1614                $('.' + selector).html(msg.added);
1615                return false;
1616            }
1617            var selector = $(this).data('selector');
1618            $('.' + selector).html(msg.adding);
1619            var add_to_cart_info;
1620            var wp_nonce = $(this).data('wp_nonce');
1621            var product_id = $(this).data('product_id');
1622            var parent_id = $(this).closest('.wpt-tr-tag.wpt_row').data('parent_id');
1623
1624            var quantity = $(this).attr('data-quantity');
1625            var quote_data = $(this).attr('data-quote_data');
1626            var yith_browse_list = $(this).data('yith_browse_list');
1627            
1628            
1629            var temp_number = $(this).closest('.wpt-tr-tag.wpt_row').data('temp_number');
1630            var addToCartSelector = $('#table_id_' + temp_number + ' #product_id_' + product_id + ' a.wpt_product_title_in_td');
1631            var tableRow = $('#table_id_' + temp_number + ' #product_id_' + product_id );
1632            
1633            var url_params = tableRow.attr('data-href');
1634            var split_params = url_params.split('?');
1635            if( typeof split_params[1] !== 'undefined' && type === 'variation' ){
1636                quote_data = '&' + split_params[1];
1637            }
1638            add_to_cart_info = 'action=yith_ywraq_action&ywraq_action=add_item&quantity=' + quantity + '&product_id='+ product_id +'&_wpnonce='+ywraq_frontend.yith_ywraq_action_nonce;
1639            add_to_cart_info += quote_data;
1640            /**
1641             * When Table will show "Only Variation" as row
1642             * Then Product ID will get from Parent ID
1643             * And variation id will be product ID
1644             * 
1645             * @since 2.7.7
1646             */
1647            if( type === 'variation' ){
1648               var variation_id = product_id;
1649               product_id = parent_id;
1650                add_to_cart_info += '&variation_id=' + variation_id;
1651            }
1652            
1653            var yith_ajax_url;// = ywraq_frontend.ajaxurl;
1654            yith_ajax_url = ywraq_frontend.ajaxurl.toString().replace( '%%endpoint%%', 'yith_ywraq_action' );
1655            
1656            $.ajax({
1657            type   : 'POST',
1658            url    : ywraq_frontend.ajaxurl,//yith_ajax_url,
1659            dataType: 'json',
1660            data   : add_to_cart_info,
1661            beforeSend: function(){
1662
1663            },
1664            complete: function(){
1665            },
1666            success: function (response) {
1667                if( response && ( response.result === 'true' || response.result === 'exists' ) ){
1668                    $('.' + selector).html(msg.added);
1669                    //if(response.result === 'exists'){
1670                        //$('.' + selector).attr('data-response_msg',response.message);
1671                    //}
1672                    $('.' + selector).attr('data-response_msg',response.message);
1673                    var html;
1674                    
1675                    html = '<div class="yith_ywraq_add_item_response_message">' + response.message + '</div>';
1676                    html += '<a class="yith_browse_link" href="'+response.rqa_url+'" target="_blank">' + yith_browse_list + '</a>';
1677                    
1678                    $('.' + selector).parent().append( html ).show(); //response.label_browse
1679                }else{
1680                    $('.' + selector).html(msg.added);
1681                }
1682                
1683            }
1684        });
1685        });
1686        
1687        loadMiniFilter();
1688        $(document.body).on('wpt_ajax_loaded',function(){
1689            loadMiniFilter();
1690        });
1691        /**
1692         * Loading MiniFilter 's option based on loaded products
1693         * @since 4.8
1694         * 
1695         * @returns {void}
1696         */
1697        function loadMiniFilter(){
1698            $('.wpt-wrap .wpt-mini-filter select.filter_select').each(function(){
1699
1700                var id = $(this).attr('id');
1701                var temp_number = $(this).data('temp_number');
1702                var config_json = getConfig_json( temp_number );
1703                var key =  $(this).data('key');
1704
1705                var label =  $(this).data('label');
1706                var taxArray = new Array();
1707                var taxValArray = new Array();
1708                taxArray.sort();
1709                $('#table_id_' + temp_number + ' .wpt-tbody-tag .wpt-tr-tag').each(function(){
1710                    var tax = $(this).data(key);
1711                    if(tax && tax !== ''){
1712                        tax = tax.replace(/,\s*$/, "");
1713                        tax = tax.replace(/\s/g, ' ');
1714
1715                        tax = tax.split(',');
1716                        tax.forEach(function(item){
1717                            item = item.trimStart(" ");
1718                            var taxDetails = item.split(':');
1719                            var taxID = taxDetails[0];
1720                            var taxValue = taxDetails[1];
1721                            taxArray[taxID] = taxValue;
1722                            taxValArray[taxValue] = taxID;
1723                        });
1724                    }
1725                });
1726
1727                
1728                if(config_json.sort_mini_filter === 'ASC'){
1729                    taxArray.sort();
1730                    
1731                }else if(config_json.sort_mini_filter === 'DESC'){
1732                    taxArray.sort();
1733                    taxArray.reverse();
1734                }
1735                
1736                var html = '<option value="">' + label + '</option>';
1737                taxArray.forEach(function(value,number){
1738                    html += '<option value="' + key + '_' + temp_number + '_' + taxValArray[value] + '">' + value + '</option>';
1739                });
1740                $(this).html(html);
1741            });
1742        }
1743
1744        /**
1745         * We will grab number/inter from Sting. such from 1st,3rd,5th to 1,3,4 as well 
1746         * as from price $23.45 to 23.45
1747         * 
1748         * I have used it into soring perpose code
1749         * 
1750         * @param {string} text 
1751         * @param {string|int|number} product_id 
1752         * @returns int
1753         */
1754        function textToIntForSorting(text){
1755            text = text.replace(/[^0-9.]/g,'');
1756            text = parseFloat(text);
1757            if(text == ''){
1758                text = 0;
1759            }
1760
1761            text = text * 100000;
1762
1763            text = parseInt(text);
1764            return text;
1765        }
1766
1767        /**
1768         * sort order organization
1769         * column sort sorting
1770         * Colunm Sorting Option
1771         * js base column sorting.
1772         * N.B: you have to enable it from Configuration page.
1773         * 
1774         * @since 2.8
1775         * @date 26.7.2018
1776         */
1777        $(document.body).on('click','div.wpt_column_sort .wpt-table-tag.wpt_product_table .wpt-thead-tag .wpt-tr-tag .wpt-th-tag',function(){
1778
1779            
1780            var unq_id = $(this).closest('div.wpt-wrap').data('unique_id');
1781
1782            var class_for_sorted = 'this_column_sorted';
1783            var temp_number = $(this).parent().data('temp_number');
1784            var target_class = '.' + $(this).data('target_class');
1785
1786            var target_table_wrapper_id = "div#table_id_" + temp_number + "[data-unique_id='" + unq_id + "']";
1787            var thisColObject = $(this);
1788            var status = false;
1789            var disableClass = [
1790                '.wpt_quantity',
1791                '.wpt_check',
1792            ];
1793            
1794            var number_class = $('.wpt-td-tag'+target_class + '>.text_with_number');//.find('.text_with_number');
1795            var content_type = 'normal';
1796            if(number_class.length > 0 || target_class.search('.wpt_serial_number') != -1 || target_class.search('.wpt_product_id') != -1 || target_class.search('.wpt_total') != -1 ){
1797                content_type = 'number';
1798            }else if(target_class.search('.wpt_price') != -1){
1799                content_type = 'price';
1800            }
1801                        
1802            var sort_type = $(this).attr('data-sort_type');
1803                
1804            if(!sort_type || sort_type === 'ASC'){
1805                sort_type = 'ASC';
1806                $(this).attr('data-sort_type','DESC');
1807            }else{
1808
1809                $(this).attr('data-sort_type','ASC');
1810            }
1811
1812            /**
1813             * Actually when Audio item in table, then we will not 
1814             * support column sorting.
1815             * 
1816             * @since 3.3.2.2
1817             */
1818            var audioItems = $(target_table_wrapper_id).find('.mejs-container');
1819            if(audioItems.length > 0){
1820                return;
1821            }
1822            
1823            //for check box collumn //wpt_thumbnails //wpt_product_id
1824            if($.inArray(target_class,disableClass) == -1){
1825            
1826                $(target_table_wrapper_id + ' .' +class_for_sorted).removeClass(class_for_sorted);
1827                
1828                //Again Class Reform after remove class
1829                target_class = '.' + $(this).data('target_class');
1830
1831                var contentHTMLArray = [];
1832                var currentColumnObject = $(target_table_wrapper_id + ' .wpt-table-tag .wpt-tbody-tag .wpt-td-tag' + target_class);
1833
1834                //div#table_id_124[data-unique_id='dAtlfogymulaaCiesrIlosoS'] table tbody td.wpt_product_title 
1835
1836                currentColumnObject.each(function(index){
1837                    
1838                    
1839                    var text,
1840                    html = '', 
1841                    product_id = $(this).parent('.wpt-tr-tag').data('product_id');
1842                    text = $(this).text();
1843                    text = $.trim(text);
1844                    if(content_type == 'price'){
1845                        text = $(this).find('span.woocommerce-Price-amount.amount').last().text();
1846                        // console.log(text);
1847                        text = textToIntForSorting(text);
1848                        // console.log(text);
1849
1850                    }else if(content_type == 'number'){
1851                        
1852                        text = textToIntForSorting(text);
1853
1854                    }else{
1855                        text = $.trim(text.substring(0,80));
1856                        
1857                        text = text + "_" + product_id;
1858                    }
1859                    // console.log(text);
1860                    var thisRowObject = $('#table_id_'+ temp_number +' #product_id_' + product_id);
1861                    html = thisRowObject.prop('outerHTML');
1862                    //get_val is actually generated value
1863                    contentHTMLArray[index] = {
1864                        product_id: product_id,
1865                        gen_val: text,
1866                        html: html
1867                    };
1868                });
1869                
1870                function sortingData(prevData,nextData){
1871                    var a = prevData['gen_val'];
1872                    var b = nextData['gen_val'];
1873                    var return_data;
1874                    if(sort_type === 'ASC'){
1875                        return_data = ((a < b) ? -1 : ((a > b) ? 1 : 0));
1876                    }else{
1877                        return_data = ((b < a) ? -1 : ((b > a) ? 1 : 0));
1878                    }
1879                    return return_data;
1880                  }
1881                  contentHTMLArray.sort(sortingData);
1882
1883                  var finalHTMLData = '';
1884                  $.each(contentHTMLArray,function(index,value){
1885
1886                        finalHTMLData += value.html;
1887                  });
1888
1889                //Backed HTML Data
1890                $(target_table_wrapper_id + ' .wpt-table-tag > .wpt-tbody-tag').html(finalHTMLData);
1891
1892                $(target_table_wrapper_id + ' ' +target_class).addClass(class_for_sorted);
1893                
1894                //Cliecked on 
1895                status = true;
1896            }
1897            
1898            var argStats = {};
1899            argStats['status'] = status;
1900            argStats['temp_number'] = temp_number;
1901            argStats['table_id'] = temp_number;
1902            argStats['this_object'] = thisColObject;
1903            $(document.body).trigger('wpt_column_sorted',argStats);
1904            $(document.body).trigger('wpt_ajax_loaded');
1905            
1906            
1907        });
1908        
1909        
1910        //* Removeing link for cat and tag texonomy
1911        removeCatTagLings();
1912        $(document.body).on('wpt_ajax_loaded',removeCatTagLings);
1913        /**
1914         * Removing Linkg for Categories link and from Tag's link.
1915         * We will remove link by JavaScript I mean: jQuery
1916         * 
1917         * @since 3.1
1918         * @date: 13 sept, 2018
1919         */
1920        function removeCatTagLings(){
1921           if(config_json.disable_cat_tag_link === '1'){
1922                // $('.wpt_category a,.wpt_tags a,.wpt_custom_tax a').contents().unwrap();
1923                $('.wpt_category a,.wpt_tags a,.wpt_custom_tax a').removeAttr("href");
1924            } 
1925        }
1926        // Removing link feature End here  */
1927
1928    /*
1929     * Start code for Advance Version
1930     * Version: 5.3
1931     */
1932    function Advance_NoticeBoard(response){
1933
1934        var noticeBoard = $('div.wpt_notice_board');
1935        var eachNoticeInnter = $(response);
1936        eachNoticeInnter.css('display','none');
1937        if(response !== ''){
1938            noticeBoard.prepend(eachNoticeInnter);
1939            eachNoticeInnter.fadeIn();  
1940            setTimeout(function(){
1941                eachNoticeInnter.fadeOut();
1942                eachNoticeInnter.remove(); 
1943            },notice_timeout);//Default 3000
1944        }
1945    }
1946    function WPT_BlankNotice(){
1947        var noticeBoard = $('div.wpt_notice_board');
1948        noticeBoard.html('');
1949    }
1950   
1951    $(document).on('submit','div.advance_table_wrapper .wpt-table-tag.advance_table.wpt_product_table form',function(e){
1952            footerCartAnimation();
1953            WPT_BlankNotice();
1954            var product_id = $(this).parents('.wpt-tr-tag').data('product_id');
1955            var thisButton = $('tr#product_id_' + product_id + ' .wpt_action button.single_add_to_cart_button');
1956            if(thisButton.hasClass('disabled')){
1957                return;
1958            }
1959            var thisTable = $(this).parents('div.wpt-wrap');
1960            var table_id = $(this).parents('div.wpt-wrap').attr('id');
1961            
1962            var data_json = $(this).closest('.wpt-wrap').data('basic_settings');
1963            var ajax_action = data_json.ajax_action;
1964
1965            var thisRow = $(this).closest('.wpt-tr-tag.wpt-row');
1966            var messageBox = thisRow.find('input.wpt_custom_message');
1967            var Bubble = thisRow.find('.wpt_ccount');
1968            if(Bubble.length == 0){
1969                thisRow.find('.single_add_to_cart_button').append('<span class="wpt_ccount wpt_ccount_' + product_id + '"><i class="wpt-spin5 animate-spin"></span>');
1970            }else{
1971                Bubble.html('<i class="wpt-spin5 animate-spin">');
1972            }
1973
1974            // thisButton.addClass( 'loading' );
1975            thisButton.removeClass('added');
1976            thisButton.addClass( 'disabled' );
1977            var form = $(this);
1978            var url = form.attr('action');//ajax_url;//
1979
1980            var method = form.attr('method');
1981            if( 'post' === method && ajax_action === 'ajax_active'){
1982                e.preventDefault();
1983            }else{
1984                return;
1985            }
1986            
1987            var checkoutURL = WPT_DATA.checkout_url;
1988            var cartURL = WPT_DATA.cart_url;
1989            
1990            $.post(url, form.serialize() + '&add-to-cart=' + product_id + '&_wp_http_referer=' + url, function(data,status,xh){ //form.serialize() + '&_wp_http_referer=' + url
1991                thisTable.removeClass('loading');
1992                var notice = $('.woocommerce-message,.woocommerce-error', data); //.woocommerce-error
1993
1994                if(config_json.popup_notice === '1' || config_json.popup_notice == 'no'){
1995                    Advance_NoticeBoard(notice);//Gettince Notice
1996                }
1997                    
1998                    thisButton.removeClass('disabled');
1999                    // thisButton.removeClass('loading');
2000                    thisButton.addClass('added');
2001            }).done(function(){
2002                messageBox.val('');
2003                // $( document.body ).trigger( 'added_to_cart' );
2004                $( document.body ).trigger( 'updated_cart_totals' );
2005                $( document.body ).trigger( 'wc_fragments_refreshed' );
2006                $( document.body ).trigger( 'wc_fragments_refresh' );
2007                $( document.body ).trigger( 'wc_fragment_refresh' );
2008                
2009                //Quick Button Active here and it will go Directly to checkout Page
2010                if(config_json.product_direct_checkout === 'yes'){
2011                    window.location.href = checkoutURL;
2012                    return;
2013                }
2014                //Quick Cart Button Active here and it will go Directly to Cart Page
2015                if(config_json.product_direct_checkout === 'cart'){
2016                    window.location.href = cartURL;
2017                    return;
2018                }
2019                //$( '.wpt_row_product_id_' + product_id + ' .wpt_action button.single_add_to_cart_button' ).addClass( 'added' );
2020                //$( '.wpt_row_product_id_' + product_id + ' .wpt_action button.single_add_to_cart_button' ).removeClass( 'disabled loading' );
2021                
2022                var argStats = {};
2023                argStats['status'] = true;
2024                argStats['product_id'] = product_id;
2025                argStats['form'] = form;
2026                argStats['url'] = url;
2027                argStats['temp_number'] = table_id;
2028                argStats['table_id'] = table_id;
2029                $(document.body).trigger('wpt_added_to_cart_advance',argStats);
2030            });
2031        });
2032        
2033        //div.normal_table_wrapper table.normal_table
2034        $('div.advance_table_wrapper a.button.add_to_cart_all_selected').click(function() {
2035            
2036            WPT_BlankNotice();
2037            var temp_number = $(this).data('temp_number');
2038            var allMessageBox = $('#table_id_' + temp_number + ' .wpt_custom_message');
2039            
2040            var checkoutURL = WPT_DATA.checkout_url;//$('#table_id_' + temp_number).data('checkout_url');
2041            var cartURL = WPT_DATA.cart_url;//$('#table_id_' + temp_number).data('cart_url');
2042            var tableWrapperTag = $('#table_id_' + temp_number + ' .wpt_table_tag_wrapper');
2043            tableWrapperTag.addClass('wpt-ajax-loading');
2044            //Add Looading and Disable class 
2045            var currentAllSelectedButtonSelector = $('#table_id_' + temp_number + ' a.button.add_to_cart_all_selected');
2046            currentAllSelectedButtonSelector.addClass('disabled');
2047            currentAllSelectedButtonSelector.addClass('loading');
2048
2049
2050            
2051            var add_cart_text = $('#table_id_' + temp_number).data('basic_settings').add_to_cart;
2052            
2053            var itemAmount = 0;
2054
2055            var products_data = {};
2056
2057            $('#table_id_' + temp_number + ' input.enabled.wpt_tabel_checkbox.wpt_td_checkbox:checked').each(function() {
2058                WPT_BlankNotice();
2059                var thisRow = $(this).closest('.wpt-tr-tag');
2060                var product_id = $(this).data('product_id');
2061                var form = thisRow.find('.wpt_action form');
2062                var title = thisRow.data('title');
2063                var additional_json = thisRow.attr('additional_json');
2064
2065                let eachProductData = 'product_id=' + product_id + '&' + form.serialize();
2066
2067                var obj = {};
2068
2069                eachProductData.replace(/([^=&]+)=([^&]*)/g, function(m, key, value) {
2070                    obj[decodeURIComponent(key)] = decodeURIComponent(value);
2071                });
2072
2073                // Find quantity element inside the row
2074                var qtyInput = thisRow.find('input.qty, input[name="quantity"]');
2075                var currentQantity;
2076                if(qtyInput.length > 0){
2077                    currentQantity = parseFloat(qtyInput.val());
2078                    // Sync data-quantity on the row
2079                    thisRow.attr('data-quantity', currentQantity);
2080                }else{
2081                    currentQantity = parseFloat(thisRow.attr('data-quantity'));
2082                }
2083                if( isNaN(currentQantity) || currentQantity <= 0 ){
2084                    currentQantity = 1;
2085                }
2086
2087                // Explicitly set quantity to the correct user input value
2088                obj['quantity'] = currentQantity;
2089
2090                if(additional_json !== ''){
2091                    obj['additional_json'] = additional_json;
2092                }
2093
2094                products_data[product_id] = obj;
2095
2096                var items = currentQantity;
2097                items = parseFloat(items);
2098                if(items <= 0){
2099                    return;
2100                }
2101                
2102                var itemCountSystem = config_json.item_count;
2103                if(typeof itemCountSystem !== 'undefined' && itemCountSystem === 'all'){
2104                    itemAmount += items;
2105                }else{
2106                    itemAmount++;//To get Item Amount
2107                } 
2108            });
2109
2110            //Return false for if no data
2111            if (itemAmount < 1) {
2112                currentAllSelectedButtonSelector.removeClass('disabled');
2113                currentAllSelectedButtonSelector.removeClass('loading');
2114                showAlert(config_json.please_choose_items);
2115                return false;
2116            }
2117            uncheckAllCheck(temp_number);
2118            currentAllSelectedButtonSelector.html(add_cart_text + ' [ ' + config_json.loading_more_text + ' ]');
2119
2120            $.ajax({
2121                type: 'POST',
2122                url: ajax_url,
2123                data: {
2124                    action: 'wpt_ajax_mulitple_add_to_cart',
2125                    products: products_data,
2126                },
2127                complete: function(){
2128                    $( document ).trigger( 'wc_fragments_refreshed' );
2129                },
2130                success: function( response ) {
2131
2132                    $( document.body ).trigger( 'added_to_cart' ); //Trigger and sent added_to_cart event
2133                    $( document.body ).trigger( 'updated_cart_totals' );
2134                    $( document.body ).trigger( 'wc_fragments_refreshed' );
2135                    $( document.body ).trigger( 'wc_fragments_refresh' );
2136                    $( document.body ).trigger( 'wc_fragment_refresh' );
2137                    
2138                    currentAllSelectedButtonSelector.html(add_cart_text + ' [ ' + itemAmount + ' ' + config_json.add2cart_all_added_text + ' ]');
2139                    
2140                    WPT_NoticeBoard();
2141                    if(config_json.all_selected_direct_checkout === 'yes'){
2142                        window.location.href = checkoutURL;
2143                        return;
2144                    }else if(config_json.all_selected_direct_checkout === 'cart'){
2145                        window.location.href = cartURL;
2146                        return;
2147                    }
2148                    currentAllSelectedButtonSelector.removeClass('disabled');
2149                    currentAllSelectedButtonSelector.removeClass('loading');
2150                    allMessageBox.val('');//3.2.5.5.final10
2151                    tableWrapperTag.removeClass('wpt-ajax-loading');
2152                    
2153                    
2154                    
2155                },
2156                error: function() {
2157                    alert('Failed');
2158                },
2159            });
2160
2161
2162            
2163            currentAllSelectedButtonSelector.removeClass('disabled');
2164            currentAllSelectedButtonSelector.removeClass('loading');
2165            $( document ).trigger( 'wc_fragments_refreshed' );
2166            if(config_json.all_selected_direct_checkout === 'yes'){
2167                window.location.href = checkoutURL;
2168                return;
2169            }
2170            //Quick Cart Button Active here and it will go Directly to Cart Page
2171            if(config_json.product_direct_checkout === 'cart'){
2172                window.location.href = cartURL;
2173                return;
2174            }
2175
2176        });
2177        
2178        $(document.body).on('wpt_ajax_load_data',function(e,data){
2179            var temp_number = data.table_id;
2180            uncheckAllCheck(temp_number);
2181        });
2182        $(document).on( 'reset_data', 'div.advance_table_wrapper .wpt-table-tag.advance_table.wpt_product_table form.cart', function() {
2183            var thisRow = $(this).parents('.wpt-tr-tag.wpt_row');
2184
2185            var temp_number = thisRow.data('temp_number');
2186            var product_id = thisRow.data('product_id');
2187            var quoted_target = 'yith_request_temp_' + temp_number + '_id_' + product_id;
2188            var addToQuoteSelector = $('.' + quoted_target);
2189            var checkBoxSelector = $('.wpt_check_temp_' + temp_number + '_pr_' + product_id);
2190            
2191            thisRow.attr('data-variation_id', '' );
2192            
2193            function enable_disable_class() {
2194                addToQuoteSelector.removeClass('enabled');
2195                addToQuoteSelector.addClass('disabled');
2196                
2197                checkBoxSelector.removeClass('enabled');
2198                checkBoxSelector.addClass('disabled');
2199            }
2200            enable_disable_class();
2201
2202            var skuTDobj = $('#table_id_' + temp_number + ' #product_id_' + product_id + ' .td_or_cell.wpt_sku');
2203            var sku = skuTDobj.data('sku');
2204            skuTDobj.find('div.wpt_sku').html(sku);
2205            
2206        });
2207        $(document).on( 'found_variation', 'div.advance_table_wrapper .wpt-table-tag.advance_table.wpt_product_table form.cart', function( event, variation ) {
2208            var thisRow = $(this).parents('.wpt-tr-tag.wpt_row');
2209
2210            var temp_number = thisRow.data('temp_number');
2211            var product_id = thisRow.data('product_id');
2212            var my_product_id = $(event.currentTarget).parents('.wpt-tr-tag.wpt_row').data('product_id');
2213            
2214            var targetThumbs = $('#table_id_' + temp_number + ' #product_id_' + product_id + ' wpt_thumbnails img');
2215            var quoted_target = 'yith_request_temp_' + temp_number + '_id_' + product_id;
2216            var addToQuoteSelector = $('.' + quoted_target);
2217            var checkBoxSelector = $('.wpt_check_temp_' + temp_number + '_pr_' + product_id);
2218            function targetTD(td_name) {
2219                var targetElement = $('#table_id_' + temp_number + ' #product_id_' + product_id + ' wpt_' + td_name);
2220                return targetElement;
2221            }
2222            var sku = variation.sku;
2223            var skuTDobj = $('#table_id_' + temp_number + ' #product_id_' + product_id + ' div.wpt_sku');
2224            skuTDobj.html(sku);
2225
2226            //Adding selected variation ID adding at row
2227            thisRow.attr('data-variation_id', variation.variation_id );
2228
2229            /**
2230             * Set Variations value to the targetted column's td
2231             * 
2232             * @param {type} target_td_name suppose: weight,description,serial_number,thumbnails etc
2233             * @param {type} gotten_value Suppose: variations description from targatted Object
2234             * @returns {undefined}
2235             */
2236            function setValueToTargetTD_IfAvailable(target_td_name, gotten_value){
2237                if (gotten_value !== "") {
2238                    targetTD(target_td_name).html(gotten_value);
2239                }
2240            }
2241            
2242            /**
2243             * set value for without condition
2244             * 
2245             * @param {type} target_td_name for any td
2246             * @param {type} gotten_value Any valy
2247             * @returns {undefined}
2248             */
2249            function setValueToTargetTD(target_td_name, gotten_value){
2250                targetTD(target_td_name).html(gotten_value);
2251            }
2252            
2253            
2254            
2255            targetThumbs.attr('src', variation.image.gallery_thumbnail_src);
2256            if(variation.image.srcset && 'false' !== variation.image.srcset) {
2257                targetThumbs.attr('srcset', variation.image.srcset);
2258            };
2259            
2260            function disbale_enable_class() {
2261                
2262                /**
2263                 * For Add To Quote
2264                 */
2265                addToQuoteSelector.removeClass('disabled');
2266                addToQuoteSelector.addClass('enabled');
2267
2268                checkBoxSelector.removeClass('disabled');
2269                checkBoxSelector.addClass('enabled');
2270            }
2271            disbale_enable_class();
2272            
2273            
2274            targetThumbs.attr('data-variation_id', variation.variation_id);
2275
2276        });
2277  
2278        
2279        
2280        $('.wpt-wrap').each(function(){
2281            var table_id = $(this).data('temp_number');
2282            var tableEl = $(this).find('.wpt-table-tag.wpt_product_table');
2283            var width = tableEl.width();
2284            $('.wpt_second_wrapper.wpt_second_wrapper_' + table_id + ' div.wpt_second_content').css('width',width);
2285        });
2286                
2287        $(".wpt_table_tag_wrapper").scroll(function () {
2288            $(".wpt_second_wrapper").scrollLeft($(".wpt_table_tag_wrapper").scrollLeft());
2289        });
2290        $(".wpt_second_wrapper").scroll(function () {
2291            $(".wpt_table_tag_wrapper").scrollLeft($(".wpt_second_wrapper").scrollLeft());
2292        }); 
2293        
2294        
2295        /**
2296         * Mainly for Total column
2297         * I just Insert Trigger
2298         * 
2299         * @since 2.7.7
2300         * @date 28.10.2020
2301         */
2302        $('.wpt_product_table input.input-text.qty.text').trigger('change');
2303        
2304         $('.yith-ywraq-add-to-quote').each(function(){
2305             let qty = $(this).closest('.wpt-tr-tag').data('quantity');
2306            $(this).append('<input type="hidden" class="input-text qty text" value="' + qty + '">');
2307        });
2308        
2309    });
2310});

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.