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