1/** 2 * Event Ticket script 3 * @version 2.5.3 4 * @license EventON JavaScript Assets 5 * Copyright (C) 2014-2025 Ashan Jay, AshanJay Designs LLC. 6 * 7 * PROPRIETARY LICENSE - All Rights Reserved 8 * 9 * Permission granted solely for personal use with valid EventON license. 10 * YOU MAY NOT: redistribute, resell, sublicense, or publish these Assets. 11 * 12 * Trademark: "EventON" is a trademark of AshanJay Designs LLC. 13 * Contact: [email protected] 14 * 15 * PROVIDED "AS IS" WITHOUT WARRANTY. VIOLATION MAY RESULT IN LEGAL ACTION. 16 */ 17 18jQuery(document).ready(function($){ 19 20 var BODY = $('body'); 21 22 // ticket data 23 $.fn.evotx_hide_loading = function(O){ 24 el = this; 25 return el.closest('.evorow').find('.evo_loading_bar_holder').remove(); 26 }; 27 $.fn.evotx_get_data = function(O) { 28 const el = this; 29 return el.hasClass('evotx_ticket_purchase_section') 30 ? el.find('.evotx_data').data() 31 : el.closest('.evotx_ticket_purchase_section').find('.evotx_data').data(); 32 }; 33 34 $.fn.evotx_update_data = function(data){ 35 36 el = this; 37 ROW = el.closest('.evorow'); 38 if( el.hasClass('evotx_ticket_purchase_section')) ROW = el; 39 tx_data = ROW.evotx_get_data(); 40 41 var new_tx_data = $.extend({}, tx_data, data ); 42 43 ROW.find('.evotx_data').data( new_tx_data ); 44 }; 45 $.fn.evotx_get_event_data = function(O){ 46 el = this; 47 dd = el.hasClass('evotx_ticket_purchase_section') ? el.find('.evotx_data').data() : 48 el.closest('.evotx_ticket_purchase_section').find('.evotx_data').data(); 49 50 if( dd === undefined ) return false; 51 if( !('event_data' in dd) ) return false; 52 return dd.event_data; 53 }; 54 $.fn.evotx_set_event_data = function(new_event_data){ 55 el = this; 56 dd = el.hasClass('evotx_ticket_purchase_section') ? el.find('.evotx_data').data() : 57 el.closest('.evotx_ticket_purchase_section').find('.evotx_data').data(); 58 59 dd['event_data'] = new_event_data; 60 el.closest('.evorow').data( dd ); 61 }; 62 63 // other data 64 $.fn.evotx_get_all_select_data = function(){ 65 el = this; 66 var other_data = {}; 67 68 pel = el.closest('.evorow'); 69 if( el.hasClass('evotx_ticket_purchase_section')) pel = el; 70 71 pel.find('.evotx_other_data').each(function(ii){ 72 $.each( $(this).data(), function (index, value){ 73 other_data[ index ] = value; 74 }); 75 76 }); 77 78 return other_data; 79 }; 80 $.fn.evotx_get_select_data = function(unique_class){ 81 82 el = this; 83 pel = el.closest('.evorow'); 84 if( el.hasClass('evotx_ticket_purchase_section')) pel = el; 85 86 var other_data = pel.find('.evotx_other_data.'+unique_class).data(); 87 88 return other_data; 89 }; 90 $.fn.evotx_set_select_data = function(unique_class, data){ 91 var $el = this; 92 var $container = $el.hasClass('evotx_ticket_purchase_section') ? $el : $el.closest('.evorow'); 93 var $target = $container.find('.evotx_other_data.' + unique_class); 94 95 if ($target.length === 0) return; 96 97 var current = $target.data() || {}; 98 var updated = $.extend({}, current, data); 99 100 $target.data(updated); 101 102 //console.log(new_data); 103 }; 104 105 // other addon data 106 $.fn.evotx_get_custom_data = function(unique_class){ 107 el = this; 108 pel = el.closest('.evorow'); 109 if( el.hasClass('evotx_ticket_purchase_section')) pel = el; 110 111 var other_data = pel.find('.'+unique_class).data(); 112 return other_data; 113 }; 114 $.fn.evotx_set_custom_data = function(unique_class, data){ 115 116 el = this; 117 pel = el.closest('.evorow'); 118 if( el.hasClass('evotx_ticket_purchase_section')) pel = el; 119 120 dd = pel.evotx_get_custom_data(unique_class); 121 122 pel.find('.'+ unique_class).data( $.extend({}, dd, data ) ); 123 }; 124 125 // price conversions 126 // convert to decimal base number 127 $.fn.EVO_ToNumber = function( priceStr ){ 128 129 if( priceStr === undefined ) return priceStr; 130 131 let cleanPrice = priceStr.toString().trim().replace(/[^0-9.,-]/g, ''); 132 const isNegative = cleanPrice.startsWith('-'); 133 cleanPrice = cleanPrice.replace('-', ''); 134 const lastDot = cleanPrice.lastIndexOf('.'); 135 const lastComma = cleanPrice.lastIndexOf(','); 136 if (lastDot > lastComma) cleanPrice = cleanPrice.replace(/,/g, ''); 137 else if (lastComma > lastDot) cleanPrice = cleanPrice.replace(/\./g, '').replace(',', '.'); 138 return isNaN(cleanPrice = parseFloat(cleanPrice)) ? 0 : isNegative ? -cleanPrice : cleanPrice; 139 } 140 141 // convert to formatted price 142 $.fn.EVO_ToPrice = function(price){ 143 //console.log(price); 144 145 const el = this; 146 const PFD = el.hasClass('evotx_ticket_purchase_section') 147 ? el.find('.evotx_data').data() 148 : el.closest('.evotx_ticket_purchase_section').find('.evotx_data').data(); 149 const PF = { thoSep: evotx_object.thousand_separator, decSep: evotx_object.decimal_separator, currencySymbol: evotx_object.currency_symbol, numDec: evotx_object.decimals, curPos: evotx_object.currency_position, ...this.evotx_get_data()?.pf || {} }; 150 151 // Normalize the price by removing thousand separators and standardizing decimal separator 152 let normalizedPrice = price; 153 const isDecimalNumber = typeof price === 'number' || (typeof price === 'string' && !isNaN(parseFloat(price)) && /^[+-]?\d*\.?\d*$/.test(price)); 154 155 if (!isDecimalNumber && typeof price === 'string') { 156 // Remove thousand separator and standardize decimal separator for formatted strings 157 if (PF.thoSep) { 158 normalizedPrice = normalizedPrice.replaceAll(PF.thoSep, ''); 159 } 160 if (PF.decSep !== '.') { 161 normalizedPrice = normalizedPrice.replace(PF.decSep, '.'); 162 } 163 } 164 165 const number = parseFloat(normalizedPrice); 166 if (isNaN(number)) return PF.currencySymbol + '0' + PF.decSep + '00'; 167 168 const isNegative = number < 0, absNumber = Math.abs(number); 169 let formattedPrice = absNumber.toFixed(PF.numDec).replace('.', PF.decSep); 170 171 if (PF.thoSep) { 172 const [intPart, decPart] = formattedPrice.split(PF.decSep); 173 formattedPrice = intPart.replace(/\B(?=(\d{3})+(?!\d))/g, PF.thoSep) + (decPart ? PF.decSep + decPart : ''); 174 } 175 176 //console.log(formattedPrice); 177 178 formattedPrice = isNegative ? '-' + formattedPrice : formattedPrice; 179 return PF.curPos === 'right' ? formattedPrice + PF.currencySymbol : 180 PF.curPos === 'right_space' ? formattedPrice + ' ' + PF.currencySymbol : 181 PF.curPos === 'left_space' ? PF.currencySymbol + ' ' + formattedPrice : 182 PF.currencySymbol + formattedPrice; 183 } 184 185 186// on change variable product selection 187 $('body').on('change','table.variations select',function(){ 188 CART = $(this).closest('table').siblings('.evotx_orderonline_add_cart'); 189 STOCK = CART.find('p.stock'); 190 191 // check if variable products are out of stock 192 if(STOCK.hasClass('out-of-stock')){ 193 CART.find('.variations_button').hide(); 194 }else{ 195 CART.find('.variations_button').show(); 196 } 197 });
198 199 200// get ticket product total price 201 $('body').on('evotx_qty_changed', function(event,QTY, MAX, OBJ ){ 202 SECTION = OBJ.closest('.evotx_ticket_purchase_section'); 203 $('body').trigger('evotx_calculate_total', [SECTION]); 204 }); 205 206// calculate total price 207 $('body').on('evotx_calculate_total', function(event, SECTION ){ 208 209 QTY = SECTION.find('input[name=quantity]').val(); 210 sin_price = SECTION.find('p.price.tx_price_line span.value').data('sp'); 211 price_extra = 0; 212 213 // price format data 214 var tx_data = SECTION.evotx_get_data(); 215 var price_format_data = tx_data.pf; 216 217 // single ticket price 218 sin_price = SECTION.EVO_ToNumber( sin_price ); 219 220 //console.log( sin_price); 221 222 if( SECTION.find('p.price.tx_price_line').length == 0 ){ 223 var sin_price = SECTION.find('.evotx_orderonline_add_cart bdi').text() 224 .replace( price_format_data.currencySymbol , '').trim(); 225 226 if( sin_price == '' || sin_price === undefined ) return; 227 228 // convert text string to number 229 sin_price = SECTION.EVO_ToNumber( sin_price ); 230 //console.log( sin_price); 231 } 232 233 // include sin price additions 234 if( SECTION.find('p.price.tx_price_line input').length>0){ 235 236 SECTION.find('p.price.tx_price_line input').each(function(){ 237 if( $(this).hasClass('nyp')) return; 238 239 DATA = SECTION.find('p.price.tx_price_line input').data('prices'); 240 //console.log(DATA); 241 242 if(DATA === undefined) return; 243 244 price_muli = 0; 245 price_extra = 0; 246 if( Object.keys(DATA).length>0){ 247 $.each(DATA, function(index, val){ 248 249 if( val === undefined) return; 250 if( !('price') in val) return; 251 if( val.price === undefined) return; 252 253 p = SECTION.EVO_ToNumber(val.price ); 254 p = p * parseInt( val.qty); 255 256 // uncorrelated and extra price items 257 if( ('pt' in val && val.pt == 'extra') || ('uncor' in val && val.uncor) ){ 258 price_extra += p; 259 }else{ 260 price_muli += p; 261 } 262 263 }) 264 } 265 266 sin_price += price_muli; 267 }); 268 } 269 270 new_price = sin_price * QTY; 271 new_price += price_extra; 272 273 //console.log(new_price); 274 275 // formating 276 new_price = SECTION.EVO_ToPrice( new_price ); 277 //console.log(new_price); 278 279 //console.log(new_price); 280 SECTION.find('.evotx_addtocart_total span.value').html( new_price); 281 }); 282 283// GET format the price -- deprecating 2.4.15 284 function get_format_price(price, SECTION){ 285 return SECTION.EVO_ToPrice( price ); 286 } 287 288 // convert a formatted price to decimal number 289 function __raw_price_to_number( price_string, SECTION){ 290 return SECTION.EVO_ToNumber( price_string ); 291 } 292 function _addThousandSep(n, thoSep){ 293 var rx= /(\d+)(\d{3})/; 294 return String(n).replace(/^\d+/, function(w){ 295 while(rx.test(w)){ 296 w= w.replace(rx, '$1'+thoSep+'$2'); 297 } 298 return w; 299 }); 300 }; 301 302// increase and reduce quantity 303 $('body').on('click','.evotx_qty_change', function(event){ 304 305 OBJ = $(this); 306 307 if(OBJ.closest('.evotx_quantity').hasClass('one')) return; 308 309 QTY = parseInt(OBJ.siblings('em').html()); 310 MAX = OBJ.siblings('input').data('max'); 311 312 // plug
313 $('body').trigger('evotx_before_qty_changed',[ MAX, OBJ]); 314 315 if(!MAX) MAX = OBJ.siblings('input').attr('max'); 316 317 318 NEWQTY = (OBJ.hasClass('plu'))? QTY+1: QTY-1; 319 320 NEWQTY =(NEWQTY <= 0)? 0: NEWQTY; 321 322 323 // can not go below 1 324 if( NEWQTY == 0 && OBJ.hasClass('min') && !OBJ.hasClass('zpos')){ 325 return; 326 } 327 328 NEWQTY = (MAX!='' && NEWQTY > MAX)? MAX: NEWQTY; 329 330 OBJ.siblings('em').html(NEWQTY); 331 OBJ.siblings('input').val(NEWQTY); 332 333 //console.log(MAX); 334 335 if( QTY != NEWQTY) $('body').trigger('evotx_qty_changed',[NEWQTY, MAX, OBJ]); 336 337 if(NEWQTY == MAX){ 338 339 PLU = OBJ.parent().find('b.plu'); 340 if(!PLU.hasClass('reached')) PLU.addClass('reached'); 341 342 if(QTY == MAX) $('body').trigger('evotx_qty_max_reached',[NEWQTY, MAX, OBJ]); 343 }else{ 344 OBJ.parent().find('b.plu').removeClass('reached'); 345 } 346 }); 347 348// on triggers for variations form 349 $('body').on('reset_data','form.evotx_orderonline_variable',function(event){ 350 FORM = $(this); 351 FORM.find('.evotx_variation_purchase_section').hide(); 352 }); 353 354 $('body').on('evolightbox_end',function(){ 355 $('body').trigger('show_variation'); 356 }); 357 $('body').on('show_variation','form.evotx_orderonline_variable',function(event, variation, purchasable){ 358 FORM = $(this); 359 360 // variation not in stock 361 if(!variation.is_in_stock){ 362 FORM.find('.evotx_variations_soldout').show(); 363 FORM.find('.evotx_variation_purchase_section').hide(); 364 }else{ 365 FORM.find('.evotx_variations_soldout').hide(); 366 FORM.find('.evotx_variation_purchase_section').show(); 367 } 368 369 if(variation.sold_individually){ 370 FORM.find('.evotx_quantity').hide(); 371 } 372 373 NEWQTY = parseInt(FORM.find('.evotx_quantity_adjuster em').html()); 374 NEWQTY = (variation.max_qty!= '' && NEWQTY > variation.max_qty)? variation.max_qty: NEWQTY; 375 376 FORM.find('.evotx_quantity_adjuster em').html( NEWQTY); 377 FORM.find('.evotx_quantity_adjuster input').val( NEWQTY); 378 }); 379 380// Standalone button u2.4 381 BODY.on('click','.trig_evotx_btn',function(){ 382 // get form html 383 var ajaxdataa = {}; 384 385 ajaxdataa['action'] = 'evotx_standalone_form'; 386 ajaxdataa['data'] = $(this).data(); 387 388 389 BODY.evo_lightbox_open({ 390 'uid': 'evotx_standalone_ticket', 391 'lbc': 'evotx_standalone_ticket', 392 'ajax':'yes', 393 'end':'client', 394 'd': ajaxdataa 395 }); 396 397 398 }).on('evo_ajax_success_evotx_standalone_ticket',function(event, OO, data, el){ 399 LB = BODY.find('.evo_lightbox.'+ OO.lightbox_key ); 400 $('body').trigger('evotx_standlone_loaded',[ LB, data ]); 401 }); 402 403// Add to cart custom method 404// this method is used by ticket addons when adding tickets to cart and simple ticket product 405// @version 1.7 @updated 2.5 406 $('body').on('click', '.evotx_addtocart', function(event){ 407 408 event.preventDefault(); 409 410 // make sure the button is good to go 411 if( $(this).data('green') != 'y') return; 412 413 var BTN = $(this); 414 var SECTION = BTN.closest('.evotx_ticket_purchase_section'); 415 const ajaxdata = { action: 'evotx_add_to_cart' }; 416 417 ajaxdata.event_data = SECTION.evotx_get_event_data(); 418 ajaxdata.other_data = SECTION.evotx_get_all_select_data(); 419 420 ajaxdata['qty'] = SECTION.find('input[name="quantity"]').val(); 421 ajaxdata['nyp'] = SECTION.find('input[name="nyp"]').val(); 422 ajaxdata['action'] = 'evotx_add_to_cart'; 423 424 if( ajaxdata['qty'] === undefined && BTN.hasClass('si')) ajaxdata.qty = 1; 425 426 // gather other input fields 427 SECTION.find('input').each(function(){ 428 if( $(this).attr('name') === undefined) return; 429 if( $(this).attr('name') == 'add-to-cart') return; 430 ajaxdata[ $(this).attr('name') ] = $(this).val(); 431 }); 432 433 // check for quantity 434 if (!ajaxdata.qty || ajaxdata.qty == 0) { 435 SECTION.evotx_show_msg({'status':'bad','msg':'t5'}); 436 return false; 437 } 438 439 440 441 $.ajax({
442 beforeSend: function(){ 443 BTN.addClass('evobtn_loader full w'); 444 //SECTION.addClass( 'evoloading'); 445 }, 446 url: evotx_object.ajaxurl, 447 data: ajaxdata, dataType:'json', type: 'POST', 448 success:function(data){ 449 450 if( data.status == 'good'){ 451 452 $('body').trigger('evotx_added_to_cart',[ data, SECTION, ajaxdata ]); 453 454 SECTION.evotx_show_msg({'msg': data.msg}); 455 456 // if need to be redirected to cart after adding 457 if(evotx_object.redirect_to_cart == 'cart'){ 458 window.location.href = evotx_object.cart_url; 459 }else if( evotx_object.redirect_to_cart =='checkout'){ 460 window.location.href = evotx_object.checkout_url; 461 }else{ 462 update_wc_cart(); 463 } 464 }else{ 465 SECTION.evotx_show_msg({'status':'bad','msg':data.msg }); 466 } 467 468 },complete:function(){ 469 BTN.removeClass('evobtn_loader full w'); 470 SECTION.removeClass( 'evoloading'); 471 } 472 }); 473 }); 474 475// name your price 476 $(document).on('keypress',function(e){ 477 var obj = $(e.target); 478 if(e.which == 13 && obj.hasClass('nyp') ){ 479 e.preventDefault(); 480 return; 481 } 482 }); 483 $('body').on('change','input.nyp',function(){ 484 485 const EVOROW = $(this).closest('.evorow'); 486 const TIX_SECTION = EVOROW.find('.evotx_ticket_purchase_section'); 487 488 // currency > decimal number 489 const typed_price = __raw_price_to_number( $(this).val() , TIX_SECTION ); 490 491 $(this).parent().data('sp', typed_price); // update data with types price number 492 493 var min_nyp = parseFloat( $(this).data('minnyp') ); // minimum price already in decimal 494 495 console.log( $(this).val()+' '+typed_price +' '+ min_nyp); 496 497 // min price higher than 0 498 if( min_nyp > 0 ){ 499 // price is less than minimum 500 if(typed_price < min_nyp){ 501 502 TIX_SECTION.evotx_show_msg({'status':'bad','msg':'t6','hide_hidables':false}); 503 EVOROW.find('.evotx_addtocart').data('green','n'); 504 // price is good 505 }else{ 506 EVOROW.find('.evotx_addtocart').data('green','y'); 507 TIX_SECTION.evotx_hide_msg(); 508 $('body').trigger('evotx_calculate_total', [ $(this).closest('.evotx_ticket_purchase_section') ]); 509 } 510 // minimum price less than 0 511 }else{ 512 $('body').trigger('evotx_calculate_total', [ $(this).closest('.evotx_ticket_purchase_section') ]); 513 } 514 515 }); 516 517// Show add to cart notification messages @2.2.10 518 $.fn.evotx_show_msg = function(opt){ 519 var defs = { 520 'msg':'', 521 'status':'good', 522 'hide': false, 523 'hide_hidables': true, 524 'show_btn':true 525 } 526 var OO = $.extend({}, defs, opt); 527 el = $(this); 528 const TIX_SECTION = el.hasClass('evotx_ticket_purchase_section') ? 529 el : el.closest('.evotx_ticket_purchase_section'); 530 const msg_el = TIX_SECTION.find('.tx_wc_notic'); 531 var evotx_data = TIX_SECTION.evotx_get_data(); 532 533 var msg_data = evotx_data.msg_interaction; 534 535 //console.log(OO); 536 //console.log(msg_data); 537 538 // button 539 if( OO.show_btn && OO.status == 'good'){ 540 TIX_SECTION.find('.evotx_cart_actions').show(); 541 }else{ 542 TIX_SECTION.find('.evotx_cart_actions').hide(); 543 } 544 545 // get message content 546 var message = OO.msg; 547 const TT = evotx_data && 't' in evotx_data ? evotx_data.t : null; 548 549 if( TT != null && OO.msg in TT ) message = TT[ OO.msg ]; 550 if( message == '' || message === undefined ) message = OO.status == 'good' ? TT.t1 : TT.t4; 551 552 // strip slashes @since 2.2.5 553 message = message.replace(new RegExp("\\\\", "g"), ""); 554 555 msg_el.html( "<p class='evotx_success_msg "+ OO.status +"'>"+ message +"</p>").show(); 556 557 // hide the message 558 if( msg_data.hide_after == true || OO.hide ){ 559 setTimeout(function(){ 560 $(TIX_SECTION).find('.evotx_addtocart_msg').hide(); 561 }, 3000); 562 } 563 564 // redirecting 565 if(msg_data.redirect != 'nonemore' && OO.hide_hidables){ 566 // hide only the hidable section 567 $(TIX_SECTION).find('.evotx_hidable_section').hide(); 568 } 569 570 }; 571 $.fn.evotx_hide_msg = function(){ 572 var el = $(this); 573 const TIX_SECTION = el.hasClass('evotx_ticket_purchase_section') ? 574 el : el.closest('.evotx_ticket_purchase_section');
575 const msg_el = TIX_SECTION.find('.tx_wc_notic'); 576 577 msg_el.hide(); 578 579 580 TIX_SECTION.find('.evotx_addtocart_msg').hide(); 581 }; 582 583 $('body').on('evotx_ticket_msg', function(event, EVOROW, STATUS, bad_msg, hide_hidables){ 584 585 $(EVOROW).evotx_show_msg({ 586 'status': STATUS, 587 'hide_hidables': hide_hidables, 588 'msg': bad_msg 589 }); 590 return; 591 }); 592 $('body').on('evotx_ticket_msg_hide',function(event, EVOROW){ 593 $(EVOROW).evotx_hide_msg(); 594 }); 595 596// click add to cart for variable product 597// OLD Method -- DEPRECATING 598 $('body').on('click','.evoAddToCart', function(e){ 599 600 e.preventDefault(); 601 thisButton = $(this); 602 603 // loading animation 604 thisButton.closest('.evoTX_wc').addClass('evoloading'); 605 606 // Initial 607 TICKET_ROW = thisButton.closest('.evo_metarow_tix'); 608 PURCHASESEC = TICKET_ROW.find('.evoTX_wc'); 609 610 // set cart item additional data 611 var ticket_row = thisButton.closest('.evo_metarow_tix'); 612 var event_id = ticket_row.attr('data-event_id'); 613 var ri = ticket_row.attr('data-ri'); 614 var lang = thisButton.data('l'); 615 var event_location = thisButton.closest('.evcal_eventcard').find('.evo_location_name').html(); 616 617 event_location = (event_location !== undefined && event_location != '' )? 618 encodeURIComponent(event_location):''; 619 620 // passing location values 621 location_str = event_location!= ''? '&eloc='+event_location: ''; 622 623 // pass lang 624 lang_str = ( lang !== undefined)? '&lang='+lang:''; 625 626 //console.log(event_location); 627 628 // variable item 629 if(thisButton.hasClass('variable_add_to_cart_button')){ 630 631 var variation_form = thisButton.closest('form.variations_form'), 632 variations_table = variation_form.find('table.variations'), 633 singleVariation = variation_form.find('.single_variation p.stock'); 634 635 // Stop processing is out of stock 636 if(singleVariation.hasClass('out-of-stock')){ 637 return; 638 } 639 640 var product_id = parseInt(variation_form.attr('data-product_id')); 641 var variation_id = parseInt(variation_form.find('input[name=variation_id]').val()); 642 var quantity = parseInt(variation_form.find('input[name=quantity]').val()); 643 644 quantity = (quantity=== undefined || quantity == '' || isNaN(quantity)) ? 1: quantity; 645 646 values = variation_form.serialize(); 647 648 var attributes =''; 649 variations_table.find('select').each(function(index){ 650 attributes += '&'+ $(this).attr('name') +'='+ $(this).val(); 651 }); 652 653 // get data from the add to cart form 654 dataform = thisButton.closest('.variations_form').serializeArray(); 655 var data_arg = dataform; 656 657 $.ajax({
658 type: 'POST',data: data_arg, 659 url: '?add-to-cart='+product_id+'&variation_id='+variation_id+attributes+'&quantity='+quantity +'&ri='+ri+'&eid='+event_id + location_str + lang_str, 660 beforeSend: function(){ 661 $('body').trigger('adding_to_cart'); 662 }, 663 success: function(response, textStatus, jqXHR){ 664 665 // Show success message 666 thisButton.evotx_show_msg(); 667 668 }, complete: function(){ 669 thisButton.closest('.evoTX_wc').removeClass('evoloading'); 670 671 // if need to be redirected to cart after adding 672 if(evotx_object.redirect_to_cart == 'cart'){ 673 window.location.href = evotx_object.cart_url; 674 }else if( evotx_object.redirect_to_cart =='checkout'){ 675 window.location.href = evotx_object.checkout_url; 676 }else{ 677 update_wc_cart(); 678 } 679 } 680 }); 681 } 682 683 // simple product add to cart method is deprecated since 1.8 684 return false; 685 }); 686 687// Update mini cart content 688 $('body').on('evo_update_wc_cart',function(){ 689 update_wc_cart(); 690 }); 691 function update_wc_cart(){ 692 693 var data = { 694 action: 'evoTX_ajax_09' 695 }; 696 697 $.ajax({
698 type: 'POST', 699 url: evotx_object.ajaxurl, 700 data: data, 701 dataType: 'json', 702 success: function(response) { 703 704 if (!response || !response.fragments) return; 705 706 var fragments = response.fragments; 707 var cart_hash = response.cart_hash; 708 709 // Update fragments 710 $.each(fragments, function(key, value) { 711 $(key).replaceWith(value); 712 }); 713 714 // Trigger WooCommerce events 715 $(document.body).trigger('wc_fragments_refreshed'); 716 $(document.body).trigger('wc_fragments_loaded'); 717 $(document.body).trigger('added_to_cart', [fragments, cart_hash]); 718 719 // Optional: Refresh block-based mini cart (if using blocks) 720 $(document.body).trigger('wc_fragment_refresh'); 721 722 if (typeof wc !== 'undefined') { 723 $(document.body).trigger('wc-blocks-updated'); 724 } 725 }, 726 error: function() { 727 console.log('Error updating cart'); 728 } 729 }); 730 } 731 732// inquiry submissions 733 $('body').on('click','.evotx_INQ_submit', function(event){ 734 event.preventDefault(); 735 736 const LB = $(this).closest('.evo_lightbox'); 737 var form = LB.find('.evotxINQ_form'); 738 739 //reset 740 form.find('.evotxinq_field').removeClass('error'); 741 742 var data = { action: 'evotx_ajax_06' }; 743 744 // validate captcha 745 var human = validate_human( form.find('input.captcha') ); 746 if(!human){ 747 form.find('input.captcha').addClass('error'); 748 LB.evo_lightbox_show_msg({ 749 'type': 'bad', 750 'message':evotx_object.text['003'], 751 }); 752 return; 753 } 754 755 // empty fields 756 var error = false; 757 form.find('input, textarea').each(function(index){ 758 if( $(this).val()==''){ 759 error = true; 760 $(this).addClass('error'); 761 } 762 data[$(this).attr('name')] = $(this).val(); 763 }); 764 765 if( error ){ 766 LB.evo_lightbox_show_msg({ 767 'type': 'bad', 768 'message':evotx_object.text['002'], 769 }); 770 return; 771 } 772 773 774 // submit form 775 LB.evo_admin_get_ajax({ 776 'lightbox_key':'evotx_inqure_form', 777 'uid':'evotx_inqure_submit', 778 'ajaxdata': data, 779 'end':'client' 780 }); 781 }); 782 783 // validate humans 784 function validate_human(field){ 785 if(field==undefined){ 786 return true; 787 }else{ 788 var numbers = ['11', '3', '6', '3', '8']; 789 if(numbers[field.attr('data-cal')] == field.val() ){ 790 return true; 791 }else{ return false;} 792 } 793 } 794 795// add to cart button from eventtop 796 $('body').on('click','.evotx_add_to_cart em', function(){ }); 797 798 // hover over guests list icons 799 $('body').on('mouseover','.evotx_whos_coming span', function(){ 800 OBJ = $(this); 801 EM = OBJ.parent().find('em.tooltip'); 802 TEXT = OBJ.data('name'); 803 804 POS = OBJ.position(); 805 806 EM.css({'left':(POS.left+20), 'top':(POS.top-30)}).html(TEXT).show(); 807 }); 808 $('body').on('mouseout','.evotx_whos_coming span', function(){ 809 OBJ = $(this); 810 EM = OBJ.parent().find('em.tooltip'); 811 EM.hide(); 812 }); 813 814// My account view ticket @2.4 815 BODY.on('click','.evotx_view_ticket',function(){ 816 817 818 // get form html 819 var ajaxdataa = {}; 820 821 ajaxdataa['action'] = 'evotx_my_account_ticket'; 822 ajaxdataa['tn'] = $(this).data('tn'); 823 824 825 BODY.evo_lightbox_open({ 826 'uid': 'evotx_ac_view_ticket', 827 'lbc': 'evotx_ac_view_ticket', 828 'lb_padding':'evopad0', 829 'ajax':'yes', 830 'end':'client', 831 'd': ajaxdataa 832 }); 833 });
834 835// Ticket Waitlist 836 $('body').on('evo_ajax_success_evotxw_form_submit',function(e, OO, data , el){ 837 const event_id = OO.ajaxdata.eid; 838 const ri = OO.ajaxdata.ri; 839 const wl_box = $(document).find('.evotxw_waitlist_size_'+event_id+'_'+ ri ); 840 const new_wl_count = data.new_waitlist_size; 841 842 wl_box.text( new_wl_count ); 843 }); 844 845// ActionUser event manager 846 // show ticket stats for events 847 $('#evoau_event_manager').on('click','a.load_tix_stats',function(event){ 848 event.preventDefault(); 849 MANAGER = $(this).closest('.evoau_manager'); 850 var data_arg = { 851 action: 'evotx_ajax_get_auem_stats', 852 eid: $(this).data('eid') 853 }; 854 $.ajax({ 855 beforeSend: function(){ 856 MANAGER.find('.eventon_actionuser_eventslist').addClass('evoloading'); 857 }, 858 type: 'POST', 859 url:evotx_object.ajaxurl, 860 data: data_arg, 861 dataType:'json', 862 success:function(data){ 863 $('body').trigger('evoau_show_eventdata',[MANAGER, data.html, true]); 864 },complete:function(){ 865 MANAGER.find('.eventon_actionuser_eventslist').removeClass('evoloading'); 866 } 867 }); 868 }); 869 // Open ticket data 870 $(document).on('click','.evotxVA_ticket',function(e){ 871 $(this).find('.evotxVA_data').toggle(); 872 $(this).find('.fa_icon_ind').toggleClass('fa-chevron-down fa-chevron-up'); 873 }); 874 875 // check in attendees 876 $('body').on('click','.evotx_status', function(){ 877 var obj = $(this); 878 if(obj.hasClass('refunded')) return false; 879 if( obj.data('gc')== false) return false; 880 881 var data_arg = { 882 action: 'the_ajax_evotx_a5', 883 tid: obj.data('tid'), 884 tiid: obj.data('tiid'), 885 status: obj.data('status'), 886 }; 887 $.ajax({
888 beforeSend: function(){ obj.html( obj.html()+'...' ); }, 889 type: 'POST', 890 url:evotx_object.ajaxurl, 891 data: data_arg, 892 dataType:'json', 893 success:function(data){ 894 obj.data('status', data.new_status) 895 obj.html(data.new_status_lang).removeAttr('class').addClass('evotx_status '+ data.new_status); 896 897 } 898 }); 899 }); 900 // open incompleted orders 901 $('.evoau_manager_event_content').on('click','span.evotx_incomplete_orders',function(){ 902 $(this).closest('table').find('td.hidden').toggleClass('bad'); 903 }); 904});
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.