1// JavaScript Document 2function wp_easycart_init_location_buttons() { 3 if ( jQuery( '.wpeasycart-location-popup' ).length ) { 4 jQuery( '.wpeasycart-location-popup' ).appendTo( 'body' ); 5 if ( 0 == Number( wpeasycart_ajax_object.location_id ) ) { 6 jQuery( '.wpeasycart-location-popup' ).fadeIn(); 7 wpeasycart_trigger_location_geo(); 8 } 9 jQuery( '.wpeasycart-location-popup-find-btn' ).on( 'click', function() { 10 jQuery( '.wpeasycart-location-list-loader' ).show(); 11 jQuery( '.wpeasycart-location-list' ).html( '' ); 12 var data = { 13 action: 'ec_ajax_location_search', 14 search: jQuery( '#wpeasycart_location_input' ).val(), 15 nonce: jQuery( '#wpeasycart_location_nonce' ).val() 16 }; 17 jQuery.ajax( { 18 url: wpeasycart_ajax_object.ajax_url, 19 type: 'post', 20 data: data, 21 cache: false, 22 success: function( response ){ 23 jQuery( '.wpeasycart-location-list-loader' ).hide(); 24 if ( response.data.locations ) { 25 wpeasycart_load_locations( response.data.locations ); 26 } 27 } 28 } ); 29 } ); 30 jQuery( '.wpeasycart-location-popup-use-location-btn' ).on( 'click', function() { 31 wpeasycart_trigger_location_geo(); 32 } ); 33 jQuery( document ).on( 'click', '.wpeasycart-location-popup-select-store-btn', function() { 34 jQuery( '.wpeasycart-location-list-loader' ).show(); 35 jQuery( '.wpeasycart-location-list' ).html( '' ); 36 var data = { 37 action: 'ec_ajax_location_set_selected', 38 location_id: jQuery( this ).attr( 'data-location-id' ), 39 nonce: jQuery( '#wpeasycart_location_nonce' ).val() 40 }; 41 jQuery.ajax( { 42 url: wpeasycart_ajax_object.ajax_url, 43 type: 'post', 44 data: data, 45 cache: false, 46 success: function( response ){ 47 location.reload(); 48 } 49 } ); 50 } ); 51 jQuery( '.wpeasycart-location-popup-modal-close-btn' ).on( 'click', function() { 52 jQuery( '.wpeasycart-location-popup' ).fadeOut(); 53 } ); 54 jQuery( '.ec_product_select_location' ).on( 'click', function() { 55 jQuery( '.wpeasycart-location-popup' ).fadeIn(); 56 if ( jQuery( this ).attr( 'data-product-id' ) ) { 57 wpeasycart_trigger_location_geo( Number( jQuery( this ).attr( 'data-product-id' ) ) ); 58 } else if ( jQuery( this ).attr( 'data-type' ) && 'cart' == jQuery( this ).attr( 'data-type' ) ) { 59 wpeasycart_trigger_location_geo( false, 'cart' ); 60 } else { 61 wpeasycart_trigger_location_geo(); 62 } 63 } ); 64 } 65} 66jQuery( document ).ready( function( ){ 67 wp_easycart_init_location_buttons(); 68 if ( jQuery( '#wpeasycart_cart_holder' ).length ) { 69 wpeasycart_load_cart( jQuery( '#wpeasycart_cart_holder' ).data( 'cart-page' ), jQuery( '#wpeasycart_cart_holder' ).data( 'success-code' ), jQuery( '#wpeasycart_cart_holder' ).data( 'error-code' ), jQuery( '#wpeasycart_cart_holder' ).data( 'language' ), jQuery( '#wpeasycart_cart_holder' ).data( 'nonce' ) ) 70 } 71 if ( jQuery( '#wpeasycart_account_holder' ).length ) { 72 wpeasycart_load_account( jQuery( '#wpeasycart_account_holder' ).data( 'account-page' ), jQuery( '#wpeasycart_account_holder' ).data( 'page-id' ), jQuery( '#wpeasycart_account_holder' ).data( 'success-code' ), jQuery( '#wpeasycart_account_holder' ).data( 'error-code' ), jQuery( '#wpeasycart_account_holder' ).data( 'language' ), jQuery( '#wpeasycart_account_holder' ).data( 'nonce' ), jQuery( '#wpeasycart_account_holder' ).data( 'form-only' ) ) 73 } 74 if ( jQuery( '.ec_product_quickview_container' ).length ) { 75 jQuery( '.ec_product_quickview_container' ).each( function() { 76 jQuery( this ).appendTo( document.body ); 77 } ); 78 } 79 if ( jQuery( '.ec_add_to_cart_form, input[type="number"].ec_quantity' ).length ) { 80 jQuery( '.ec_add_to_cart_form, input[type="number"].ec_quantity' ).on( 'keypress', function( e ) { 81 if ( ! jQuery( e.target ).is( 'textarea' ) && e.which == 13 ) { 82 return false; 83 } 84 } ); 85 } 86 jQuery( '.ec_flipbook_left' ).click( 87 function( event ){ 88 var current_image = jQuery( event.target ).parent( ).find( 'img.ec_flipbook_image' ).attr( 'src' ); 89 var image_list_string = jQuery( event.target ).parent( ).data( 'image-list' ); 90 var image_list = image_list_string.split( ',' ).filter( item => item !== '' ); 91 var prev = image_list[image_list.length - 1]; 92 for( var i=0; i<image_list.length; i++ ){ 93 if( image_list[i] == current_image ){ 94 break; 95 }else{ 96 prev = image_list[i]; 97 } 98 } 99 jQuery( event.target ).parent( ).find( 'img.ec_flipbook_image' ).attr( 'src', prev ); 100 } 101 ); 102 jQuery( '.ec_flipbook_right' ).click( 103 function( event ){ 104 var current_image = jQuery( event.target ).parent( ).find( 'img.ec_flipbook_image' ).attr( 'src' ); 105 var image_list_string = jQuery( event.target ).parent( ).data( 'image-list' ); 106 var image_list = image_list_string.split( ',' ).filter( item => item !== '' ); 107 var prev = image_list[0]; 108 for( var i=image_list.length-1; i>-1; i-- ){ 109 if( image_list[i] == current_image ){ 110 break; 111 }else{ 112 prev = image_list[i]; 113 } 114 } 115 jQuery( event.target ).parent( ).find( 'img.ec_flipbook_image' ).attr( 'src', prev ); 116 } 117 ); 118 jQuery( '.ec_product_shortcode .owl-carousel' ).each( function( ){ 119 jQuery( this ).on({ 120 'initialized.owl.carousel': function( ){ 121 jQuery( this ).find( '.wp-easycart-carousel-item' ).show( ); 122 jQuery( this ).parent( ).find( '.wpec-product-slider-loader' ).hide( ); 123 } 124 125 }).owlCarousel( JSON.parse( jQuery( this ).attr( 'data-owl-options' ) ) ); 126 } ); 127 wpeasycart_cart_billing_country_update( ); 128 wpeasycart_cart_shipping_country_update( ); 129 wpeasycart_account_billing_country_update( ); 130 wpeasycart_account_shipping_country_update( ); 131 jQuery( document.getElementById( 'ec_cart_billing_country' ) ).change( function( ){ wpeasycart_cart_billing_country_update( ); } ); 132 jQuery( document.getElementById( 'ec_cart_shipping_country' ) ).change( function( ){ wpeasycart_cart_shipping_country_update( ); } ); 133 jQuery( document.getElementById( 'ec_account_billing_information_country' ) ).change( function( ){ wpeasycart_account_billing_country_update( ); } ); 134 jQuery( document.getElementById( 'ec_account_shipping_information_country' ) ).change( function( ){ wpeasycart_account_shipping_country_update( ); } ); 135 if( jQuery( '.ec_menu_mini_cart' ).length ){ 136 jQuery( document.getElementById( 'ec_card_number' ) ).keydown( function( ){ 137 ec_show_cc_type( ec_get_card_type( jQuery( document.getElementById( 'ec_card_number' ) ).val( ) ) ) 138 } ); 139 // Load cart menu, updates over possible cached value 140 var data = { 141 action: 'ec_ajax_get_dynamic_cart_menu', 142 language: wpeasycart_ajax_object.current_language, 143 nonce: jQuery( '.ec_menu_mini_cart' ).attr( 'data-nonce' ) 144 }; 145 jQuery.ajax( { 146 url: wpeasycart_ajax_object.ajax_url, 147 type: 'post', 148 data: data, 149 cache: false, 150 success: function( data ){ 151 jQuery( '.ec_menu_mini_cart' ).html( data ); 152 } 153 } ); 154 } 155 if ( jQuery( '.wp-easycart-widget-cart-quantity' ).length ) { 156 var data = { 157 action: 'ec_ajax_get_dynamic_cart_total', 158 language: wpeasycart_ajax_object.current_language, 159 nonce: jQuery( '.wp-easycart-widget-cart-quantity' ).attr( 'data-nonce' ) 160 }; 161 jQuery.ajax( { 162 url: wpeasycart_ajax_object.ajax_url, 163 type: 'post', 164 data: data, 165 cache: false, 166 success: function( data ){ 167 jQuery( '.wp-easycart-widget-cart-quantity' ).html( data ); 168 } 169 } ); 170 } 171 if( wpeasycart_isTouchDevice( ) ){ 172 jQuery( '.ec_product_quickview' ).hide( ); 173 } 174 if( jQuery( document.getElementById( 'ec_card_number' ) ).length ){ 175 jQuery( document.getElementById( 'ec_card_number' ) ).payment( 'formatCardNumber' ); 176 } 177 if( jQuery( document.getElementById( 'ec_cc_expiration' ) ).length ){ 178 jQuery( document.getElementById( 'ec_cc_expiration' ) ).payment( 'formatCardExpiry' ); 179 } 180 if( jQuery( document.getElementById( 'ec_security_code' ) ).length ){ 181 jQuery( document.getElementById( 'ec_security_code' ) ).payment( 'formatCardCVC' ); 182 } 183 184 if( jQuery( '.ec_is_datepicker' ).length ){ 185 jQuery( '.ec_is_datepicker' ).datepicker( ); 186 } 187 188 if( jQuery( '.ec_details_customer_review_list' ).length ){ 189 jQuery( '.ec_details_customer_review_list' ).each( function( ){ 190 var reviews = jQuery( this ).find( 'li' );
191 var product_id = jQuery( this ).attr( 'data-product-id' ); 192 var reviews_per_page = jQuery( document.getElementById( 'ec_details_reviews_per_page_' + product_id ) ).val( ); 193 if( reviews.length > reviews_per_page ){ 194 var paging = '<div class="ec_details_customer_review_paging" id="ec_details_customer_review_paging_' + product_id + '">'; 195 for( var i=0; i<Math.ceil( reviews.length / reviews_per_page ); i++ ){ 196 paging += '<button onclick="ec_customer_review_paging( ' + (i+1) + ', ' + product_id + ' );">' + ( i + 1 ) + '</button>'; 197 } 198 paging += '</div>'; 199 jQuery( this ).after( paging ); 200 ec_customer_review_paging(1, product_id); 201 } 202 } ); 203 } 204 if( jQuery( '.ec_product_sidebar_filter_item' ).length ){ 205 jQuery( '.ec_product_sidebar_filter_item' ).on( 'click', function( ){ 206 if( jQuery( this ).hasClass( 'selected' ) ){ 207 jQuery( this ).removeClass( 'selected' ); 208 }else{ 209 jQuery( this ).addClass( 'selected' ); 210 } 211 var filter_ids = []; 212 jQuery( '.ec_product_sidebar_filter_item.selected' ).each( function( ){ 213 filter_ids.push( jQuery( this ).attr( 'data-optionitemid' ) ); 214 } ); 215 var category_ids = []; 216 jQuery( '.ec_product_sidebar_filter_item.selected' ).each( function( ){ 217 filter_ids.push( jQuery( this ).attr( 'data-categoryid' ) ); 218 } ); 219 jQuery( this ).parent( ).parent( ).parent( ).parent( ).find( '.ec_product_page_content' ).html( '</div><style>@keyframes rotation{0%{transform:rotate(0deg);}100%{ transform:rotate(359deg); } }</style><div class="wpec-product-slider-loader" style="font-size:14px; text-align:center; -webkit-box-sizing:border-box; -moz-box-sizing:border-box; -ms-box-sizing:border-box; box-sizing:border-box; width:350px; top:200px; left:50%; position:absolute; margin-left:-165px; margin-top:-80px; cursor:pointer; text-align:center; z-index:99;"><div><div style="height:30px; width:30px; display:inline-block; box-sizing:content-box; opacity:1; filter:alpha(opacity=100); -webkit-animation:rotation .7s infinite linear; -moz-animation:rotation .7s infinite linear;-o-animation: rotation .7s infinite linear; animation:rotation .7s infinite linear; border-left:8px solid rgba(0, 0, 0, .2); border-right:8px solid rgba(0, 0, 0, .2); border-bottom:8px solid rgba(0, 0, 0, .2); border-top:8px solid #fff; border-radius:100%;"></div></div></div>' ); 220 var data = { 221 action: 'ec_ajax_update_product_page_content', 222 filter_ids: filter_ids, 223 category_ids: category_ids, 224 nonce: jQuery( '.ec_product_sidebar_filter_item' ).attr( 'data-nonce' ) 225 }; 226 } ); 227 } 228 if( jQuery( '.ec_product_page_with_sidebar.ec_product_page_sidebar_left, .ec_product_page_with_sidebar.ec_product_page_sidebar_right' ).length ){ 229 jQuery( '.ec_product_page_sidebar_left > .ec_product_page_sidebar, .ec_product_page_sidebar_right > .ec_product_page_sidebar' ).clone().appendTo( document.body ).addClass( 'ec_product_page_sidebar_mobile_only' ).addClass( 'ec_product_page_sidebar_slide-left' ).find( '.ec_product_sidebar_filter_item' ).removeClass( 'ec_product_sidebar_filter_item' ).addClass( 'ec_product_sidebar_filter_item_mobile' ); 230 jQuery( '.ec_product_sidebar_filter_item_mobile' ).on( 'click', function() { 231 if ( jQuery( this ).hasClass( 'selected' ) ) { 232 jQuery( this ).removeClass( 'selected' ); 233 } else { 234 jQuery( this ).addClass( 'selected' ); 235 } 236 jQuery( '.ec_product_page_content' ).html( '<div style="min-height:400px; width:100%; float:left;"><style>@keyframes rotation{0%{transform:rotate(0deg);}100%{ transform:rotate(359deg); } }</style><div class="wpec-product-slider-loader" style="font-size:14px; text-align:center; -webkit-box-sizing:border-box; -moz-box-sizing:border-box; -ms-box-sizing:border-box; box-sizing:border-box; width:350px; top:200px; left:50%; position:absolute; margin-left:-165px; margin-top:-80px; cursor:pointer; text-align:center; z-index:99;"><div><div style="height:30px; width:30px; display:inline-block; box-sizing:content-box; opacity:1; filter:alpha(opacity=100); -webkit-animation:rotation .7s infinite linear; -moz-animation:rotation .7s infinite linear;-o-animation: rotation .7s infinite linear; animation:rotation .7s infinite linear;
236 border-left:8px solid rgba(0, 0, 0, .2); border-right:8px solid rgba(0, 0, 0, .2); border-bottom:8px solid rgba(0, 0, 0, .2); border-top:8px solid #fff; border-radius:100%;"></div></div></div></div>' ); 237 jQuery( '.ec_product_page_sidebar_slide_bg' ).fadeOut( 'fast' ); 238 jQuery( '.ec_product_page_sidebar_mobile_only' ).css( 'left', '-500px' ); 239 return true; 240 } ); 241 jQuery( '.ec_product_page_sidebar_slide_bg' ).appendTo( document.body ); 242 jQuery( '.ec_product_page_filters_toggle' ).on( 'click', function( ){ 243 if( jQuery( '.ec_product_page_sidebar_mobile_only' ).css( 'left' ) == '0px' ){ 244 jQuery( '.ec_product_page_sidebar_mobile_only' ).css( 'left', '-500px' ).fadeOut(); 245 jQuery( '.ec_product_page_sidebar_slide_bg' ).fadeOut( 'fast' ); 246 }else{ 247 jQuery( '.ec_product_page_sidebar_mobile_only' ).css( 'left', '0px' ).fadeIn( 'fast' ); 248 jQuery( '.ec_product_page_sidebar_slide_bg' ).fadeIn( 'fast' ); 249 } 250 } ); 251 jQuery( '.ec_product_page_sidebar_slide_bg, .ec_product_sidebar_close, .ec_product_sidebar_close_mobile_only' ).on( 'click', function( ){ 252 jQuery( '.ec_product_page_sidebar_slide_bg' ).fadeOut( 'fast' ); 253 jQuery( '.ec_product_page_sidebar_mobile_only' ).css( 'left', '-500px' ); 254 return false; 255 } ); 256 257 } else if( jQuery( '.ec_product_page_with_sidebar.ec_product_page_sidebar_slide-left, .ec_product_page_sidebar_slide-right > .ec_product_page_sidebar' ).length ){ 258 jQuery( '.ec_product_page_sidebar_slide-left > .ec_product_page_sidebar, .ec_product_page_sidebar_slide-right > .ec_product_page_sidebar' ).appendTo( document.body ).show( ); 259 jQuery( '.ec_product_page_sidebar_slide_bg' ).appendTo( document.body ); 260 jQuery( '.ec_product_page_sidebar_slide-left .ec_product_page_filters_toggle' ).on( 'click', function( ){ 261 if( jQuery( '.ec_product_page_sidebar' ).css( 'left' ) == '0px' ){ 262 jQuery( '.ec_product_page_sidebar' ).css( 'left', '-500px' ); 263 jQuery( '.ec_product_page_sidebar_slide_bg' ).fadeOut( 'fast' ); 264 }else{ 265 jQuery( '.ec_product_page_sidebar' ).css( 'left', '0px' ); 266 jQuery( '.ec_product_page_sidebar_slide_bg' ).fadeIn( 'fast' ); 267 } 268 } ); 269 jQuery( '.ec_product_page_sidebar_slide-right .ec_product_page_filters_toggle' ).on( 'click', function( ){ 270 if( jQuery( '.ec_product_page_sidebar' ).css( 'right' ) == '0px' ){ 271 jQuery( '.ec_product_page_sidebar' ).css( 'right', '-500px' ); 272 jQuery( '.ec_product_page_sidebar_slide_bg' ).fadeOut( 'fast' ); 273 }else{ 274 jQuery( '.ec_product_page_sidebar' ).css( 'right', '0px' ); 275 jQuery( '.ec_product_page_sidebar_slide_bg' ).fadeIn( 'fast' ); 276 } 277 } ); 278 jQuery( '.ec_product_page_sidebar_slide_bg, .ec_product_sidebar_close, .ec_product_sidebar_close_mobile_only' ).on( 'click', function() { 279 jQuery( '.ec_product_page_sidebar_slide_bg' ).fadeOut( 'fast' ); 280 jQuery( '.ec_product_page_sidebar_slide-left' ).css( 'left', '-500px' ); 281 jQuery( '.ec_product_page_sidebar_slide-right' ).css( 'right', '-500px' ); 282 return false; 283 } ); 284 jQuery( '.ec_product_page_sidebar.ec_product_page_sidebar_slide-left .ec_product_sidebar_filter_item, .ec_product_page_sidebar.ec_product_page_sidebar_slide-right .ec_product_sidebar_filter_item, .ec_product_page_sidebar.ec_product_page_sidebar_slide-left .ec_product_sidebar_link_item, .ec_product_page_sidebar.ec_product_page_sidebar_slide-right .ec_product_sidebar_link_item' ).on( 'click', function( ){ 285 jQuery( '.ec_product_page_content' ).html( '<div style="min-height:400px; width:100%; float:left;"><style>@keyframes rotation{0%{transform:rotate(0deg);}100%{ transform:rotate(359deg); } }</style><div class="wpec-product-slider-loader" style="font-size:14px; text-align:center; -webkit-box-sizing:border-box; -moz-box-sizing:border-box; -ms-box-sizing:border-box; box-sizing:border-box; width:350px; top:200px; left:50%; position:absolute; margin-left:-165px; margin-top:-80px; cursor:pointer; text-align:center; z-index:99;"><div><div style="height:30px; width:30px; display:inline-block; box-sizing:content-box; opacity:1; filter:alpha(opacity=100); -webkit-animation:rotation .7s infinite linear; -moz-animation:rotation .7s infinite linear;-o-animation: rotation .7s infinite linear; animation:rotation .7s infinite linear;
285 border-left:8px solid rgba(0, 0, 0, .2); border-right:8px solid rgba(0, 0, 0, .2); border-bottom:8px solid rgba(0, 0, 0, .2); border-top:8px solid #fff; border-radius:100%;"></div></div></div></div>' ); 286 jQuery( '.ec_product_page_sidebar_slide_bg' ).fadeOut( 'fast' ); 287 jQuery( '.ec_product_page_sidebar_mobile_only' ).css( 'left', '-500px' ); 288 } ); 289 } 290 if ( jQuery( '.ec_product_sidebar_group_title' ).length ) { 291 jQuery( '.ec_product_sidebar_group_title' ).on( 'click', function() { 292 jQuery( this ).parent( ).find( '.ec_product_sidebar_group_link_list, .ec_product_sidebar_group_filter_list' ).toggle( ); 293 } ); 294 } 295 jQuery( '.ec_add_to_cart_form_ajax' ).submit( function( e ) { 296 e.preventDefault(); 297 var input_eles = jQuery( this ).find( 'input, select' ); 298 var input_submit = jQuery( this ).find( 'input[type="submit"]' ); 299 jQuery( input_submit ).addClass( 'loading' ).parent().append( '<span class="dashicons dashicons-update-alt"></span>' ); 300 var data = { 301 action: 'ec_ajax_add_to_cart_complete', 302 noredirect: 1, 303 nonce: jQuery( '.ec_add_to_cart_form_ajax' ).attr( 'data-nonce' ) 304 }; 305 for ( var i=0; i<input_eles.length; i++ ) { 306 if( ! jQuery( input_eles[i] ).hasClass( '.ec_minus' ) && ! jQuery( input_eles[i] ).hasClass( '.ec_plus' ) ) { 307 data[ input_eles[i].name ] = jQuery( input_eles[i] ).val(); 308 } 309 } 310 jQuery.ajax( { 311 url: wpeasycart_ajax_object.ajax_url, 312 type: 'post', 313 data: data, 314 cache: false, 315 success: function( result ){ 316 var json_data = JSON.parse( result ); 317 jQuery( ".ec_cart_items_total" ).html( json_data[0].total_items ); 318 jQuery( ".ec_cart_price_total" ).html( json_data[0].total_price ); 319 320 if( json_data[0].total_items == 1 ){ 321 jQuery( ".ec_menu_cart_singular_text" ).show( ); 322 jQuery( ".ec_menu_cart_plural_text" ).hide( ); 323 }else{ 324 jQuery( ".ec_menu_cart_singular_text" ).hide( ); 325 jQuery( ".ec_menu_cart_plural_text" ).show( ); 326 } 327 328 if( json_data[0].total_items == 0 ){ 329 jQuery( ".ec_cart_price_total" ).hide( ); 330 }else{ 331 jQuery( ".ec_cart_price_total" ).show( ); 332 } 333 334 if( jQuery( '.ec_cart_widget_minicart_product_padding' ).length ){ 335 336 jQuery( '.ec_cart_widget_minicart_product_padding' ).append( '<div class="ec_cart_widget_minicart_product_title" id="ec_cart_widget_row_' + json_data[0].cartitem_id + '">' + json_data[0].title + ' x 1 @ ' + json_data[0].price + '</div>' ); 337 338 } 339 340 jQuery( input_submit ).parent().find( '.dashicons-update-alt' ).remove(); 341 jQuery( input_submit ).parent().append( '<span class="dashicons dashicons-saved"></span>' ); 342 jQuery( input_submit ).removeClass( 'loading' ).addClass( 'added' ); 343 setTimeout(function() { 344 jQuery( input_submit ).removeClass( 'added' ).parent().find( '.dashicons-saved' ).remove(); 345 }, 2000 ); 346 } 347 } ); 348 } ); 349 350 if( jQuery( '.ec_details_thumbnail' ).length ) { 351 jQuery( '.ec_details_thumbnail' ).on( 'click', function() { 352 var product_id = jQuery( this ).attr( 'data-product-id' ); 353 var rand_id = jQuery( this ).attr( 'data-rand-id' ); 354 var src = ''; 355 if ( jQuery( this ).find( 'img' ).attr( 'data-large-src' ) ) { 356 src = jQuery( this ).find( 'img' ).attr( 'data-large-src' ); 357 } else if ( jQuery( this ).find( 'img' ).parent().attr( 'data-large-src' ) ) { 358 src = jQuery( this ).find( 'img' ).parent().attr( 'data-large-src' ); 359 } else if ( jQuery( this ).find( 'img' ).parent().parent().attr( 'data-large-src' ) ) { 360 src = jQuery( this ).find( 'img' ).parent().parent().attr( 'data-large-src' ); 361 } else if ( jQuery( this ).find( 'img' ).attr( 'data-src' ) ) { 362 src = jQuery( this ).find( 'img' ).attr( 'data-src' ); 363 } else { 364 src = jQuery( this ).find( 'img' ).attr( 'src' ); 365 } 366 jQuery( '.ec_details_thumbnails_' + product_id + '_' + rand_id + ' > .ec_details_thumbnail' ).removeClass( 'ec_active' ); 367 jQuery( this ).addClass( 'ec_active' ); 368 if( jQuery( this ).hasClass( 'ec_details_thumbnail_video' ) ) { 369 var video_src = jQuery( this ).find( 'a' ).attr( 'href' ); 370 jQuery( '.ec_details_main_image_' + product_id + '_' + rand_id ).find( 'img' ).attr( 'data-src', src ).attr( 'src', src ).hide(); 371 jQuery( '.ec_details_main_image_' + product_id + '_' + rand_id ).find( '.wp-easycart-video-box' ).remove(); 372 if( jQuery( this ).hasClass( 'videoType' ) ) { 373 jQuery( '.ec_details_main_image_' + product_id + '_' + rand_id ).append( '<div class="wp-easycart-video-box"><video controls muted autoplay loop><source src="' + video_src + '" /></video></div>' ); 374 } else { 375 jQuery( '.ec_details_main_image_' + product_id + '_' + rand_id ).append( '<div class="wp-easycart-video-box"><iframe src="' + video_src + '" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe></div>' ); 376 } 377 jQuery( '.ec_details_large_popup_main_' + product_id + '_' + rand_id ).find( 'img' ).attr( 'data-src', src ).attr( 'src', src ); 378 jQuery( '.ec_details_magbox_' + product_id + '_' + rand_id ).addClass( 'inactive' ); 379 jQuery( '.ec_details_magbox_image_' + product_id + '_' + rand_id ).css( 'background', 'url( "' + src + '" ) no-repeat' ); 380 } else { 381 if ( jQuery( '.ec_details_main_image_' + product_id + '_' + rand_id ).find( 'picture > source[type="image/webp"]' ).length ) { 382 jQuery( '.ec_details_main_image_' + product_id + '_' + rand_id ).find( 'picture > source[type="image/webp"]' ).remove(); 383 } 384 if ( jQuery( '.ec_details_large_popup_main_' + product_id + '_' + rand_id ).find( 'picture > source[type="image/webp"]' ).length ) { 385 jQuery( '.ec_details_large_popup_main_' + product_id + '_' + rand_id ).find( 'picture > source[type="image/webp"]' ).remove(); 386 } 387 if ( jQuery( '.ec_details_magbox_image_' + product_id + '_' + rand_id ).find( 'picture > source[type="image/webp"]' ).length ) { 388 jQuery( '.ec_details_magbox_image_' + product_id + '_' + rand_id ).find( 'picture > source[type="image/webp"]' ).remove(); 389 } 390 jQuery( '.ec_details_main_image_' + product_id + '_' + rand_id ).find( 'img' ).attr( 'data-src', src ).attr( 'src', src ).show(); 391 jQuery( '.ec_details_main_image_' + product_id + '_' + rand_id ).find( '.wp-easycart-video-box' ).remove(); 392 jQuery( '.ec_details_large_popup_main_' + product_id + '_' + rand_id ).find( 'img' ).attr( 'data-src', src ).attr( 'src', src ); 393 jQuery( '.ec_details_magbox_' + product_id + '_' + rand_id ).removeClass( 'inactive' ); 394 jQuery( '.ec_details_magbox_image_' + product_id + '_' + rand_id ).css( 'background', 'url( "' + src + '" ) no-repeat' ).attr( 'data-bg', 'url( "' + src + '" ) no-repeat' ); 395 } 396 return false; 397 } ); 398 } 399 if( jQuery( '.ec_details_large_popup_thumbnail' ).length ) { 400 jQuery( '.ec_details_large_popup_thumbnail' ).on( 'click', function() {
401 var product_id = jQuery( this ).attr( 'data-product-id' ); 402 var rand_id = jQuery( this ).attr( 'data-rand-id' ); 403 var src = ''; 404 if ( jQuery( this ).find( 'img' ).attr( 'data-large-src' ) ) { 405 src = jQuery( this ).find( 'img' ).attr( 'data-large-src' ); 406 } else if ( jQuery( this ).find( 'img' ).parent().attr( 'data-large-src' ) ) { 407 src = jQuery( this ).find( 'img' ).parent().attr( 'data-large-src' ); 408 } else if ( jQuery( this ).find( 'img' ).parent().parent().attr( 'data-large-src' ) ) { 409 src = jQuery( this ).find( 'img' ).parent().parent().attr( 'data-large-src' ); 410 } else if ( jQuery( this ).find( 'img' ).attr( 'data-src' ) ) { 411 src = jQuery( this ).find( 'img' ).attr( 'data-src' ); 412 } else { 413 src = jQuery( this ).find( 'img' ).attr( 'src' ); 414 } 415 jQuery( '.ec_details_large_popup_thumbnails_' + product_id + '_' + rand_id + ' > .ec_details_large_popup_thumbnail' ).removeClass( 'ec_active' ); 416 jQuery( this ).addClass( 'ec_active' ); 417 if ( jQuery( this ).hasClass( 'ec_details_thumbnail_video' ) ) { 418 var video_src = jQuery( this ).find( 'a' ).attr( 'href' ); 419 jQuery( '.ec_details_main_image_' + product_id + '_' + rand_id ).find( 'img' ).attr( 'data-src', src ).attr( 'src', src ).hide(); 420 jQuery( '.ec_details_main_image_' + product_id + '_' + rand_id ).find( '.wp-easycart-video-box' ).remove(); 421 422 jQuery( '.ec_details_large_popup_main_' + product_id + '_' + rand_id ).find( 'img' ).attr( 'data-src', src ).attr( 'src', src ).hide(); 423 jQuery( '.ec_details_large_popup_main_' + product_id + '_' + rand_id ).find( '.wp-easycart-video-box' ).remove(); 424 425 if( jQuery( this ).hasClass( 'videoType' ) ) { 426 jQuery( '.ec_details_main_image_' + product_id + '_' + rand_id ).append( '<div class="wp-easycart-video-box"><video controls muted autoplay loop><source src="' + video_src + '" /></video></div>' ); 427 jQuery( '.ec_details_large_popup_main_' + product_id + '_' + rand_id ).append( '<div class="wp-easycart-video-box"><video controls muted autoplay loop><source src="' + video_src + '" /></video></div>' ); 428 429 } else { 430 jQuery( '.ec_details_main_image_' + product_id + '_' + rand_id ).append( '<div class="wp-easycart-video-box"><iframe src="' + video_src + '" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe></div>' ); 431 jQuery( '.ec_details_large_popup_main_' + product_id + '_' + rand_id ).append( '<div class="wp-easycart-video-box"><iframe src="' + video_src + '" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe></div>' ); 432 } 433 jQuery( '.ec_details_magbox_' + product_id + '_' + rand_id ).addClass( 'inactive' ); 434 jQuery( '.ec_details_magbox_image_' + product_id + '_' + rand_id ).css( 'background', 'url( "' + src + '" ) no-repeat' ); 435 } else { 436 if ( jQuery( '.ec_details_main_image_' + product_id + '_' + rand_id ).find( 'picture > source[type="image/webp"]' ).length ) { 437 jQuery( '.ec_details_main_image_' + product_id + '_' + rand_id ).find( 'picture > source[type="image/webp"]' ).remove(); 438 } 439 if ( jQuery( '.ec_details_large_popup_main_' + product_id + '_' + rand_id ).find( 'picture > source[type="image/webp"]' ).length ) { 440 jQuery( '.ec_details_large_popup_main_' + product_id + '_' + rand_id ).find( 'picture > source[type="image/webp"]' ).remove(); 441 } 442 if ( jQuery( '.ec_details_magbox_image_' + product_id + '_' + rand_id ).find( 'picture > source[type="image/webp"]' ).length ) { 443 jQuery( '.ec_details_magbox_image_' + product_id + '_' + rand_id ).find( 'picture > source[type="image/webp"]' ).remove(); 444 } 445 jQuery( '.ec_details_thumbnails_' + product_id + '_' + rand_id + ' > .ec_details_thumbnail' ).removeClass( 'ec_active' ); 446 jQuery( '.ec_details_main_image_' + product_id + '_' + rand_id ).find( 'img' ).attr( 'data-src', src ).attr( 'src', src ).show(); 447 jQuery( '.ec_details_large_popup_main_' + product_id + '_' + rand_id ).find( 'img' ).attr( 'data-src', src ).attr( 'src', src ).show(); 448 jQuery( '.ec_details_main_image_' + product_id + '_' + rand_id ).find( '.wp-easycart-video-box' ).remove(); 449 jQuery( '.ec_details_large_popup_main_' + product_id + '_' + rand_id ).find( '.wp-easycart-video-box' ).remove(); 450 jQuery( '.ec_details_magbox_image_' + product_id + '_' + rand_id ).css( 'background', 'url( "' + src + '" ) no-repeat' ); 451 } 452 return false; 453 }); 454 } 455 if ( jQuery( '.ec_details_main_image.mag_enabled' ).length ) { 456 var img = new Image( ); 457 var img_width = 400; 458 var img_height = 400; 459 jQuery( '.ec_details_main_image' ).mousemove( function( e ){ 460 var parentOffset = jQuery( this ).parent( ).offset( ); 461 var mouse_x = e.pageX - parentOffset.left; 462 var mouse_y = e.pageY - parentOffset.top; 463 var div_width = jQuery( this ).width( ); 464 var div_height = jQuery( this ).height( ); 465 var x_val = '-' + ( ( img_width - div_width ) * ( mouse_x / div_width ) ) + 'px'; 466 var y_val = '-' + ( ( img_height - div_height ) * ( mouse_y / div_height ) ) + 'px';
467 var product_id = jQuery( this ).attr( 'data-product-id' ); 468 var rand_id = jQuery( this ).attr( 'data-rand-id' ); 469 jQuery( '.ec_details_magbox_image_' + product_id + '_' + rand_id ).css( 'background-position', x_val + ' ' + y_val ); 470 } ); 471 jQuery( '.ec_details_main_image' ).hover( 472 function() { 473 var product_id = jQuery( this ).attr( 'data-product-id' ); 474 var rand_id = jQuery( this ).attr( 'data-rand-id' ); 475 img = new Image( ); 476 img.onload = function( ) { 477 img_width = this.width; 478 img_height = this.height; 479 jQuery( '.ec_details_magbox_' + product_id + '_' + rand_id ).css( 'width', jQuery( '.ec_details_main_image_' + product_id + '_' + rand_id ).width( ) + 'px' ).css( 'height', jQuery( '.ec_details_main_image_' + product_id + '_' + rand_id ).height( ) + 'px' ); 480 jQuery( '.ec_details_magbox_image_' + product_id + '_' + rand_id ).css( 'width', jQuery( '.ec_details_main_image_' + product_id + '_' + rand_id ).width( ) + 'px' ).css( 'height', jQuery( '.ec_details_main_image_' + product_id + '_' + rand_id ).height( ) + 'px' ); 481 } 482 img.src = jQuery( this ).find( 'img' ).attr( 'src' ); 483 jQuery( '.ec_details_magbox_' + product_id + '_' + rand_id ).fadeIn( 'fast' ); 484 }, 485 function() { 486 var product_id = jQuery( this ).attr( 'data-product-id' ); 487 var rand_id = jQuery( this ).attr( 'data-rand-id' ); 488 jQuery( '.ec_details_magbox_' + product_id + '_' + rand_id ).fadeOut( 'fast' ); 489 } 490 ); 491 } 492 if ( jQuery( '.ec_minus' ).length ) { 493 jQuery( '.ec_minus' ).on( 'click', function() { 494 var product_id = jQuery( this ).parent().attr( 'data-product-id' ); 495 var rand_id = jQuery( this ).parent().attr( 'data-rand-id' ); 496 var min_quantity = jQuery( this ).parent().attr( 'data-min-purchase-quantity' ); 497 var use_advanced_optionset = jQuery( this ).parent().attr( 'data-use-advanced-optionset' ); 498 ec_minus_quantity( product_id + '_' + rand_id, min_quantity ); 499 if ( '1' == use_advanced_optionset ) { 500 ec_details_advanced_adjust_price( product_id, rand_id ); 501 } else { 502 ec_details_base_adjust_price( product_id, rand_id ); 503 } 504 } ); 505 } 506 if ( jQuery( '.ec_plus' ).length ) { 507 jQuery( '.ec_plus' ).on( 'click', function() { 508 var product_id = jQuery( this ).parent().attr( 'data-product-id' ); 509 var rand_id = jQuery( this ).parent().attr( 'data-rand-id' ); 510 var show_stock_quantity = jQuery( this ).parent().attr( 'data-show-stock-quantity' ); 511 var max_quantity = jQuery( this ).parent().attr( 'data-min-purchase-quantity' ); 512 var use_advanced_optionset = jQuery( this ).parent().attr( 'data-use-advanced-optionset' ); 513 ec_plus_quantity( product_id + '_' + rand_id, show_stock_quantity, max_quantity ); 514 if ( '1' == use_advanced_optionset ) { 515 ec_details_advanced_adjust_price( product_id, rand_id ); 516 } else { 517 ec_details_base_adjust_price( product_id, rand_id ); 518 } 519 } ); 520 } 521 if ( jQuery( '.ec_quantity' ).length ) { 522 jQuery( '.ec_quantity' ).on( 'change', function() { 523 var product_id = jQuery( this ).parent().attr( 'data-product-id' ); 524 var rand_id = jQuery( this ).parent().attr( 'data-rand-id' ); 525 var use_advanced_optionset = jQuery( this ).parent().attr( 'data-use-advanced-optionset' ); 526 if ( '1' == use_advanced_optionset ) { 527 ec_details_advanced_adjust_price( product_id, rand_id ); 528 } else { 529 ec_details_base_adjust_price( product_id, rand_id ); 530 } 531 } ); 532 } 533 if ( jQuery( '.ec_donation_amount' ).length ) { 534 jQuery( '.ec_donation_amount' ).on( 'change', function() { 535 var product_id = jQuery( this ).attr( 'data-product-id' ); 536 var rand_id = jQuery( this ).attr( 'data-rand-id' ); 537 var use_advanced_optionset = jQuery( this ).attr( 'data-use-advanced-optionset' ); 538 if ( '1' == use_advanced_optionset ) { 539 ec_details_advanced_adjust_price( product_id, rand_id ); 540 } else { 541 ec_details_base_adjust_price( product_id, rand_id ); 542 } 543 } ); 544 } 545 jQuery( '.ec_details_checkbox_row > input, .ec_details_radio_row > input' ).click( function( ){ 546 var product_id = jQuery( this ).parent().parent().parent().attr( 'data-
546product-id' ); 547 var rand_id = jQuery( this ).parent().parent().parent().attr( 'data-rand-id' ); 548 ec_details_advanced_conditional_logic( product_id, rand_id ); 549 ec_details_advanced_adjust_price( product_id, rand_id ); 550 } ); 551 jQuery( '.ec_details_checkbox_row_ele input, .ec_details_radio_row_ele input' ).click( function( ){ 552 var product_id = jQuery( this ).parent().parent().parent().parent().attr( 'data-product-id' ); 553 var rand_id = jQuery( this ).parent().parent().parent().parent().attr( 'data-rand-id' ); 554 ec_details_advanced_conditional_logic( product_id, rand_id ); 555 ec_details_advanced_adjust_price( product_id, rand_id ); 556 } ); 557 jQuery( '.ec_details_option_row.ec_option_type_combo > .ec_details_option_data > select' ).change( function( ){ 558 var product_id = jQuery( this ).parent().parent().attr( 'data-product-id' ); 559 var rand_id = jQuery( this ).parent().parent().attr( 'data-rand-id' ); 560 var product_option_id = jQuery( this ).parent().parent().attr( 'data-product-option-id' ); 561 var is_required = jQuery( this ).parent().parent().attr( 'data-option-required' ); 562 var val = jQuery( this ).val(); 563 if ( val == '0' && is_required == '1' ) { 564 jQuery( document.getElementById( 'ec_details_adv_option_row_error_' + product_option_id + '_' + product_id + '_' + rand_id ) ).show( ); 565 } else { 566 jQuery( document.getElementById( 'ec_details_adv_option_row_error_' + product_option_id + '_' + product_id + '_' + rand_id ) ).hide( ); 567 } 568 ec_details_advanced_conditional_logic( product_id, rand_id ); 569 ec_details_advanced_adjust_price( product_id, rand_id ); 570 } ); 571 jQuery( '.ec_details_option_row.ec_option_type_date > .ec_details_option_data > input' ).change( function( ){ 572 var product_id = jQuery( this ).parent().parent().attr( 'data-product-id' ); 573 var rand_id = jQuery( this ).parent().parent().attr( 'data-rand-id' ); 574 ec_details_advanced_conditional_logic( product_id, rand_id ); 575 ec_details_advanced_adjust_price( product_id, rand_id ); 576 } ); 577 jQuery( '.ec_details_option_row.ec_option_type_file > .ec_details_option_data > input' ).change( function( ){ 578 var product_id = jQuery( this ).parent().parent().attr( 'data-product-id' ); 579 var rand_id = jQuery( this ).parent().parent().attr( 'data-rand-id' ); 580 ec_details_advanced_conditional_logic( product_id, rand_id ); 581 ec_details_advanced_adjust_price( product_id, rand_id ); 582 } ); 583 jQuery( '.ec_details_option_row.ec_option_type_text > .ec_details_option_data > input' ).change( function( ){ 584 var product_id = jQuery( this ).parent().parent().attr( 'data-product-id' ); 585 var rand_id = jQuery( this ).parent().parent().attr( 'data-rand-id' ); 586 ec_details_advanced_conditional_logic( product_id, rand_id ); 587 ec_details_advanced_adjust_price( product_id, rand_id ); 588 } ); 589 jQuery( '.ec_details_option_row.ec_option_type_number > .ec_details_option_data > input' ).change( function( ){ 590 var product_id = jQuery( this ).parent().parent().attr( 'data-product-id' ); 591 var rand_id = jQuery( this ).parent().parent().attr( 'data-rand-id' ); 592 ec_details_advanced_conditional_logic( product_id, rand_id ); 593 ec_details_advanced_adjust_price( product_id, rand_id ); 594 } ); 595 jQuery( '.ec_details_option_row.ec_option_type_textarea > .ec_details_option_data > textarea' ).change( function( ){ 596 var product_id = jQuery( this ).parent().parent().attr( 'data-product-id' ); 597 var rand_id = jQuery( this ).parent().parent().attr( 'data-rand-id' ); 598 ec_details_advanced_conditional_logic( product_id, rand_id ); 599 ec_details_advanced_adjust_price( product_id, rand_id ); 600 } ); 601 jQuery( '.ec_details_grid_row > input' ).change( function( ){ 602 var product_id = jQuery( this ).parent().parent().parent().attr( 'data-product-id' ); 603 var rand_id = jQuery( this ).parent().parent().parent().attr( 'data-rand-id' ); 604 ec_details_advanced_conditional_logic( product_id, rand_id ); 605 ec_details_advanced_adjust_price( product_id, rand_id ); 606 } ); 607 jQuery( '.ec_details_swatches > li.ec_advanced, .ec_details_swatches_ele > li.ec_advanced' ).click( function( ){ 608 var optionitem_id = jQuery( this ).attr( 'data-optionitem-id' );
609 var product_option_id = jQuery( this ).attr( 'data-product-option-id' ); 610 var product_id = jQuery( this ).parent().parent().parent().attr( 'data-product-id' ); 611 var rand_id = jQuery( this ).parent().parent().parent().attr( 'data-rand-id' ); 612 jQuery( document.getElementById( 'ec_option_adv_' + product_option_id + "_" + product_id + '_' + rand_id ) ).val( optionitem_id ); 613 jQuery( '.ec_details_swatches > li.ec_option_adv_' + product_option_id + "_" + product_id + '_' + rand_id ).removeClass( 'ec_selected' ); 614 jQuery( '.ec_details_swatches_ele > li.ec_option_adv_' + product_option_id + "_" + product_id + '_' + rand_id ).removeClass( 'ec_selected' ); 615 jQuery( this ).addClass( 'ec_selected' ); 616 jQuery( document.getElementById( 'ec_details_option_row_error_' + product_option_id + "_" + product_id + '_' + rand_id ) ).hide( ); 617 if ( jQuery( this ).find( 'img' ).length ) { 618 if ( '' == jQuery( this ).find( 'img' ).attr( 'title' ) && '' != jQuery( this ).find( 'img' ).attr( 'pac_da_title' ) ) { 619 jQuery( this ).parent( ).parent( ).parent( ).find( '.ec_details_option_label_selected' ).html( jQuery( this ).find( 'img' ).attr( 'pac_da_title' ) ); 620 } else { 621 jQuery( this ).parent( ).parent( ).parent( ).find( '.ec_details_option_label_selected' ).html( jQuery( this ).find( 'img' ).attr( 'title' ) ); 622 } 623 } else { 624 jQuery( this ).parent( ).parent( ).parent( ).find( '.ec_details_option_label_selected' ).html( jQuery( this ).attr( 'title' ) ); 625 } 626 ec_details_advanced_conditional_logic( product_id, rand_id ); 627 ec_details_advanced_adjust_price( product_id, rand_id ); 628 } ); 629 jQuery( '.ec_details_option_row.ec_option_type_dimensions1 > .ec_details_option_data > input' ).change( function( ){ 630 var product_id = jQuery( this ).parent().parent().attr( 'data-product-id' ); 631 var rand_id = jQuery( this ).parent().parent().attr( 'data-rand-id' ); 632 ec_details_advanced_conditional_logic( product_id, rand_id ); 633 ec_details_advanced_adjust_price( product_id, rand_id ); 634 } ); 635 jQuery( '.ec_details_option_row.ec_option_type_dimensions2 > .ec_details_option_data > input' ).change( function( ){ 636 var product_id = jQuery( this ).parent().parent().attr( 'data-product-id' ); 637 var rand_id = jQuery( this ).parent().parent().attr( 'data-rand-id' ); 638 ec_details_advanced_conditional_logic( product_id, rand_id ); 639 ec_details_advanced_adjust_price( product_id, rand_id ); 640 } ); 641 jQuery( '.ec_details_option_row.ec_option_type_dimensions2 > .ec_details_option_data > select' ).change( function( ){ 642 var product_id = jQuery( this ).parent().parent().attr( 'data-product-id' ); 643 var rand_id = jQuery( this ).parent().parent().attr( 'data-rand-id' ); 644 ec_details_advanced_conditional_logic( product_id, rand_id ); 645 ec_details_advanced_adjust_price( product_id, rand_id ); 646 } ); 647 if ( jQuery( '.ec_details_swatches > li.ec_option1, .ec_details_swatches_ele > li.ec_option1' ).length ) { 648 jQuery( '.ec_details_swatches > li.ec_option1, .ec_details_swatches_ele > li.ec_option1' ).each( function() { 649 var product_id = jQuery( this ).parent().parent().parent().attr( 'data-product-id' ); 650 var rand_id = jQuery( this ).parent().parent().parent().attr( 'data-rand-id' ); 651 var optionitem_id_1 = jQuery( this ).attr( 'data-optionitem-id' ); 652 ec_option1_init_swatches( product_id, rand_id, jQuery( this ), optionitem_id_1 ); 653 } ); 654 } 655 if ( jQuery( '.ec_details_combo.ec_option1' ).length ) { 656 jQuery( '.ec_details_combo.ec_option1' ).each( function() { 657 var product_id = jQuery( this ).parent().parent().attr( 'data-product-id' ); 658 var rand_id = jQuery( this ).parent().parent().attr( 'data-rand-id' ); 659 ec_option1_init_combo( product_id, rand_id ); 660 } ); 661 } 662 jQuery( '.ec_details_swatches > li.ec_option1, .ec_details_swatches_ele > li.ec_option1' ).click( function( ){ 663 if( jQuery( this ).hasClass( 'ec_active' ) ){ 664 var product_id = jQuery( this ).parent().parent().parent().attr( 'data-product-id' ); 665 var rand_id = jQuery( this ).parent().parent().parent().attr( 'data-rand-id' ); 666 var optionitem_id_1 = jQuery( this ).attr( 'data-optionitem-id' ); 667 var quantity = jQuery( this ).attr( 'data-optionitem-quantity' ); 668 var use_optionitem_quantity_tracking = jQuery( document.getElementById( 'use_optionitem_quantity_tracking_' + product_id + '_' + rand_id ) ).val(); 669 if ( jQuery( document.getElementById( 'ec_allow_backorders_' + product_id + '_' + rand_id ) ).length && '1' == jQuery( document.getElementById( 'ec_allow_backorders_' + product_id + '_' + rand_id ) ).val() ) { 670 use_optionitem_quantity_tracking = '0'; 671 } 672 if ( '1' == use_optionitem_quantity_tracking ) { 673 ec_option1_selected( product_id, rand_id, optionitem_id_1, quantity ); 674 } else { 675 ec_option1_updated( product_id, rand_id, optionitem_id_1 ); 676 } 677 ec_option1_image_change( product_id, rand_id, optionitem_id_1, quantity ); 678 jQuery( '.ec_details_swatches > li.ec_option1_' + product_id + '_' + rand_id ).removeClass( 'ec_selected' ); 679 jQuery( '.ec_details_swatches_ele > li.ec_option1_' + product_id + '_' + rand_id ).removeClass( 'ec_selected' ); 680 jQuery( this ).addClass( 'ec_selected' ); 681 jQuery( '.ec_option1_' + product_id + '_' + rand_id + '.ec_details_option_row_error' ).hide( ); 682 jQuery( document.getElementById( 'ec_option1_' + product_id + '_' + rand_id ) ).val( optionitem_id_1 ); 683 if ( jQuery( this ).find( 'img' ).length ) { 684 if ( '' == jQuery( this ).find( 'img' ).attr( 'title' ) && '' != jQuery( this ).find( 'img' ).attr( 'pac_da_title' ) ) { 685 jQuery( this ).parent( ).parent( ).find( '.ec_details_option_label_selected' ).html( jQuery( this ).find( 'img' ).attr( 'pac_da_title' ) ); 686 } else { 687 jQuery( this ).parent( ).parent( ).find( '.ec_details_option_label_selected' ).html( jQuery( this ).find( 'img' ).attr( 'title' ) ); 688 } 689 } else { 690 jQuery( this ).parent( ).parent( ).find( '.ec_details_option_label_selected' ).html( jQuery( this ).attr( 'title' ) ); 691 } 692 ec_details_base_adjust_price( product_id, rand_id ); 693 } 694 } ); 695 jQuery( '.ec_details_swatches > li.ec_option2, .ec_details_swatches_ele > li.ec_option2' ).click( function( ){ 696 if( jQuery( this ).hasClass( 'ec_active' ) ){ 697 var product_id = jQuery( this ).parent().parent().parent().attr( 'data-
697product-id' ); 698 var rand_id = jQuery( this ).parent().parent().parent().attr( 'data-rand-id' ); 699 var optionitem_id_1 = 0; 700 if( jQuery( '.ec_details_swatches > li.ec_option1_' + product_id + '_' + rand_id + '.ec_selected, .ec_details_swatches_ele > li.ec_option1_' + product_id + '_' + rand_id + '.ec_selected' ).length ){ 701 optionitem_id_1 = jQuery( '.ec_details_swatches > li.ec_option1_' + product_id + '_' + rand_id + '.ec_selected, .ec_details_swatches_ele > li.ec_option1_' + product_id + '_' + rand_id + '.ec_selected' ).attr( 'data-optionitem-id' ); 702 }else{ 703 optionitem_id_1 = jQuery( '.ec_details_combo.ec_option1_' + product_id + '_' + rand_id ).val( ); 704 } 705 var optionitem_id_2 = jQuery( this ).attr( 'data-optionitem-id' ); 706 var use_optionitem_quantity_tracking = jQuery( document.getElementById( 'use_optionitem_quantity_tracking_' + product_id + '_' + rand_id ) ).val(); 707 if ( jQuery( document.getElementById( 'ec_allow_backorders_' + product_id + '_' + rand_id ) ).length && '1' == jQuery( document.getElementById( 'ec_allow_backorders_' + product_id + '_' + rand_id ) ).val() ) { 708 use_optionitem_quantity_tracking = '0'; 709 } 710 if ( '1' == use_optionitem_quantity_tracking ) { 711 var quantity = jQuery( this ).attr( 'data-optionitem-quantity' ); 712 option2_selected( product_id, rand_id, optionitem_id_1, optionitem_id_2, quantity ); 713 } else { 714 ec_option2_updated( product_id, rand_id, optionitem_id_1, optionitem_id_2 ); 715 } 716 jQuery( '.ec_details_swatches > li.ec_option2_' + product_id + '_' + rand_id ).removeClass( 'ec_selected' ); 717 jQuery( '.ec_details_swatches_ele > li.ec_option2_' + product_id + '_' + rand_id ).removeClass( 'ec_selected' ); 718 jQuery( this ).addClass( 'ec_selected' ); 719 jQuery( '.ec_option2_' + product_id + '_' + rand_id + '.ec_details_option_row_error' ).hide( ); 720 jQuery( document.getElementById( 'ec_option2_' + product_id + '_' + rand_id ) ).val( optionitem_id_2 ); 721 if ( jQuery( this ).find( 'img' ).length ) { 722 if ( '' == jQuery( this ).find( 'img' ).attr( 'title' ) && '' != jQuery( this ).find( 'img' ).attr( 'pac_da_title' ) ) { 723 jQuery( this ).parent( ).parent( ).find( '.ec_details_option_label_selected' ).html( jQuery( this ).find( 'img' ).attr( 'pac_da_title' ) ); 724 } else { 725 jQuery( this ).parent( ).parent( ).find( '.ec_details_option_label_selected' ).html( jQuery( this ).find( 'img' ).attr( 'title' ) ); 726 } 727 } else { 728 jQuery( this ).parent( ).parent( ).find( '.ec_details_option_label_selected' ).html( jQuery( this ).attr( 'title' ) ); 729 } 730 ec_details_base_adjust_price( product_id, rand_id ); 731 } 732 } ); 733 jQuery( '.ec_details_swatches > li.ec_option3, .ec_details_swatches_ele > li.ec_option3' ).click( function( ){ 734 if( jQuery( this ).hasClass( 'ec_active' ) ){ 735 var product_id = jQuery( this ).parent().parent().parent().attr( 'data-product-id' ); 736 var rand_id = jQuery( this ).parent().parent().parent().attr( 'data-rand-id' ); 737 var optionitem_id_1 = 0; 738 if( jQuery( '.ec_details_swatches > li.ec_option1_' + product_id + '_' + rand_id + '.ec_selected, .ec_details_swatches_ele > li.ec_option1_' + product_id + '_' + rand_id + '.ec_selected' ).length ){ 739 optionitem_id_1 = jQuery( '.ec_details_swatches > li.ec_option1_' + product_id + '_' + rand_id + '.ec_selected, .ec_details_swatches_ele > li.ec_option1_' + product_id + '_' + rand_id + '.ec_selected' ).attr( 'data-optionitem-id' ); 740 }else{ 741 optionitem_id_1 = jQuery( '.ec_details_combo.ec_option1_' + product_id + '_' + rand_id ).val( ); 742 } 743 var optionitem_id_2 = 0; 744 if( jQuery( '.ec_details_swatches > li.ec_option2_' + product_id + '_' + rand_id + '.ec_selected, .ec_details_swatches_ele > li.ec_option2_' + product_id + '_' + rand_id + '.ec_selected' ).length ){ 745 optionitem_id_2 = jQuery( '.ec_details_swatches > li.ec_option2_' + product_id + '_' + rand_id + '.ec_selected, .ec_details_swatches_ele > li.ec_option2_' + product_id + '_' + rand_id + '.ec_selected' ).attr( 'data-optionitem-id' ); 746 }else{ 747 optionitem_id_2 = jQuery( '.ec_details_combo.ec_option2_' + product_id + '_' + rand_id ).val( ); 748 } 749 var optionitem_id_3 = jQuery( this ).attr( 'data-optionitem-id' ); 750 var use_optionitem_quantity_tracking = jQuery( document.getElementById( 'use_optionitem_quantity_tracking_' + product_id + '_' + rand_id ) ).val(); 751 if ( jQuery( document.getElementById( 'ec_allow_backorders_' + product_id + '_' + rand_id ) ).length && '1' == jQuery( document.getElementById( 'ec_allow_backorders_' + product_id + '_' + rand_id ) ).val() ) { 752 use_optionitem_quantity_tracking = '0'; 753 } 754 if ( '1' == use_optionitem_quantity_tracking ) { 755 var quantity = jQuery( this ).attr( 'data-optionitem-quantity' ); 756 option3_selected( product_id, rand_id, optionitem_id_1, optionitem_id_2, optionitem_id_3, quantity ); 757 } else { 758 ec_option3_updated( product_id, rand_id, optionitem_id_1, optionitem_id_2, optionitem_id_3 ); 759 } 760 jQuery( '.ec_details_swatches > li.ec_option3_' + product_id + '_' + rand_id ).removeClass( 'ec_selected' ); 761 jQuery( '.ec_details_swatches_ele > li.ec_option3_' + product_id + '_' + rand_id ).removeClass( 'ec_selected' ); 762 jQuery( this ).addClass( 'ec_selected' ); 763 jQuery( '.ec_option3_' + product_id + '_' + rand_id + '.ec_details_option_row_error' ).hide( ); 764 jQuery( document.getElementById( 'ec_option3_' + product_id + '_' + rand_id ) ).val( optionitem_id_3 ); 765 if ( jQuery( this ).find( 'img' ).length ) { 766 if ( '' == jQuery( this ).find( 'img' ).attr( 'title' ) && '' != jQuery( this ).find( 'img' ).attr( 'pac_da_title' ) ) { 767 jQuery( this ).parent( ).parent( ).find( '.ec_details_option_label_selected' ).html( jQuery( this ).find( 'img' ).attr( 'pac_da_title' ) ); 768 } else { 769 jQuery( this ).parent( ).parent( ).find( '.ec_details_option_label_selected' ).html( jQuery( this ).find( 'img' ).attr( 'title' ) ); 770 } 771 } else { 772 jQuery( this ).parent( ).parent( ).find( '.ec_details_option_label_selected' ).html( jQuery( this ).attr( 'title' ) ); 773 } 774 ec_details_base_adjust_price( product_id, rand_id ); 775 } 776 } ); 777 jQuery( '.ec_details_swatches > li.ec_option4, .ec_details_swatches_ele > li.ec_option4' ).click( function( ){ 778 if( jQuery( this ).hasClass( 'ec_active' ) ){ 779 var product_id = jQuery( this ).parent().parent().parent().attr( 'data-
779product-id' ); 780 var rand_id = jQuery( this ).parent().parent().parent().attr( 'data-rand-id' ); 781 var optionitem_id_1 = 0; 782 if( jQuery( '.ec_details_swatches > li.ec_option1_' + product_id + '_' + rand_id + '.ec_selected, .ec_details_swatches_ele > li.ec_option1_' + product_id + '_' + rand_id + '.ec_selected' ).length ){ 783 optionitem_id_1 = jQuery( '.ec_details_swatches > li.ec_option1_' + product_id + '_' + rand_id + '.ec_selected, .ec_details_swatches_ele > li.ec_option1_' + product_id + '_' + rand_id + '.ec_selected' ).attr( 'data-optionitem-id' ); 784 }else{ 785 optionitem_id_1 = jQuery( '.ec_details_combo.ec_option1_' + product_id + '_' + rand_id ).val( ); 786 } 787 var optionitem_id_2 = 0; 788 if( jQuery( '.ec_details_swatches > li.ec_option2_' + product_id + '_' + rand_id + '.ec_selected, .ec_details_swatches_ele > li.ec_option2_' + product_id + '_' + rand_id + '.ec_selected' ).length ){ 789 optionitem_id_2 = jQuery( '.ec_details_swatches > li.ec_option2_' + product_id + '_' + rand_id + '.ec_selected, .ec_details_swatches_ele > li.ec_option2_' + product_id + '_' + rand_id + '.ec_selected' ).attr( 'data-optionitem-id' ); 790 }else{ 791 optionitem_id_2 = jQuery( '.ec_details_combo.ec_option2_' + product_id + '_' + rand_id ).val( ); 792 } 793 var optionitem_id_3 = 0; 794 if( jQuery( '.ec_details_swatches > li.ec_option3_' + product_id + '_' + rand_id + '.ec_selected, .ec_details_swatches_ele > li.ec_option3_' + product_id + '_' + rand_id + '.ec_selected' ).length ){ 795 optionitem_id_3 = jQuery( '.ec_details_swatches > li.ec_option3_' + product_id + '_' + rand_id + '.ec_selected, .ec_details_swatches_ele > li.ec_option3_' + product_id + '_' + rand_id + '.ec_selected' ).attr( 'data-optionitem-id' ); 796 }else{ 797 optionitem_id_3 = jQuery( '.ec_details_combo.ec_option3_' + product_id + '_' + rand_id ).val( ); 798 } 799 var optionitem_id_4 = jQuery( this ).attr( 'data-optionitem-id' ); 800 var use_optionitem_quantity_tracking = jQuery( document.getElementById( 'use_optionitem_quantity_tracking_' + product_id + '_' + rand_id ) ).val(); 801 if ( jQuery( document.getElementById( 'ec_allow_backorders_' + product_id + '_' + rand_id ) ).length && '1' == jQuery( document.getElementById( 'ec_allow_backorders_' + product_id + '_' + rand_id ) ).val() ) { 802 use_optionitem_quantity_tracking = '0'; 803 } 804 if ( '1' == use_optionitem_quantity_tracking ) { 805 var quantity = jQuery( this ).attr( 'data-optionitem-quantity' ); 806 option4_selected( product_id, rand_id, optionitem_id_1, optionitem_id_2, optionitem_id_3, optionitem_id_4, quantity ); 807 } else { 808 ec_option4_updated( product_id, rand_id, optionitem_id_1, optionitem_id_2, optionitem_id_3, optionitem_id_4 ); 809 } 810 jQuery( '.ec_details_swatches > li.ec_option4_' + product_id + '_' + rand_id ).removeClass( 'ec_selected' ); 811 jQuery( '.ec_details_swatches_ele > li.ec_option4_' + product_id + '_' + rand_id ).removeClass( 'ec_selected' ); 812 jQuery( this ).addClass( 'ec_selected' ); 813 jQuery( '.ec_option4_' + product_id + '_' + rand_id + '.ec_details_option_row_error' ).hide( ); 814 jQuery( document.getElementById( 'ec_option4_' + product_id + '_' + rand_id ) ).val( optionitem_id_4 ); 815 if ( jQuery( this ).find( 'img' ).length ) { 816 if ( '' == jQuery( this ).find( 'img' ).attr( 'title' ) && '' != jQuery( this ).find( 'img' ).attr( 'pac_da_title' ) ) { 817 jQuery( this ).parent( ).parent( ).find( '.ec_details_option_label_selected' ).html( jQuery( this ).find( 'img' ).attr( 'pac_da_title' ) ); 818 } else { 819 jQuery( this ).parent( ).parent( ).find( '.ec_details_option_label_selected' ).html( jQuery( this ).find( 'img' ).attr( 'title' ) ); 820 } 821 } else { 822 jQuery( this ).parent( ).parent( ).find( '.ec_details_option_label_selected' ).html( jQuery( this ).attr( 'title' ) ); 823 } 824 ec_details_base_adjust_price( product_id, rand_id ); 825 } 826 } ); 827 jQuery( '.ec_details_swatches > li.ec_option5, .ec_details_swatches_ele > li.ec_option5' ).click( function( ){ 828 if( jQuery( this ).hasClass( 'ec_active' ) ){ 829 var product_id = jQuery( this ).parent().parent().parent().attr( 'data-
829product-id' ); 830 var rand_id = jQuery( this ).parent().parent().parent().attr( 'data-rand-id' ); 831 var optionitem_id_5 = jQuery( this ).attr( 'data-optionitem-id' ); 832 jQuery( '.ec_details_swatches > li.ec_option5_' + product_id + '_' + rand_id ).removeClass( 'ec_selected' ); 833 jQuery( '.ec_details_swatches_ele > li.ec_option5_' + product_id + '_' + rand_id ).removeClass( 'ec_selected' ); 834 var quantity = jQuery( this ).attr( 'data-optionitem-quantity' ); 835 jQuery( document.getElementById( 'ec_details_stock_quantity_' + product_id + '_' + rand_id ) ).html( quantity ); 836 if ( 'inf' != quantity ) { 837 jQuery( '.ec_details_stock_total' ).show(); 838 } else { 839 jQuery( '.ec_details_stock_total' ).hide(); 840 } 841 jQuery( document.getElementById('ec_quantity_' + product_id + '_' + rand_id ) ).attr( 'max', quantity ); 842 if( Number( jQuery( document.getElementById('ec_quantity_' + product_id + '_' + rand_id ) ).val( ) ) > Number( quantity ) ){ 843 jQuery( document.getElementById('ec_quantity_' + product_id + '_' + rand_id ) ).val( quantity ); 844 } 845 jQuery( this ).addClass( 'ec_selected' ); 846 jQuery( '.ec_option5_' + product_id + '_' + rand_id + '.ec_details_option_row_error' ).hide( ); 847 jQuery( document.getElementById( 'ec_option5_' + product_id + '_' + rand_id ) ).val( optionitem_id_5 ); 848 if ( jQuery( this ).find( 'img' ).length ) { 849 if ( '' == jQuery( this ).find( 'img' ).attr( 'title' ) && '' != jQuery( this ).find( 'img' ).attr( 'pac_da_title' ) ) { 850 jQuery( this ).parent( ).parent( ).find( '.ec_details_option_label_selected' ).html( jQuery( this ).find( 'img' ).attr( 'pac_da_title' ) ); 851 } else { 852 jQuery( this ).parent( ).parent( ).find( '.ec_details_option_label_selected' ).html( jQuery( this ).find( 'img' ).attr( 'title' ) ); 853 } 854 } else { 855 jQuery( this ).parent( ).parent( ).find( '.ec_details_option_label_selected' ).html( jQuery( this ).attr( 'title' ) ); 856 } 857 ec_details_base_adjust_price( product_id, rand_id ); 858 } 859 } ); 860 jQuery( '.ec_details_radio_row.ec_optionitem_images > input' ).click( function( ){ 861 var product_id = jQuery( this ).parent().parent().parent().attr( 'data-product-id' ); 862 var rand_id = jQuery( this ).parent().parent().parent().attr( 'data-rand-id' ); 863 var optionitem_id_1 = jQuery( this ).val( ); 864 ec_option1_image_change( product_id, rand_id, optionitem_id_1, 1 ); 865 } ); 866 jQuery( '.ec_details_radio_row.ec_optionitem_images > label > input' ).click( function( ){ 867 var product_id = jQuery( this ).attr( 'data-product-id' ); 868 var rand_id = jQuery( this ).attr( 'data-rand-id' ); 869 var optionitem_id_1 = jQuery( this ).val( ); 870 ec_option1_image_change( product_id, rand_id, optionitem_id_1, 1 ); 871 } ); 872 jQuery( '.ec_option_type_combo .ec_optionitem_images' ).click( function( ){ 873 var product_id = jQuery( this ).parent().parent().attr( 'data-product-id' ); 874 var rand_id = jQuery( this ).parent().parent().attr( 'data-rand-id' ); 875 var optionitem_id_1 = jQuery( this ).val( ); 876 ec_option1_image_change( product_id, rand_id, optionitem_id_1, 1 ); 877 } ); 878 jQuery( '.ec_option_type_combo .ec_optionitem_images' ).on( 'change', function( ){ 879 var product_id = jQuery( this ).parent().parent().attr( 'data-product-id' ); 880 var rand_id = jQuery( this ).parent().parent().attr( 'data-rand-id' ); 881 var optionitem_id_1 = jQuery( this ).val( ); 882 ec_option1_image_change( product_id, rand_id, optionitem_id_1, 1 ); 883 } ); 884 jQuery( '.ec_option_type_swatch li.ec_optionitem_images' ).click( function( ){ 885 var product_id = jQuery( this ).parent().parent().parent().attr( 'data-product-id' ); 886 var rand_id = jQuery( this ).parent().parent().parent().attr( 'data-rand-id' ); 887 var optionitem_id_1 = jQuery( this ).attr( 'data-optionitem-id' ); 888 ec_option1_image_change( product_id, rand_id, optionitem_id_1, 1 ); 889 } ); 890 jQuery( '.ec_details_combo.ec_option1' ).change( function( ){ 891 var product_id = jQuery( this ).parent().parent().attr( 'data-product-id' ); 892 var rand_id = jQuery( this ).parent().parent().attr( 'data-rand-id' ); 893 var optionitem_id_1 = jQuery( '.ec_details_combo.ec_option1_' + product_id + '_' + rand_id ).val( ); 894 var quantity = jQuery( '.ec_details_combo.ec_option1_' + product_id + '_' + rand_id + ' option:selected' ).attr( 'data-optionitem-quantity' ); 895 var use_optionitem_quantity_tracking = jQuery( document.getElementById( 'use_optionitem_quantity_tracking_' + product_id + '_' + rand_id ) ).val(); 896 if ( jQuery( document.getElementById( 'ec_allow_backorders_' + product_id + '_' + rand_id ) ).length && '1' == jQuery( document.getElementById( 'ec_allow_backorders_' + product_id + '_' + rand_id ) ).val() ) { 897 use_optionitem_quantity_tracking = '0'; 898 } 899 if ( '1' == use_optionitem_quantity_tracking ) { 900 if( optionitem_id_1 != '0' ){ 901 ec_option1_selected( product_id, rand_id, optionitem_id_1, quantity ); 902 }else{ 903 jQuery( '.ec_details_combo.ec_option2_' + product_id + '_' + rand_id ).val( '0' ).prop( 'disabled', true ).addClass( 'ec_inactive' ); 904 jQuery( '.ec_details_combo.ec_option3_' + product_id + '_' + rand_id ).val( '0' ).prop( 'disabled', true ).addClass( 'ec_inactive' ); 905 jQuery( '.ec_details_combo.ec_option4_' + product_id + '_' + rand_id ).val( '0' ).prop( 'disabled', true ).addClass( 'ec_inactive' ); 906 jQuery( '.ec_details_combo.ec_option5_' + product_id + '_' + rand_id ).val( '0' ).prop( 'disabled', true ).addClass( 'ec_inactive' ); 907 jQuery( document.getElementById( 'ec_details_stock_quantity_' + product_id + '_' + rand_id ) ).html( quantity ); 908 if ( 'inf' != quantity ) { 909 jQuery( '.ec_details_stock_total' ).show(); 910 } else { 911 jQuery( '.ec_details_stock_total' ).hide(); 912 } 913 } 914 } else { 915 ec_option1_updated( product_id, rand_id, optionitem_id_1 ); 916 } 917 ec_option1_image_change( product_id, rand_id, optionitem_id_1, quantity ); 918 jQuery( '.ec_option1_' + product_id + '_' + rand_id + '.ec_details_option_row_error' ).hide( ); 919 ec_details_base_adjust_price( product_id, rand_id ); 920 } ); 921 jQuery( '.ec_details_combo.ec_option2' ).change( function( ){ 922 var product_id = jQuery( this ).parent().parent().attr( 'data-
922product-id' ); 923 var rand_id = jQuery( this ).parent().parent().attr( 'data-rand-id' ); 924 var use_optionitem_quantity_tracking = jQuery( document.getElementById( 'use_optionitem_quantity_tracking_' + product_id + '_' + rand_id ) ).val(); 925 if ( jQuery( document.getElementById( 'ec_allow_backorders_' + product_id + '_' + rand_id ) ).length && '1' == jQuery( document.getElementById( 'ec_allow_backorders_' + product_id + '_' + rand_id ) ).val() ) { 926 use_optionitem_quantity_tracking = '0'; 927 } 928 var optionitem_id_1 = 0; 929 if( jQuery( '.ec_details_swatches > li.ec_option1_' + product_id + '_' + rand_id + '.ec_selected, .ec_details_swatches_ele > li.ec_option1_' + product_id + '_' + rand_id + '.ec_selected' ).length ){ 930 optionitem_id_1 = jQuery( '.ec_details_swatches > li.ec_option1_' + product_id + '_' + rand_id + '.ec_selected, .ec_details_swatches_ele > li.ec_option1_' + product_id + '_' + rand_id + '.ec_selected' ).attr( 'data-optionitem-id' ); 931 }else{ 932 optionitem_id_1 = jQuery( '.ec_details_combo.ec_option1_' + product_id + '_' + rand_id ).val( ); 933 } 934 var optionitem_id_2 = jQuery( '.ec_details_combo.ec_option2_' + product_id + '_' + rand_id ).val( ); 935 if ( '1' == use_optionitem_quantity_tracking ) { 936 var quantity = jQuery( '.ec_details_combo.ec_option2_' + product_id + '_' + rand_id + ' option:selected' ).attr( 'data-optionitem-quantity' ); 937 if( optionitem_id_2 != '0' ){ 938 option2_selected( product_id, rand_id, optionitem_id_1, optionitem_id_2, quantity ); 939 }else{ 940 jQuery( document.getElementById( 'ec_details_stock_quantity_' + product_id + '_' + rand_id ) ).html( quantity ); 941 if ( 'inf' != quantity ) { 942 jQuery( '.ec_details_stock_total' ).show(); 943 } else { 944 jQuery( '.ec_details_stock_total' ).hide(); 945 } 946 } 947 } else { 948 ec_option2_updated( product_id, rand_id, optionitem_id_1, optionitem_id_2 ); 949 } 950 jQuery( '.ec_option2_' + product_id + '_' + rand_id + '.ec_details_option_row_error' ).hide( ); 951 ec_details_base_adjust_price( product_id, rand_id ); 952 } ); 953 jQuery( '.ec_details_combo.ec_option3' ).change( function( ){ 954 var product_id = jQuery( this ).parent().parent().attr( 'data-product-id' ); 955 var rand_id = jQuery( this ).parent().parent().attr( 'data-rand-id' ); 956 var use_optionitem_quantity_tracking = jQuery( document.getElementById( 'use_optionitem_quantity_tracking_' + product_id + '_' + rand_id ) ).val(); 957 if ( jQuery( document.getElementById( 'ec_allow_backorders_' + product_id + '_' + rand_id ) ).length && '1' == jQuery( document.getElementById( 'ec_allow_backorders_' + product_id + '_' + rand_id ) ).val() ) { 958 use_optionitem_quantity_tracking = '0'; 959 } 960 var optionitem_id_1 = 0; 961 if( jQuery( '.ec_details_swatches > li.ec_option1_' + product_id + '_' + rand_id + '.ec_selected, .ec_details_swatches_ele > li.ec_option1_' + product_id + '_' + rand_id + '.ec_selected' ).length ){ 962 optionitem_id_1 = jQuery( '.ec_details_swatches > li.ec_option1_' + product_id + '_' + rand_id + '.ec_selected, .ec_details_swatches_ele > li.ec_option1_' + product_id + '_' + rand_id + '.ec_selected' ).attr( 'data-optionitem-id' ); 963 }else{ 964 optionitem_id_1 = jQuery( '.ec_details_combo.ec_option1_' + product_id + '_' + rand_id ).val( ); 965 } 966 var optionitem_id_2 = 0; 967 if( jQuery( '.ec_details_swatches > li.ec_option2_' + product_id + '_' + rand_id + '.ec_selected, .ec_details_swatches_ele > li.ec_option2_' + product_id + '_' + rand_id + '.ec_selected' ).length ){ 968 optionitem_id_2 = jQuery( '.ec_details_swatches > li.ec_option2_' + product_id + '_' + rand_id + '.ec_selected, .ec_details_swatches_ele > li.ec_option2_' + product_id + '_' + rand_id + '.ec_selected' ).attr( 'data-optionitem-id' ); 969 }else{ 970 optionitem_id_2 = jQuery( '.ec_details_combo.ec_option2_' + product_id + '_' + rand_id ).val( ); 971 } 972 var optionitem_id_3 = jQuery( '.ec_details_combo.ec_option3_' + product_id + '_' + rand_id ).val( ); 973 if ( '1' == use_optionitem_quantity_tracking ) { 974 var quantity = jQuery( '.ec_details_combo.ec_option3_' + product_id + '_' + rand_id + ' option:selected' ).attr( 'data-optionitem-quantity' ); 975 if( optionitem_id_3 != '0' ){ 976 option3_selected( product_id, rand_id, optionitem_id_1, optionitem_id_2, optionitem_id_3, quantity ); 977 }else{ 978 jQuery( document.getElementById( 'ec_details_stock_quantity_' + product_id + '_' + rand_id ) ).html( quantity ); 979 if ( 'inf' != quantity ) { 980 jQuery( '.ec_details_stock_total' ).show(); 981 } else { 982 jQuery( '.ec_details_stock_total' ).hide(); 983 } 984 } 985 } else { 986 ec_option3_updated( product_id, rand_id, optionitem_id_1, optionitem_id_2, optionitem_id_3 ); 987 } 988 jQuery( '.ec_option3_' + product_id + '_' + rand_id + '.ec_details_option_row_error' ).hide( ); 989 ec_details_base_adjust_price( product_id, rand_id ); 990 } ); 991 jQuery( '.ec_details_combo.ec_option4' ).change( function( ){ 992 var product_id = jQuery( this ).parent().parent().attr( 'data-
992product-id' ); 993 var rand_id = jQuery( this ).parent().parent().attr( 'data-rand-id' ); 994 var use_optionitem_quantity_tracking = jQuery( document.getElementById( 'use_optionitem_quantity_tracking_' + product_id + '_' + rand_id ) ).val(); 995 if ( jQuery( document.getElementById( 'ec_allow_backorders_' + product_id + '_' + rand_id ) ).length && '1' == jQuery( document.getElementById( 'ec_allow_backorders_' + product_id + '_' + rand_id ) ).val() ) { 996 use_optionitem_quantity_tracking = '0'; 997 } 998 var optionitem_id_1 = 0; 999 if( jQuery( '.ec_details_swatches > li.ec_option1_' + product_id + '_' + rand_id + '.ec_selected, .ec_details_swatches_ele > li.ec_option1_' + product_id + '_' + rand_id + '.ec_selected' ).length ){ 1000 optionitem_id_1 = jQuery( '.ec_details_swatches > li.ec_option1_' + product_id + '_' + rand_id + '.ec_selected, .ec_details_swatches_ele > li.ec_option1_' + product_id + '_' + rand_id + '.ec_selected' ).attr( 'data-optionitem-id' ); 1001 }else{ 1002 optionitem_id_1 = jQuery( '.ec_details_combo.ec_option1_' + product_id + '_' + rand_id ).val( ); 1003 } 1004 var optionitem_id_2 = 0; 1005 if( jQuery( '.ec_details_swatches > li.ec_option2_' + product_id + '_' + rand_id + '.ec_selected, .ec_details_swatches_ele > li.ec_option2_' + product_id + '_' + rand_id + '.ec_selected' ).length ){ 1006 optionitem_id_2 = jQuery( '.ec_details_swatches > li.ec_option2_' + product_id + '_' + rand_id + '.ec_selected, .ec_details_swatches_ele > li.ec_option2_' + product_id + '_' + rand_id + '.ec_selected' ).attr( 'data-optionitem-id' ); 1007 }else{ 1008 optionitem_id_2 = jQuery( '.ec_details_combo.ec_option2_' + product_id + '_' + rand_id ).val( ); 1009 } 1010 var optionitem_id_3 = 0; 1011 if( jQuery( '.ec_details_swatches > li.ec_option3_' + product_id + '_' + rand_id + '.ec_selected, .ec_details_swatches_ele > li.ec_option3_' + product_id + '_' + rand_id + '.ec_selected' ).length ){ 1012 optionitem_id_3 = jQuery( '.ec_details_swatches > li.ec_option3_' + product_id + '_' + rand_id + '.ec_selected, .ec_details_swatches_ele > li.ec_option3_' + product_id + '_' + rand_id + '.ec_selected' ).attr( 'data-optionitem-id' ); 1013 }else{ 1014 optionitem_id_3 = jQuery( '.ec_details_combo.ec_option3_' + product_id + '_' + rand_id ).val( ); 1015 } 1016 var optionitem_id_4 = jQuery( '.ec_details_combo.ec_option4_' + product_id + '_' + rand_id ).val( ); 1017 if ( '1' == use_optionitem_quantity_tracking ) { 1018 var quantity = jQuery( '.ec_details_combo.ec_option4_' + product_id + '_' + rand_id + ' option:selected' ).attr( 'data-optionitem-quantity' ); 1019 if( optionitem_id_4 != '0' ){ 1020 option4_selected( product_id, rand_id, optionitem_id_1, optionitem_id_2, optionitem_id_3, optionitem_id_4, quantity ); 1021 }else{ 1022 jQuery( document.getElementById( 'ec_details_stock_quantity_' + product_id + '_' + rand_id ) ).html( quantity ); 1023 if ( 'inf' != quantity ) { 1024 jQuery( '.ec_details_stock_total' ).show(); 1025 } else { 1026 jQuery( '.ec_details_stock_total' ).hide(); 1027 } 1028 } 1029 } else { 1030 ec_option4_updated( product_id, rand_id, optionitem_id_1, optionitem_id_2, optionitem_id_3, optionitem_id_4 ); 1031 } 1032 jQuery( '.ec_option4_' + product_id + '_' + rand_id + '.ec_details_option_row_error' ).hide( ); 1033 ec_details_base_adjust_price( product_id, rand_id ); 1034 } ); 1035 jQuery( '.ec_details_combo.ec_option5' ).change( function( ){ 1036 var product_id = jQuery( this ).parent().parent().attr( 'data-product-id' ); 1037 var rand_id = jQuery( this ).parent().parent().attr( 'data-rand-id' ); 1038 var use_optionitem_quantity_tracking = jQuery( document.getElementById( 'use_optionitem_quantity_tracking_' + product_id + '_' + rand_id ) ).val(); 1039 if ( jQuery( document.getElementById( 'ec_allow_backorders_' + product_id + '_' + rand_id ) ).length && '1' == jQuery( document.getElementById( 'ec_allow_backorders_' + product_id + '_' + rand_id ) ).val() ) { 1040 use_optionitem_quantity_tracking = '0'; 1041 } 1042 if ( '1' == use_optionitem_quantity_tracking ) { 1043 var quantity = jQuery( '.ec_details_combo.ec_option5_' + product_id + '_' + rand_id + ' option:selected' ).attr( 'data-optionitem-quantity' ); 1044 jQuery( document.getElementById( 'ec_details_stock_quantity_' + product_id + '_' + rand_id ) ).html( quantity ); 1045 if ( 'inf' != quantity ) { 1046 jQuery( '.ec_details_stock_total' ).show(); 1047 } else { 1048 jQuery( '.ec_details_stock_total' ).hide(); 1049 } 1050 } 1051 jQuery( '.ec_option5_' + product_id + '_' + rand_id + '.ec_details_option_row_error' ).hide( ); 1052 ec_details_base_adjust_price( product_id, rand_id ); 1053 } ); 1054 jQuery( '.ec_details_tab' ).click( function( ){
1055 var product_id = jQuery( this ).parent().attr( 'data-product-id' ); 1056 var rand_id = jQuery( this ).parent().attr( 'data-rand-id' ); 1057 jQuery( '.ec_details_tab_' + product_id + '_' + rand_id ).removeClass( 'ec_active' ); 1058 jQuery( this ).addClass( 'ec_active' ); 1059 jQuery( '.ec_details_extra_area_' + product_id + '_' + rand_id ).children( 'div' ).each( function( ){ 1060 jQuery( this ).hide() 1061 } ); 1062 if( jQuery( this ).hasClass( 'ec_description' ) ) { 1063 jQuery( '.ec_details_description_tab_' + product_id + '_' + rand_id ).show( ); 1064 } else if( jQuery( this ).hasClass( 'ec_specifications' ) ) { 1065 jQuery( '.ec_details_specifications_tab_' + product_id + '_' + rand_id ).show( ); 1066 } else if( jQuery( this ).hasClass( 'ec_customer_reviews' ) ) { 1067 jQuery( '.ec_details_customer_reviews_tab_' + product_id + '_' + rand_id ).show( ); 1068 } else { 1069 jQuery( '.ec_details_' + jQuery( this ).attr( 'data-tab-id' ) + '_tab' ).show( ); 1070 } 1071 jQuery( this ).parent().toggleClass( 'ec_is_open' ); 1072 } ); 1073 jQuery( '.ec_details_review_input' ).click( function() { 1074 var product_id = jQuery( this ).parent().attr( 'data-product-id' ); 1075 var rand_id = jQuery( this ).parent().attr( 'data-rand-id' ); 1076 var score = jQuery( this ).attr( 'data-review-score' ); 1077 if ( jQuery( '.ec_details_review_input_' + product_id + '_' + rand_id ).hasClass( 'ec_product_details_star_off_ele' ) || jQuery( '.ec_details_review_input_' + product_id + '_' + rand_id ).hasClass( 'ec_product_details_star_on_ele' ) ) { 1078 jQuery( '.ec_details_review_input_' + product_id + '_' + rand_id ).removeClass( 'ec_product_details_star_on_ele' ).addClass( 'ec_product_details_star_off_ele' ); 1079 } else { 1080 jQuery( '.ec_details_review_input_' + product_id + '_' + rand_id ).removeClass( 'ec_product_details_star_on' ).addClass( 'ec_product_details_star_off' ); 1081 } 1082 for( var i=0; i<score; i++ ){ 1083 if ( jQuery( document.getElementById( 'ec_details_review_star' + (i+1) + '_' + product_id + '_' + rand_id ) ).hasClass( 'ec_product_details_star_off_ele' ) || jQuery( document.getElementById( 'ec_details_review_star' + (i+1) + '_' + product_id + '_' + rand_id ) ).hasClass( 'ec_product_details_star_on_ele' ) ) { 1084 jQuery( document.getElementById( 'ec_details_review_star' + (i+1) + '_' + product_id + '_' + rand_id ) ).removeClass( 'ec_product_details_star_off_ele' ).addClass( 'ec_product_details_star_on_ele' ); 1085 } else { 1086 jQuery( document.getElementById( 'ec_details_review_star' + (i+1) + '_' + product_id + '_' + rand_id ) ).removeClass( 'ec_product_details_star_off' ).addClass( 'ec_product_details_star_on' ); 1087 } 1088 } 1089 } ); 1090 if( jQuery( '.ec_product_details_page' ).length ) { 1091 jQuery( '.ec_product_details_page' ).each( function() { 1092 var product_id = jQuery( this ).attr( 'data-product-id' ); 1093 var rand_id = jQuery( this ).attr( 'data-rand-id' ); 1094 ec_details_base_adjust_price( product_id, rand_id ); 1095 ec_details_advanced_adjust_price( product_id, rand_id ); 1096 ec_details_advanced_conditional_logic( product_id, rand_id ); 1097 } ); 1098 jQuery( '.ec_product_openclose' ).hide( ); 1099 } 1100 if ( jQuery( '.ec_details_inquiry_popup' ).length ) { 1101 jQuery( '.ec_details_inquiry_popup' ).appendTo( document.body ); 1102 } 1103 if ( jQuery( '.ec_details_large_popup' ).length ) { 1104 jQuery( '.ec_details_large_popup' ).appendTo( document.body ); 1105 } 1106 if ( jQuery( document.getElementById('ec_cart_login_loader' ) ).length ) { 1107 jQuery( document.getElementById( 'ec_cart_login_loader' ) ).appendTo( document.body ); 1108 } 1109 if ( jQuery( document.getElementById('ec_cart_create_account_loader' ) ).length ) { 1110 jQuery( document.getElementById( 'ec_cart_create_account_loader' ) ).appendTo( document.body ); 1111 } 1112 if ( jQuery( document.getElementById('ec_cart_address_loader' ) ).length ) { 1113 jQuery( document.getElementById( 'ec_cart_address_loader' ) ).appendTo( document.body ); 1114 } 1115 if ( jQuery( document.getElementById('ec_cart_subscription_shipping_methods_loader' ) ).length ) { 1116 jQuery( document.getElementById( 'ec_cart_subscription_shipping_methods_loader' ) ).appendTo( document.body ); 1117 } 1118 var shippingAddressTimer; 1119 var billingAddressTimer; 1120 var contactEmailTimer; 1121 jQuery( document ).on( 'change keyup', 'input.ec_cart_auto_validate_v2', function() { 1122 if ( jQuery( this ).hasClass( 'ec_cart_shipping_input_text' ) ) { 1123 if ( ec_validate_address_block( 'ec_cart_shipping' ) ) { 1124 if ( jQuery( document.getElementById( 'ec_cart_onepage_info' ) ).length ) { 1125 clearTimeout( shippingAddressTimer ); 1126 shippingAddressTimer = setTimeout( function() { 1127 wp_easycart_goto_shipping_v2(); 1128 if ( jQuery( document.getElementById( 'ec_shipping_order_error' ) ).length ) { 1129 jQuery( document.getElementById( 'ec_shipping_order_error' ) ).hide(); 1130 } 1131 }, 800 ); 1132 } 1133 } 1134 } else if ( jQuery( this ).hasClass( 'ec_cart_contact_information_input_text' ) ) { 1135 if ( ec_validate_email_block( 'ec_contact' ) ) { 1136 clearTimeout( contactEmailTimer ); 1137 contactEmailTimer = setTimeout( function() { 1138 jQuery( document.getElementById( 'ec_email_order2_error' ) ).hide(); 1139 wp_easycart_update_contact_email_v2(); 1140 }, 800 ); 1141 } 1142 if ( jQuery( document.getElementById( 'ec_user_create_form' ) ).length && ec_validate_create_account( 'ec_contact' ) ) { 1143 jQuery( document.getElementById( 'ec_create_account_order_error' ) ).hide(); 1144 } 1145 } else { 1146 if ( ec_validate_address_block( 'ec_cart_billing' ) ) { 1147 clearTimeout( billingAddressTimer ); 1148 billingAddressTimer = setTimeout( function() { 1149 var shipping_selector = ( ! jQuery( '#billing_address_type_different' ).length || ( jQuery( '#billing_address_type_different' ).length && jQuery( '#billing_address_type_different' ).is( ':checked' ) ) ) ? '1' : '0'; 1150 ec_update_billing_address_display( shipping_selector, jQuery( document.getElementById( 'wp_easycart_update_billing_nonce' ) ).val() ); 1151 jQuery( document.getElementById( 'ec_billing_order_error' ) ).hide(); 1152 }, 800 ); 1153 } 1154 } 1155 } ); 1156 jQuery( document ).on( 'change', 'select.ec_cart_auto_validate_v2', function() { 1157 if ( jQuery( this ).hasClass( 'ec_cart_shipping_input_text' ) ) { 1158 if ( ec_validate_address_block( 'ec_cart_shipping' ) ) { 1159 if ( jQuery( document.getElementById( 'ec_cart_onepage_info' ) ).length ) { 1160 clearTimeout( shippingAddressTimer ); 1161 shippingAddressTimer = setTimeout( function() { 1162 wp_easycart_goto_shipping_v2(); 1163 if ( jQuery( document.getElementById( 'ec_shipping_order_error' ) ).length ) { 1164 jQuery( document.getElementById( 'ec_shipping_order_error' ) ).hide(); 1165 } 1166 }, 800 ); 1167 } 1168 } 1169 } else { 1170 if ( ec_validate_address_block( 'ec_cart_billing' ) ) { 1171 clearTimeout( billingAddressTimer ); 1172 billingAddressTimer = setTimeout( function() { 1173 var shipping_selector = ( ! jQuery( '#billing_address_type_different' ).length || ( jQuery( '#billing_address_type_different' ).length && jQuery( '#billing_address_type_different' ).is( ':checked' ) ) ) ? '1' : '0'; 1174 ec_update_billing_address_display( shipping_selector, jQuery( document.getElementById( 'wp_easycart_update_billing_nonce' ) ).val() ); 1175 jQuery( document.getElementById( 'ec_billing_order_error' ) ).hide(); 1176 }, 800 ); 1177 } 1178 } 1179 } ); 1180 jQuery( document ).on( 'change', '#preorder_pickup_date', function() { 1181 ec_cart_save_pickup_date_time(); 1182 } ); 1183 jQuery( document ).on( 'change', '#preorder_pickup_time', function() { 1184 ec_cart_save_pickup_date_time(); 1185 } ); 1186 jQuery( document ).on( 'click', '#restaurant_pickup_time_asap', function() { 1187 ec_cart_save_pickup_date_time(); 1188 } ); 1189 jQuery( document ).on( 'click', '#restaurant_pickup_time_schedule', function() { 1190 ec_cart_save_pickup_date_time(); 1191 } ); 1192 jQuery( document ).on( 'change', '#restaurant_pickup_time', function() { 1193 ec_cart_save_pickup_date_time(); 1194 } ); 1195 jQuery( '.wp-easycart-orders-pagination' ).each( function() { 1196 const pagination_container = jQuery( this ); 1197 const order_wrapper = pagination_container.parent(); 1198 if ( order_wrapper.length === 0 ) { 1199 return; 1200 } 1201 const all_order_rows = order_wrapper.find( '.wp-easycart-order-item' ); 1202 const all_page_links = pagination_container.find( '.wp-easycart-orders-pagination-page-num' ); 1203 const page_numbers_container = pagination_container.find( '.wp-easycart-orders-page-numbers' ); 1204 const per_page = parseInt( pagination_container.find('.wp-easycart-orders-pagination-per-page').val(), 10 ); 1205 const total_pages = parseInt( pagination_container.find( '.wp-easycart-orders-pagination-total-pages').val(), 10 ); 1206 let current_page = 1; 1207 const page_next_to = 2; 1208 function wp_easycart_pagination_show_page( page ) { 1209 const start_i = ( page - 1 ) * per_page; 1210 const end_i = start_i + per_page; 1211 all_order_rows.hide(); 1212 all_order_rows.slice( start_i, end_i ).css( 'display', 'flex' ); 1213 } 1214 function wp_easycart_pagination_update_display( page ) { 1215 all_page_links.removeClass( 'active' ); 1216 all_page_links.filter( '[data-page="' + page + '"]' ).addClass( 'active' ); 1217 pagination_container.find( '.wp-easycart-orders-pagination-first-page, .wp-easycart-orders-pagination-prev-page' ).toggleClass( 'disabled', page === 1 ); 1218 pagination_container.find( '.wp-easycart-orders-pagination-next-page, .wp-easycart-orders-pagination-last-page' ).toggleClass( 'disabled', page === total_pages ); 1219 all_page_links.hide(); 1220 page_numbers_container.find( '.wp-easycart-orders-pagination-ellipsis' ).remove(); 1221 const ellipsis = jQuery( '<span class="wp-easycart-orders-pagination-ellipsis">...</span>' ); 1222 let pagesToShow = []; 1223 pagesToShow.push( all_page_links.eq(0) ); 1224 let start = Math.max( 1, page - page_next_to ); 1225 let end = Math.min( total_pages - 2, page + page_next_to ); 1226 if ( page - page_next_to <= 1 ) { 1227 end = Math.min(total_pages - 2, 1 + (page_next_to * 2)); 1228 } 1229 if (page + page_next_to >= total_pages - 2) { 1230 start = Math.max(1, total_pages - 2 - (page_next_to * 2)); 1231 } 1232 if ( start > 1 ) { 1233 pagesToShow.push( ellipsis.clone() ); 1234 } 1235 for ( let i = start; i <= end; i++ ) { 1236 pagesToShow.push( all_page_links.eq(i) ); 1237 } 1238 if ( end < total_pages - 2 ) { 1239 pagesToShow.push( ellipsis.clone() ); 1240 } 1241 if ( total_pages > 1 ) { 1242 pagesToShow.push( all_page_links.eq( total_pages - 1 ) ); 1243 } 1244 jQuery.each( pagesToShow, function() { 1245 if ( jQuery( this ).is( 'a' ) ) { 1246 jQuery( this ).show(); 1247 } else { 1248 page_numbers_container.append( this ); 1249 } 1250 } ); 1251 if ( total_pages > 1 ) { 1252 all_page_links.eq( total_pages - 1 ).show(); 1253 } 1254 } 1255 pagination_container.on( 'click', 'a[data-page]', function(e) { 1256 e.preventDefault(); 1257 const target = jQuery( this ); 1258 if ( target.hasClass( 'disabled' ) || target.hasClass( 'active' ) ) { 1259 return; 1260 } 1261 const page_control = target.data( 'page' ); 1262 let new_page = current_page; 1263 switch ( page_control ) { 1264 case 'first': new_page = 1; break; 1265 case 'last': new_page = total_pages; break; 1266 case 'prev': new_page = Math.max( 1, current_page - 1 ); break; 1267 case 'next': new_page = Math.min( total_pages, current_page + 1 ); break;
1268 default: new_page = parseInt( page_control, 10 ); 1269 } 1270 if ( new_page !== current_page ) { 1271 current_page = new_page; 1272 wp_easycart_pagination_show_page( current_page ); 1273 wp_easycart_pagination_update_display( current_page ); 1274 } 1275 } ); 1276 if ( all_order_rows.length > 0 && total_pages > 0 ) { 1277 wp_easycart_pagination_show_page( 1 ); 1278 wp_easycart_pagination_update_display( 1 ); 1279 } else { 1280 pagination_container.hide(); 1281 } 1282 } ); 1283} ); 1284function ec_cart_restaurant_start_timer() { 1285 var restaurant_timer_minutes = parseInt( jQuery( '.ec_cart_restaurant_timer_min' ).html() ); 1286 var restaurant_timer_seconds = parseInt( jQuery( '.ec_cart_restaurant_timer_sec' ).html() ); 1287 var restaurant_total_seconds = restaurant_timer_minutes * 60 + restaurant_timer_seconds; 1288 var restaurant_timer = setInterval( function() { 1289 restaurant_total_seconds--; 1290 var minutesLeft = Math.floor( restaurant_total_seconds / 60 ); 1291 var secondsLeft = restaurant_total_seconds % 60; 1292 jQuery( '.ec_cart_restaurant_timer_min' ).html( minutesLeft.toString().padStart( 2, '0' ) ); 1293 jQuery( '.ec_cart_restaurant_timer_sec' ).html( secondsLeft.toString().padStart(2, '0') ); 1294 if ( restaurant_total_seconds <= 0 ) { 1295 clearInterval( restaurant_timer ); 1296 window.location.reload(); 1297 } 1298 }, 1000 ); 1299} 1300function ec_cart_save_pickup_date_time() { 1301 var pickup_date = ''; 1302 var pickup_date_time = ''; 1303 var pickup_asap = 0; 1304 var pickup_time = ''; 1305 if ( jQuery( '#preorder_pickup_date' ).length ) { 1306 pickup_date = jQuery( '#preorder_pickup_date' ).datepicker( 'getDate' ); 1307 pickup_date_time = jQuery( '#preorder_pickup_time' ).val(); 1308 if ( pickup_date && '' != pickup_date_time ) { 1309 jQuery( '#ec_preorder_pickup_error' ).hide(); 1310 } 1311 } 1312 if ( jQuery( '#restaurant_pickup_time_asap' ).length && jQuery( '#restaurant_pickup_time_asap' ).is( ':checked' ) ) { 1313 pickup_asap = 1; 1314 } 1315 if ( jQuery( '#restaurant_pickup_time' ).length ) { 1316 pickup_time = jQuery( '#restaurant_pickup_time' ).val(); 1317 } 1318 var data = { 1319 action: 'ec_ajax_save_pickup_info', 1320 pickup_date: pickup_date, 1321 pickup_date_time: pickup_date_time, 1322 pickup_asap: pickup_asap, 1323 pickup_time: pickup_time, 1324 nonce: jQuery( '#ec_cart_form_nonce' ).val() 1325 }; 1326 jQuery.ajax( { 1327 url: wpeasycart_ajax_object.ajax_url, 1328 type: 'post', 1329 data: data, 1330 cache: false 1331 } ); 1332} 1333var wpeasycart_login_recaptcha; 1334var wpeasycart_register_recaptcha; 1335var wpeasycart_product_stock_recaptcha; 1336var wpeasycart_inquiry_recaptcha; 1337var wpeasycart_recaptcha_onload = function ( ){ 1338 if( jQuery( document.getElementById( 'ec_account_login_recaptcha' ) ).length ){ 1339 var wpeasycart_login_recaptcha = grecaptcha.render( document.getElementById( 'ec_account_login_recaptcha' ), { 1340 'sitekey' : jQuery( document.getElementById( 'ec_grecaptcha_site_key' ) ).val( ), 1341 'callback' : wpeasycart_login_recaptcha_callback 1342 }); 1343 } 1344 if( jQuery( document.getElementById( 'ec_account_login_widget_recaptcha' ) ).length ){ 1345 var wpeasycart_login_widget_recaptcha = grecaptcha.render( document.getElementById( 'ec_account_login_widget_recaptcha' ), { 1346 'sitekey' : jQuery( document.getElementById( 'ec_grecaptcha_site_key' ) ).val( ), 1347 'callback' : wpeasycart_login_widget_recaptcha_callback 1348 }); 1349 } 1350 if( jQuery( document.getElementById( 'ec_account_register_recaptcha' ) ).length ){ 1351 var wpeasycart_register_recaptcha = grecaptcha.render( document.getElementById( 'ec_account_register_recaptcha' ), { 1352 'sitekey' : jQuery( document.getElementById( 'ec_grecaptcha_site_key' ) ).val( ), 1353 'callback' : wpeasycart_register_recaptcha_callback 1354 }); 1355 } 1356 if( jQuery( document.getElementById( 'ec_product_details_recaptcha' ) ).length ){ 1357 var wpeasycart_register_recaptcha = grecaptcha.render( document.getElementById( 'ec_product_details_recaptcha' ), { 1358 'sitekey' : jQuery( document.getElementById( 'ec_grecaptcha_site_key' ) ).val( ), 1359 'callback' : wpeasycart_product_details_recaptcha_callback 1360 }); 1361 } 1362 if( jQuery( document.getElementById( 'ec_product_details_inquiry_recaptcha' ) ).length ){ 1363 var wpeasycart_inquiry_recaptcha = grecaptcha.render( document.getElementById( 'ec_product_details_inquiry_recaptcha' ), { 1364 'sitekey' : jQuery( document.getElementById( 'ec_grecaptcha_site_key' ) ).val( ), 1365 'callback' : wpeasycart_inquiry_recaptcha_callback 1366 }); 1367 } 1368} 1369function ec_customer_review_paging( page, product_id ){ 1370 var review_ele = jQuery( '.ec_details_customer_review_list[data-product-id="' + product_id + '"]' ); 1371 var reviews = review_ele.find( 'li' ); 1372 var reviews_per_page = jQuery( document.getElementById( 'ec_details_reviews_per_page_' + product_id ) ).val( ); 1373 1374 if( reviews.length > reviews_per_page ){ 1375 var i=0; 1376 reviews.each( function( ){ 1377 if( i < (reviews_per_page * page ) && i >= (reviews_per_page * (page-1) ) ){ 1378 jQuery( this ).show( ); 1379 }else{ 1380 jQuery( this ).hide( ); 1381 } 1382 i++; 1383 } ); 1384 i=0; 1385 review_ele.find( '#ec_details_customer_review_paging_' + product_id + ' > button' ).removeClass( 'selected' ).each( function( ){ 1386 if( ( i+1 ) == page ){ 1387 jQuery( this ).addClass( 'selected' ); 1388 } 1389 i++; 1390 } ); 1391 } 1392} 1393function wpeasycart_login_recaptcha_callback( response ){ 1394 jQuery( document.getElementById( 'ec_grecaptcha_response_login' ) ).val( response ); 1395 if( response.length ){ 1396 jQuery( '#ec_account_login_recaptcha > div' ).css( 'border', 'none' ); 1397 }else{ 1398 jQuery( '#ec_account_login_recaptcha > div' ).css( 'border', '1px solid red' ); 1399 } 1400} 1401function wpeasycart_login_widget_recaptcha_callback( response ){ 1402 jQuery( document.getElementById( 'ec_grecaptcha_response_login_widget' ) ).val( response ); 1403 if( response.length ){ 1404 jQuery( '#ec_account_login_widget_recaptcha > div' ).css( 'border', 'none' ); 1405 }else{ 1406 jQuery( '#ec_account_login_widget_recaptcha > div' ).css( 'border', '1px solid red' ); 1407 } 1408} 1409function wpeasycart_register_recaptcha_callback( response ){ 1410 jQuery( document.getElementById( 'ec_grecaptcha_response_register' ) ).val( response ); 1411 if( response.length ){ 1412 jQuery( '#ec_account_register_recaptcha > div' ).css( 'border', 'none' ); 1413 }else{ 1414 jQuery( '#ec_account_register_recaptcha > div' ).css( 'border', '1px solid red' ); 1415 } 1416} 1417function wpeasycart_product_details_recaptcha_callback( response ){ 1418 jQuery( document.getElementById( 'ec_grecaptcha_response_product_details' ) ).val( response ); 1419 if( response.length ){ 1420 jQuery( '#ec_product_details_recaptcha > div' ).css( 'border', 'none' ); 1421 }else{ 1422 jQuery( '#ec_product_details_recaptcha > div' ).css( 'border', '1px solid red' ); 1423 } 1424} 1425function wpeasycart_inquiry_recaptcha_callback( response ){ 1426 jQuery( document.getElementById( 'ec_grecaptcha_response_inquiry' ) ).val( response ); 1427 if( response.length ){ 1428 jQuery( '#ec_product_details_inquiry_recaptcha > div' ).css( 'border', 'none' ); 1429 }else{ 1430 jQuery( '#ec_product_details_inquiry_recaptcha > div' ).css( 'border', '1px solid red' ); 1431 } 1432} 1433function wpeasycart_cart_billing_country_update( ){ 1434 if( document.getElementById( 'ec_cart_billing_country' ) ){ 1435 var selected_country = jQuery( document.getElementById( 'ec_cart_billing_country' ) ).val( ); 1436 if( ec_is_state_required( selected_country ) ) 1437 jQuery( document.getElementById( 'ec_billing_state_required' ) ).show( ); 1438 else 1439 jQuery( document.getElementById( 'ec_billing_state_required' ) ).hide( ); 1440 1441 if( document.getElementById( 'ec_cart_billing_state_' + selected_country ) ){ 1442 jQuery( '.ec_billing_state_dropdown, #ec_cart_billing_state' ).hide( ); 1443 jQuery( document.getElementById( 'ec_cart_billing_state_' + selected_country ) ).show( ); 1444 }else{ 1445 jQuery( '.ec_billing_state_dropdown' ).hide( ); 1446 jQuery( document.getElementById( 'ec_cart_billing_state' ) ).show( ); 1447 } 1448 } 1449} 1450function wpeasycart_cart_shipping_country_update( ){ 1451 if( document.getElementById( 'ec_cart_shipping_country' ) ){ 1452 var selected_country = jQuery( document.getElementById( 'ec_cart_shipping_country' ) ).val( ); 1453 if( ec_is_state_required( selected_country ) ) 1454 jQuery( document.getElementById( 'ec_shipping_state_required' ) ).show( ); 1455 else 1456 jQuery( document.getElementById( 'ec_shipping_state_required' ) ).hide( ); 1457 1458 if( document.getElementById( 'ec_cart_shipping_state_' + selected_country ) ){ 1459 jQuery( '.ec_shipping_state_dropdown, #ec_cart_shipping_state' ).hide( ); 1460 jQuery( document.getElementById( 'ec_cart_shipping_state_' + selected_country ) ).show( ); 1461 }else{ 1462 jQuery( '.ec_shipping_state_dropdown' ).hide( ); 1463 jQuery( document.getElementById( 'ec_cart_shipping_state' ) ).show( ); 1464 } 1465 } 1466} 1467function wpeasycart_account_billing_country_update( ){ 1468 if( document.getElementById( 'ec_account_billing_information_country' ) ){ 1469 var selected_country = jQuery( document.getElementById( 'ec_account_billing_information_country' ) ).val( ); 1470 if( ec_is_state_required( selected_country ) ) 1471 jQuery( document.getElementById( 'ec_billing_state_required' ) ).show( ); 1472 else 1473 jQuery( document.getElementById( 'ec_billing_state_required' ) ).hide( ); 1474 1475 if( document.getElementById( 'ec_account_billing_information_state_' + selected_country ) ){ 1476 jQuery( '.ec_billing_state_dropdown, #ec_account_billing_information_state' ).hide( ); 1477 jQuery( document.getElementById( 'ec_account_billing_information_state_' + selected_country ) ).show( ); 1478 }else{ 1479 jQuery( '.ec_billing_state_dropdown' ).hide( ); 1480 jQuery( document.getElementById( 'ec_account_billing_information_state' ) ).show( ); 1481 } 1482 } 1483} 1484function wpeasycart_account_shipping_country_update( ){ 1485 if( document.getElementById( 'ec_account_shipping_information_country' ) ){ 1486 var selected_country = jQuery( document.getElementById( 'ec_account_shipping_information_country' ) ).val( ); 1487 if( ec_is_state_required( selected_country ) ) 1488 jQuery( document.getElementById( 'ec_shipping_state_required' ) ).show( ); 1489 else 1490 jQuery( document.getElementById( 'ec_shipping_state_required' ) ).hide( ); 1491 1492 if( document.getElementById( 'ec_account_shipping_information_state_' + selected_country ) ){ 1493 jQuery( '.ec_shipping_state_dropdown, #ec_account_shipping_information_state' ).hide( ); 1494 jQuery( document.getElementById( 'ec_account_shipping_information_state_' + selected_country ) ).show( ); 1495 }else{ 1496 jQuery( '.ec_shipping_state_dropdown' ).hide( ); 1497 jQuery( document.getElementById( 'ec_account_shipping_information_state' ) ).show( ); 1498 } 1499 } 1500} 1501function wpeasycart_isTouchDevice() { 1502 return 'ontouchstart' in window || !!(navigator.msMaxTouchPoints); 1503} 1504function ec_product_show_quick_view_link( modelnum ){ 1505 jQuery( document.getElementById( 'ec_product_quickview_container_' + modelnum ) ).fadeIn(100); 1506} 1507function ec_product_hide_quick_view_link( modelnum ){ 1508 jQuery( document.getElementById( 'ec_product_quickview_container_' + modelnum ) ).fadeOut(100); 1509} 1510function change_product_sort( menu_id, menu_name, submenu_id, submenu_name, subsubmenu_id, subsubmenu_name, manufacturer_id, pricepoint_id, currentpage_selected, perpage, URL, divider, filter_option = '' ){ 1511 var url_string = URL + divider + "filternum=" + document.getElementById('sortfield').value; 1512 if( subsubmenu_id != 0 ){ 1513 url_string = url_string + "&subsubmenuid=" + subsubmenu_id; 1514 if( subsubmenu_name != 0 ) 1515 url_string = url_string + "&subsubmenu=" + subsubmenu_name; 1516 }else if( submenu_id != 0 ){ 1517 url_string = url_string + "&submenuid=" + submenu_id; 1518 if( submenu_name != 0 ) 1519 url_string = url_string + "&submenu=" + submenu_name; 1520 }else if( menu_id != 0 ){ 1521 url_string = url_string + "&menuid=" + menu_id; 1522 if( menu_name != 0 ) 1523 url_string = url_string + "&menu=" + menu_name; 1524 } 1525 if( manufacturer_id > 0 ) 1526 url_string = url_string + "&manufacturer=" + manufacturer_id; 1527 if( pricepoint_id > 0 ) 1528 url_string = url_string + "&pricepoint=" + pricepoint_id; 1529 if( currentpage_selected ) 1530 url_string = url_string + "&pagenum=" + currentpage_selected; 1531 if( perpage ) 1532 url_string = url_string + "&perpage=" + perpage; 1533 if( filter_option ) 1534 url_string = url_string + "&filter_option=" + filter_option; 1535 window.location = url_string; 1536} 1537function ec_add_to_cart_redirect( product_id, model_number, quantity, use_quantity_tracking, min_quantity, max_quantity, nonce, quantity_ele = false ) { 1538 return true; 1539} 1540function ec_add_to_cart( product_id, model_number, quantity, use_quantity_tracking, min_quantity, max_quantity, nonce, quantity_ele = false ) { 1541 if( !use_quantity_tracking || ( !isNaN( quantity ) && quantity > 0 && quantity >= min_quantity && quantity <= max_quantity ) ){ 1542 if ( quantity_ele && jQuery( '#' + quantity_ele ).length ) { 1543 if ( Number( jQuery( '#' + quantity_ele ).val() ) >= min_quantity && Number( jQuery( '#' + quantity_ele ).val() ) <= max_quantity ) { 1544 quantity = Number( jQuery( '#' + quantity_ele ).val() ); 1545 } 1546 } 1547 1548 ec_product_hide_quick_view_link( model_number ); 1549 jQuery( document.getElementById( 'ec_addtocart_quantity_exceeded_error_' + model_number ) ).hide( ); 1550 jQuery( document.getElementById( 'ec_addtocart_quantity_minimum_error_' + model_number ) ).hide( ); 1551 1552 jQuery( document.getElementById( "ec_product_loader_" + model_number ) ).show( ); 1553 var data = { 1554 action: 'ec_ajax_add_to_cart', 1555 product_id: product_id, 1556 model_number: model_number, 1557 quantity: quantity, 1558 nonce: nonce 1559 }; 1560 1561 jQuery.ajax( { 1562 url: wpeasycart_ajax_object.ajax_url, 1563 type: 'post', 1564 data: data, 1565 cache: false, 1566 success: function( data ){ 1567 var json_data = JSON.parse( data ); 1568 jQuery( document.getElementById( "ec_product_loader_" + model_number ) ).hide( ); 1569 jQuery( document.getElementById( "ec_product_added_" + model_number ) ).show( ).delay( 2500 ).fadeOut( 'slow' ); 1570 1571 if ( jQuery( document.getElementById( "ec_added_to_cart_" + product_id ) ).length ) { 1572 jQuery( document.getElementById( "ec_add_to_cart_" + product_id ) ).css( 'display', 'none' ); 1573 jQuery( document.getElementById( "ec_added_to_cart_" + product_id ) ).css( 'display', 'inline-block' ); 1574 } 1575 1576 if ( jQuery( document.getElementById( "ec_added_to_cart_type6_" + product_id ) ).length ) { 1577 jQuery( document.getElementById( "ec_add_to_cart_" + product_id ) ).css( 'display', 'none' ); 1578 jQuery( document.getElementById( "ec_added_to_cart_type6_" + product_id ) ).css( 'display', 'inline-block' ); 1579 } 1580 1581 jQuery( '.ec_product_added_to_cart' ).fadeIn( 'slow' ); 1582 jQuery( ".ec_cart_items_total" ).html( json_data[0].total_items ); 1583 jQuery( ".ec_cart_price_total" ).html( json_data[0].total_price ); 1584 1585 if( json_data[0].total_items == 1 ){ 1586 jQuery( ".ec_menu_cart_singular_text" ).show( ); 1587 jQuery( ".ec_menu_cart_plural_text" ).hide( ); 1588 }else{ 1589 jQuery( ".ec_menu_cart_singular_text" ).hide( ); 1590 jQuery( ".ec_menu_cart_plural_text" ).show( ); 1591 } 1592 1593 if( json_data[0].total_items == 0 ){ 1594 jQuery( ".ec_cart_price_total" ).hide( ); 1595 }else{ 1596 jQuery( ".ec_cart_price_total" ).show( ); 1597 } 1598 1599 if( jQuery( '.ec_cart_widget_minicart_product_padding' ).length ){ 1600 jQuery( '.ec_cart_widget_minicart_product_padding' ).html(''); 1601 for( var i=0; i<json_data.length; i++ ) { 1602 jQuery( '.ec_cart_widget_minicart_product_padding' ).append( '<div class="ec_cart_widget_minicart_product_title" id="ec_cart_widget_row_' + json_data[i].cartitem_id + '"><a href="' + json_data[i].link + '">' + json_data[i].title + '</a> x <span>' + json_data[i].quantity + '</span> @ <span>' + json_data[i].price + '</span></div>' ); 1603 } 1604 } 1605 if ( jQuery( '.wp-easycart-widget-cart-quantity' ).length ) { 1606 jQuery( '.wp-easycart-widget-cart-quantity' ).html( json_data[0].total_items ); 1607 } 1608 } 1609 } ); 1610 } else { 1611 if ( ! isNaN( quantity ) && ( quantity < min_quantity || quantity < 1 ) ) { 1612 jQuery( document.getElementById( 'ec_addtocart_quantity_minimum_error_' + model_number ) ).show( ); 1613 jQuery( document.getElementById( 'ec_addtocart_quantity_exceeded_error_' + model_number ) ).hide( ); 1614 } else { 1615 jQuery( document.getElementById( 'ec_addtocart_quantity_exceeded_error_' + model_number ) ).show( ); 1616 jQuery( document.getElementById( 'ec_addtocart_quantity_minimum_error_' + model_number
1616 ) ).hide( ); 1617 } 1618 } 1619 1620} 1621 1622function ec_minus_quantity( product_id, min_quantity ){ 1623 var currval = jQuery( document.getElementById( 'ec_quantity_' + product_id ) ).val( ); 1624 currval = Number( currval ) - 1; 1625 if( currval <= 0 ){ 1626 currval = 1; 1627 } 1628 if( currval < min_quantity ){ 1629 currval = min_quantity; 1630 } 1631 jQuery( document.getElementById( 'ec_quantity_' + product_id ) ).val( currval ); 1632} 1633 1634function ec_plus_quantity( product_id, track_quantity, max_quantity ){ 1635 if( jQuery( document.getElementById( 'ec_details_stock_quantity_' + product_id ) ).length && jQuery( document.getElementById( 'ec_details_stock_quantity_' + product_id ) ).val( ) != 10000000 ){ 1636 max_quantity = ( 'inf' == jQuery( document.getElementById( 'ec_details_stock_quantity_' + product_id ) ).html( ) ) ? 10000000 : Number( jQuery( document.getElementById( 'ec_details_stock_quantity_' + product_id ) ).html( ) ); 1637 } 1638 if( max_quantity > 0 && max_quantity != 10000000 ){ 1639 jQuery( document.getElementById( 'ec_quantity_' + product_id ) ).attr( 'max', max_quantity ); 1640 } 1641 var currval = Number( jQuery( document.getElementById( 'ec_quantity_' + product_id ) ).val( ) ); 1642 if( currval < Number( max_quantity ) ){ 1643 currval = currval + 1; 1644 }else if( max_quantity != 10000000 ){ 1645 currval = Number( max_quantity ); 1646 }else{ 1647 currval = currval + 1; 1648 } 1649 jQuery( document.getElementById( 'ec_quantity_' + product_id ) ).val( currval ); 1650} 1651 1652function ec_cartitem_delete( cartitem_id, model_number, nonce ){ 1653 var data = { 1654 action: 'ec_ajax_cartitem_delete', 1655 ec_v3_24: 'true', 1656 cartitem_id: cartitem_id, 1657 nonce: nonce 1658 } 1659 1660 jQuery( document.getElementById( 'ec_cartitem_delete_' + cartitem_id ) ).hide( ); 1661 jQuery( document.getElementById( 'ec_cartitem_deleting_' + cartitem_id ) ).show( ); 1662 1663 jQuery.ajax( { 1664 url: wpeasycart_ajax_object.ajax_url, 1665 type: 'post', 1666 data: data, 1667 cache: false, 1668 success: function(data){ 1669 jQuery( document.getElementById( 'ec_cartitem_row_' + cartitem_id ) ).remove( ); 1670 jQuery( '.ec_cartitem_' + cartitem_id ).remove(); 1671 jQuery( document.getElementById( 'ec_cartitem_min_error_' + cartitem_id ) ).remove( ); 1672 jQuery( document.getElementById( 'ec_cartitem_max_error_' + cartitem_id ) ).remove( ); 1673 jQuery( document.getElementById( 'ec_cart_widget_row_' + cartitem_id ) ).remove( ); 1674 var response_obj = JSON.parse( data ); 1675 ec_update_cart( response_obj ); 1676 } 1677 } ); 1678} 1679 1680var ec_cartitem_update_clickTimeout; 1681function ec_cartitem_update_v2( cartitem_id, model_number, nonce ){ 1682 clearTimeout( ec_cartitem_update_clickTimeout ); 1683 ec_cartitem_update_clickTimeout = setTimeout( function() { 1684 ec_cartitem_update( cartitem_id, model_number, nonce ); 1685 }, 500 ); 1686} 1687 1688function ec_cartitem_update( cartitem_id, model_number, nonce ){ 1689 var data = { 1690 action: 'ec_ajax_cartitem_update', 1691 ec_v3_24: 'true', 1692 cartitem_id: cartitem_id, 1693 quantity: jQuery( document.getElementById( 'ec_quantity_' + model_number ) ).val( ), 1694 nonce: nonce 1695 }; 1696 1697 jQuery( document.getElementById( 'ec_cartitem_updating_' + cartitem_id ) ).show( ); 1698 1699 jQuery.ajax( { 1700 url: wpeasycart_ajax_object.ajax_url, 1701 type: 'post', 1702 data: data, 1703 cache: false, 1704 success: function( data ){ 1705 jQuery( document.getElementById( 'ec_cartitem_updating_' + cartitem_id ) ).hide( ); 1706 var response_obj = JSON.parse( data ); 1707 ec_update_cart( response_obj ); 1708 } 1709 } ); 1710} 1711 1712function ec_apply_coupon( nonce, is_mobile = false ){ 1713 jQuery( document.getElementById( 'ec_apply_coupon' ) ).hide( ); 1714 if ( jQuery( '#ec_applying_coupon_v2' ).length ) { 1715 jQuery( '#ec_applying_coupon_v2' ).addClass( 'ec_cart_button_working_active' ); 1716 jQuery( '#ec_applying_coupon_v2_mobile' ).addClass( 'ec_cart_button_working_active' ); 1717 jQuery( document.getElementById( 'ec_apply_coupon_mobile' ) ).hide( ); 1718 } else { 1719 jQuery( document.getElementById( 'ec_applying_coupon' ) ).show( ); 1720 } 1721 1722 var coupon_code = ( is_mobile ) ? jQuery( document.getElementById( 'ec_coupon_code_mobile' ) ).val() : jQuery( document.getElementById( 'ec_coupon_code' ) ).val( ); 1723 if ( is_mobile ) { 1724 jQuery( document.getElementById( 'ec_coupon_code' ) ).val( coupon_code ); 1725 } else { 1726 if ( jQuery( document.getElementById( 'ec_coupon_code_mobile' ) ).length ) { 1727 jQuery( document.getElementById( 'ec_coupon_code_mobile' ) ).val( coupon_code ) 1728 } 1729 } 1730 1731 var data = { 1732 action: 'ec_ajax_redeem_coupon_code', 1733 ec_v3_24: 'true', 1734 couponcode: coupon_code, 1735 nonce: nonce 1736 }; 1737 1738 jQuery.ajax( { 1739 url: wpeasycart_ajax_object.ajax_url, 1740 type: 'post', 1741 data: data, 1742 cache: false, 1743 success: function( data ) { 1744 jQuery( document.getElementById( 'ec_apply_coupon' ) ).show( ); 1745 if ( jQuery( '#ec_applying_coupon_v2' ).length ) { 1746 jQuery( '#ec_applying_coupon_v2' ).removeClass( 'ec_cart_button_working_active' ); 1747 jQuery( '#ec_applying_coupon_v2_mobile' ).removeClass( 'ec_cart_button_working_active' ); 1748 jQuery( document.getElementById( 'ec_apply_coupon_mobile' ) ).show( ); 1749 } else { 1750 jQuery( document.getElementById( 'ec_applying_coupon' ) ).hide( ); 1751 } 1752 var response_obj = JSON.parse( data ); 1753 ec_update_cart( response_obj ); 1754 if ( response_obj.is_coupon_valid ) { 1755 jQuery( document.getElementById( 'ec_coupon_error' ) ).hide( ); 1756 jQuery( document.getElementById( 'ec_coupon_success' ) ).html( response_obj.coupon_message ).show( ); 1757 if ( jQuery( '#ec_applying_coupon_v2' ).length ) { 1758 jQuery( document.getElementById( 'ec_coupon_error_mobile' ) ).hide( ); 1759 jQuery( document.getElementById( 'ec_coupon_success_mobile' ) ).html( response_obj.coupon_message ).show( ); 1760 } 1761 } else { 1762 jQuery( document.getElementById( 'ec_coupon_success' ) ).hide( ); 1763 jQuery( document.getElementById( 'ec_coupon_error' ) ).html( response_obj.coupon_message ).show( ); 1764 if ( jQuery( '#ec_applying_coupon_v2' ).length ) { 1765 jQuery( document.getElementById( 'ec_coupon_success_mobile' ) ).hide( ); 1766 jQuery( document.getElementById( 'ec_coupon_error_mobile' ) ).html( response_obj.coupon_message ).show( ); 1767 } 1768 if ( jQuery( document.getElementById( 'ec_coupon_code_mobile' ) ).length ) { 1769 jQuery( document.getElementById( 'ec_coupon_code_mobile' ) ).val( '' ); 1770 } 1771 if ( jQuery( document.getElementById( 'ec_coupon_code' ) ).length ) { 1772 jQuery( document.getElementById( 'ec_coupon_code' ) ).val( '' ); 1773 } 1774 } 1775 } 1776 } ); 1777} 1778 1779function subscription_create_account( nonce ) { 1780 var email_complete = ec_validate_email_block( 'ec_contact' ); 1781 var create_account_complete = ec_validate_create_account( 'ec_contact' ); 1782 var recaptcha_complete = true; 1783 var recaptcha_response = ''; 1784 1785 if ( document.getElementById( 'ec_account_register_recaptcha' ) ) { 1786 recaptcha_response = jQuery( document.getElementById( 'ec_grecaptcha_response_register' ) ).val(); 1787 if ( ! recaptcha_response.length ) { 1788 jQuery( '#ec_account_register_recaptcha > div' ).css( 'border', '1px solid red' ); 1789 recaptcha_complete = false; 1790 } else { 1791 jQuery( '#ec_account_register_recaptcha > div' ).css( 'border', 'none' ); 1792 } 1793 } 1794 1795 if ( email_complete && create_account_complete && recaptcha_complete ) { 1796 jQuery( document.getElementById( 'ec_cart_create_account_loader' ) ).show(); 1797 1798 var email = jQuery( document.getElementById( 'ec_contact_email' ) ).val(); 1799 var first_name = ( jQuery( document.getElementById( 'ec_contact_first_name' ) ).length ) ? jQuery( document.getElementById( 'ec_contact_first_name' ) ).val() : ''; 1800 var last_name = ( jQuery( document.getElementById( 'ec_contact_last_name' ) ).length ) ? jQuery( document.getElementById( 'ec_contact_last_name' ) ).val() : ''; 1801 var password = jQuery( document.getElementById( 'ec_contact_password' ) ).val(); 1802 1803 var data = { 1804 action: 'ec_ajax_subscription_create_account', 1805 nonce: nonce, 1806 ec_contact_email: email, 1807 ec_contact_first_name: first_name, 1808 ec_contact_last_name: last_name, 1809 ec_contact_password: password, 1810 recaptcha_response: recaptcha_response 1811 }; 1812 1813 jQuery.ajax( { 1814 url: wpeasycart_ajax_object.ajax_url, 1815 type: 'post', 1816 data: data, 1817 cache: false, 1818 success: function( response ){ 1819 var data_arr = JSON.parse( response ); 1820 if ( data_arr['error'] ) { 1821 jQuery( document.getElementById( 'ec_subscription_email_exists' ) ).show(); 1822 jQuery( document.getElementById( 'ec_cart_create_account_loader' ) ).hide();
1823 if ( '' != recaptcha_response ) { 1824 jQuery( document.getElementById( 'ec_grecaptcha_response_register' ) ).val( '' ); 1825 grecaptcha.reset( wpeasycart_register_recaptcha ); 1826 } 1827 } else { 1828 ec_reload_cart(); 1829 jQuery( document.getElementById( 'ec_subscription_email_exists' ) ).hide(); 1830 jQuery( document.getElementById( 'ec_user_contact_form' ) ).hide(); 1831 jQuery( document.getElementById( 'ec_user_logged_out_header' ) ).hide(); 1832 jQuery( document.getElementById( 'ec_cart_user_logged_in_name' ) ).html( data_arr['name'] ); 1833 jQuery( document.getElementById( 'ec_cart_billing_first_name' ) ).val( data_arr['first_name'] ); 1834 jQuery( document.getElementById( 'ec_cart_billing_last_name' ) ).val( data_arr['last_name'] ); 1835 jQuery( document.getElementById( 'ec_cart_shipping_first_name' ) ).val( data_arr['first_name'] ); 1836 jQuery( document.getElementById( 'ec_cart_shipping_last_name' ) ).val( data_arr['last_name'] ); 1837 jQuery( document.getElementById( 'ec_user_logged_in_form' ) ).show(); 1838 jQuery( document.getElementById( 'ec_cart_billing_form' ) ).show(); 1839 jQuery( document.getElementById( 'ec_cart_billing_locked' ) ).hide(); 1840 if ( jQuery( document.getElementById( 'ec_cart_shipping_locked' ) ).length ) { 1841 jQuery( document.getElementById( 'ec_cart_shipping_locked' ) ).hide(); 1842 } 1843 jQuery( document.getElementById( 'ec_cart_subscription_end_form' ) ).hide(); 1844 } 1845 } 1846 } ); 1847 } 1848} 1849 1850function update_subscription_totals( product_id, nonce ){ 1851 var billing_complete = ec_validate_address_block( 'ec_cart_billing' ); 1852 var shipping_complete = true; 1853 1854 if( jQuery( document.getElementById( 'ec_shipping_selector' ) ).is( ':checked' ) ) { 1855 shipping_complete = ec_validate_address_block( 'ec_cart_shipping' ); 1856 } 1857 1858 if ( billing_complete && shipping_complete ) { 1859 jQuery( document.getElementById( 'ec_cart_address_loader' ) ).show(); 1860 1861 var shipping_selector = 0; 1862 if( jQuery( document.getElementById( 'ec_shipping_selector' ) ).length && jQuery( document.getElementById( 'ec_shipping_selector' ) ).is( ':checked' ) ){ 1863 shipping_selector = 1; 1864 } 1865 1866 var vat_registration_number = ''; 1867 if( jQuery( document.getElementById( 'ec_cart_billing_vat_registration_number' ) ).length ){ 1868 vat_registration_number = jQuery( document.getElementById( 'ec_cart_billing_vat_registration_number' ) ).val( ); 1869 } 1870 1871 var billing_first_name = ( jQuery( document.getElementById( 'ec_cart_billing_first_name' ) ).length ) ? jQuery( document.getElementById( 'ec_cart_billing_first_name' ) ).val() : ''; 1872 var billing_last_name = ( jQuery( document.getElementById( 'ec_cart_billing_last_name' ) ).length ) ? jQuery( document.getElementById( 'ec_cart_billing_last_name' ) ).val() : ''; 1873 var billing_company_name = ( jQuery( document.getElementById( 'ec_cart_billing_company_name' ) ).length ) ? jQuery( document.getElementById( 'ec_cart_billing_company_name' ) ).val() : ''; 1874 var billing_address_line_1 = ( jQuery( document.getElementById( 'ec_cart_billing_address' ) ).length ) ? jQuery( document.getElementById( 'ec_cart_billing_address' ) ).val() : ''; 1875 var billing_address_line_2 = ( jQuery( document.getElementById( 'ec_cart_billing_address2' ) ).length ) ? jQuery( document.getElementById( 'ec_cart_billing_address2' ) ).val() : ''; 1876 var billing_city = ( jQuery( document.getElementById( 'ec_cart_billing_city' ) ).length ) ? jQuery( document.getElementById( 'ec_cart_billing_city' ) ).val() : ''; 1877 var billing_state = jQuery( document.getElementById( 'ec_cart_billing_state' ) ).val(); 1878 var billing_zip = ( jQuery( document.getElementById( 'ec_cart_billing_zip' ) ).length ) ? jQuery( document.getElementById( 'ec_cart_billing_zip' ) ).val() : ''; 1879 var billing_country = jQuery( document.getElementById( 'ec_cart_billing_country' ) ).val(); 1880 if( '0' != billing_country && jQuery( document.getElementById( 'ec_cart_billing_state_' + billing_country ) ).length ){ 1881 billing_state = jQuery( document.getElementById( 'ec_cart_billing_state_' + billing_country ) ).val(); 1882 } 1883 var billing_phone = ( jQuery( document.getElementById( 'ec_cart_billing_phone' ) ).length ) ? jQuery( document.getElementById( 'ec_cart_billing_phone' ) ).val() : ''; 1884 1885 var shipping_first_name = billing_first_name; 1886 var shipping_last_name = billing_last_name; 1887 var shipping_company_name = billing_company_name; 1888 var shipping_address_line_1 = billing_address_line_1; 1889 var shipping_address_line_2 = billing_address_line_2; 1890 var shipping_city = billing_city; 1891 var shipping_state = billing_state; 1892 var shipping_zip = billing_zip; 1893 var shipping_country = billing_country; 1894 var shipping_phone = billing_phone; 1895 1896 if ( shipping_selector ) { 1897 shipping_state = jQuery( document.getElementById( 'ec_cart_shipping_state' ) ).val(); 1898 shipping_country = jQuery( document.getElementById( 'ec_cart_shipping_country' ) ).val(); 1899 if( '0' != shipping_country && jQuery( document.getElementById( 'ec_cart_shipping_state_' + shipping_country ) ).length ){ 1900 shipping_state = jQuery( document.getElementById( 'ec_cart_shipping_state_' + shipping_country ) ).val(); 1901 } 1902 shipping_first_name = ( jQuery( document.getElementById( 'ec_cart_shipping_first_name' ) ).length ) ? jQuery( document.getElementById( 'ec_cart_shipping_first_name' ) ).val() : ''; 1903 shipping_last_name = ( jQuery( document.getElementById( 'ec_cart_shipping_last_name' ) ).length ) ? jQuery( document.getElementById( 'ec_cart_shipping_last_name' ) ).val() : ''; 1904 shipping_company_name = ( jQuery( document.getElementById( 'ec_cart_shipping_company_name' ) ).length ) ? jQuery( document.getElementById( 'ec_cart_shipping_company_name' ) ).val() : ''; 1905 shipping_address_line_1 = ( jQuery( document.getElementById( 'ec_cart_shipping_address' ) ).length ) ? jQuery( document.getElementById( 'ec_cart_shipping_address' ) ).val() : ''; 1906 shipping_address_line_2 = ( jQuery( document.getElementById( 'ec_cart_shipping_address2' ) ).length ) ? jQuery( document.getElementById( 'ec_cart_shipping_address2' ) ).val() : ''; 1907 shipping_city = ( jQuery( document.getElementById( 'ec_cart_shipping_city' ) ).length ) ? jQuery( document.getElementById( 'ec_cart_shipping_city' ) ).val() : ''; 1908 shipping_zip = ( jQuery( document.getElementById( 'ec_cart_shipping_zip' ) ).length ) ? jQuery( document.getElementById( 'ec_cart_shipping_zip' ) ).val() : ''; 1909 shipping_phone = ( jQuery( document.getElementById( 'ec_cart_shipping_phone' ) ).length ) ? jQuery( document.getElementById( 'ec_cart_shipping_phone' ) ).val() : ''; 1910 1911 } 1912 1913 var data = { 1914 action: 'ec_ajax_update_subscription_tax', 1915 product_id: product_id, 1916 shipping_selector: shipping_selector, 1917 nonce: nonce, 1918 1919 vat_registration_number: vat_registration_number, 1920 1921 billing_first_name: billing_first_name, 1922 billing_last_name: billing_last_name, 1923 billing_company_name: billing_company_name, 1924 billing_country: billing_country, 1925 billing_address: billing_address_line_1, 1926 billing_address2: billing_address_line_2, 1927 billing_city: billing_city, 1928 billing_state: billing_state, 1929 billing_zip: billing_zip, 1930 billing_phone: billing_phone, 1931 1932 shipping_first_name: shipping_first_name, 1933 shipping_last_name: shipping_last_name, 1934 shipping_company_name: shipping_company_name, 1935 shipping_country: shipping_country, 1936 shipping_address: shipping_address_line_1, 1937 shipping_address2: shipping_address_line_2, 1938 shipping_city: shipping_city, 1939 shipping_state: shipping_state, 1940 shipping_zip: shipping_zip, 1941 shipping_phone: shipping_phone 1942 }; 1943 1944 jQuery.ajax( { 1945 url: wpeasycart_ajax_object.ajax_url, 1946 type: 'post', 1947 data: data, 1948 cache: false, 1949 success: function( response ) { 1950 var data_arr = JSON.parse( response ); 1951 wpeasycart_subscription_cart_update_totals( data_arr ); 1952 jQuery( document.getElementById( 'ec_cart_billing_form' ) ).hide(); 1953 jQuery( document.getElementById( 'ec_cart_billing_address_display' ) ).html( data_arr['billing_address_display'] ); 1954 jQuery( document.getElementById( 'ec_cart_billing_locked' ) ).show(); 1955 if ( jQuery( document.getElementById( 'ec_cart_shipping_locked' ) ).length ) { 1956 jQuery( document.getElementById( 'ec_cart_shipping_address_display' ) ).html( data_arr['shipping_address_display'] ); 1957 jQuery( document.getElementById( 'ec_cart_shipping_locked' ) ).show(); 1958 } 1959 jQuery( document.getElementById( 'ec_cart_subscription_end_form' ) ).show(); 1960 jQuery( document.getElementById( 'ec_cart_address_loader' ) ).hide(); 1961 } 1962 } ); 1963 } 1964} 1965 1966function wpeasycart_subscription_cart_update_totals( data_arr ) { 1967 jQuery( document.getElementById( 'ec_cart_discount' ) ).html( data_arr['discount_total'] ); 1968 jQuery( document.getElementById( 'ec_cart_discount_mobile' ) ).html( data_arr['discount_total'] ); 1969 if ( data_arr['has_discount'] ) { 1970 jQuery( '.ec_cart_price_row_discount_total' ).removeClass( 'ec_no_discount' ); 1971 } else { 1972 jQuery( '.ec_cart_price_row_discount_total' ).removeClass( 'ec_no_discount' ).addClass( 'ec_no_discount' ); 1973 } 1974 if( jQuery( document.getElementById( 'ec_cart_tax' ) ).length ){ 1975 jQuery( document.getElementById( 'ec_cart_tax' ) ).html( data_arr['tax_total'] ); 1976 jQuery( document.getElementById( 'ec_cart_tax_mobile' ) ).html( data_arr['tax_total'] ); 1977 } 1978 if( jQuery( document.getElementById( 'ec_cart_vat' ) ).length ){ 1979 jQuery( document.getElementById( 'ec_cart_vat' ) ).html( data_arr['vat_total'] ); 1980 jQuery( document.getElementById( 'ec_cart_vat_mobile' ) ).html( data_arr['vat_total'] ); 1981 } 1982 if( jQuery( document.getElementById( 'ec_cart_vat_rate' ) ).length ){ 1983 jQuery( document.getElementById( 'ec_cart_vat_rate' ) ).html( data_arr['vat_rate_formatted'] ); 1984 } 1985 if( jQuery( document.getElementById( 'ec_cart_vat_rate_mobile' ) ).length ){ 1986 jQuery( document.getElementById( 'ec_cart_vat_rate_mobile' ) ).html( data_arr['vat_rate_formatted'] ); 1987 } 1988 if( jQuery( document.getElementById( 'ec_cart_hst' ) ).length ){ 1989 jQuery( document.getElementById( 'ec_cart_hst' ) ).html( data_arr['hst_total'] ); 1990 jQuery( document.getElementById( 'ec_cart_hst_mobile' ) ).html( data_arr['hst_total'] ); 1991 jQuery( document.getElementById( 'ec_cart_hst_rate' ) ).html( data_arr['hst_rate'] ); 1992 jQuery( document.getElementById( 'ec_cart_hst_rate_mobile' ) ).html( data_arr['hst_rate'] ); 1993 if( data_arr['hst_rate'] > 0 ){ 1994 jQuery( document.getElementById( 'ec_cart_hst_row' ) ).show( ); 1995 jQuery( document.getElementById( 'ec_cart_hst_row_mobile' ) ).show( ); 1996 }else{ 1997 jQuery( document.getElementById( 'ec_cart_hst_row' ) ).hide( ); 1998 jQuery( document.getElementById( 'ec_cart_hst_row_mobile' ) ).hide( ); 1999 } 2000 } 2001 2002 if( jQuery( document.getElementById( 'ec_cart_pst' ) ).length ){ 2003 jQuery( document.getElementById( 'ec_cart_pst' ) ).html( data_arr['pst_total'] ); 2004 jQuery( document.getElementById( 'ec_cart_pst_mobile' ) ).html( data_arr['pst_total'] ); 2005 jQuery( document.getElementById( 'ec_cart_pst_rate' ) ).html( data_arr['pst_rate'] ); 2006 jQuery( document.getElementById( 'ec_cart_pst_rate_mobile' ) ).html( data_arr['pst_rate'] ); 2007 if ( data_arr['pst_label'] ) { // QST for Quebec addresses 2008 jQuery( document.getElementById( 'ec_cart_pst_label' ) ).text( data_arr['pst_label'] ); 2009 jQuery( document.getElementById( 'ec_cart_pst_label_mobile' ) ).text( data_arr['pst_label'] ); 2010 } 2011 if( data_arr['pst_rate'] > 0 ){ 2012 jQuery( document.getElementById( 'ec_cart_pst_row' ) ).show( ); 2013 jQuery( document.getElementById( 'ec_cart_pst_row_mobile' ) ).show( ); 2014 }else{ 2015 jQuery( document.getElementById( 'ec_cart_pst_row' ) ).hide( ); 2016 jQuery( document.getElementById( 'ec_cart_pst_row_mobile' ) ).hide( ); 2017 } 2018 } 2019 2020 if( jQuery( document.getElementById( 'ec_cart_gst' ) ).length ){ 2021 jQuery( document.getElementById( 'ec_cart_gst' ) ).html( data_arr['gst_total'] ); 2022 jQuery( document.getElementById( 'ec_cart_gst_mobile' ) ).html( data_arr['gst_total'] ); 2023 jQuery( document.getElementById( 'ec_cart_gst_rate' ) ).html( data_arr['gst_rate'] ); 2024 jQuery( document.getElementById( 'ec_cart_gst_rate_mobile' ) ).html( data_arr['gst_rate'] ); 2025 if( data_arr['gst_rate'] > 0 ){ 2026 jQuery( document.getElementById( 'ec_cart_gst_row' ) ).show( ); 2027 jQuery( document.getElementById( 'ec_cart_gst_row_mobile' ) ).show( ); 2028 }else{ 2029 jQuery( document.getElementById( 'ec_cart_gst_row' ) ).hide( ); 2030 jQuery( document.getElementById( 'ec_cart_gst_row_mobile' ) ).hide( ); 2031 } 2032 } 2033 2034 if( jQuery( document.getElementById( 'ec_cart_shipping' ) ).length ){ 2035 jQuery( document.getElementById( 'ec_cart_shipping' ) ).html( data_arr['shipping_total'] ); 2036 jQuery( document.getElementById( 'ec_cart_shipping_mobile' ) ).html( data_arr['shipping_total'] ); 2037 } 2038 2039 if ( jQuery( document.getElementById( 'ec_cart_subscription_shipping_methods' ) ).length ) { 2040 jQuery( document.getElementById( 'ec_cart_subscription_shipping_methods' ) ).html( data_arr['shipping_methods'] ); 2041 } 2042 2043 jQuery( document.getElementById( 'ec_cart_total' ) ).html( data_arr['grand_total'] ); 2044 jQuery( document.getElementById( 'ec_cart_total_mobile' ) ).html( data_arr['grand_total'] ); 2045 2046 if( Number( data_arr['has_tax'] ) == 1 ){ 2047 jQuery( '#ec_cart_tax_row' ).show( ); 2048 jQuery( '#ec_cart_tax_row_mobile' ).show( ); 2049 }else{ 2050 jQuery( '#ec_cart_tax_row' ).hide( ); 2051 jQuery( '#ec_cart_tax_row_mobile' ).hide( ); 2052 } 2053 if( Number( data_arr['has_vat'] ) == 1 ){ 2054 jQuery( '#ec_cart_vat_row' ).show( ); 2055 jQuery( '#ec_cart_vat_row_mobile' ).show( ); 2056 }else{ 2057 jQuery( '#ec_cart_vat_row' ).hide( ); 2058 jQuery( '#ec_cart_vat_row_mobile' ).hide( ); 2059 } 2060} 2061 2062function ec_apply_subscription_coupon( product_id, manufacturer_id, nonce, is_mobile = false ){ 2063 2064 jQuery( document.getElementById( 'ec_apply_coupon' ) ).hide( ); 2065 jQuery( document.getElementById( 'ec_applying_coupon' ) ).show( ); 2066 jQuery( document.getElementById( 'ec_apply_coupon_mobile' ) ).hide( ); 2067 jQuery( document.getElementById( 'ec_applying_coupon_mobile' ) ).show( ); 2068 2069 var coupon_code = ( is_mobile ) ? jQuery( document.getElementById( 'ec_coupon_code_mobile' ) ).val() : jQuery( document.getElementById( 'ec_coupon_code' ) ).val(); 2070 jQuery( document.getElementById( 'ec_coupon_code_mobile' ) ).val( coupon_code ); 2071 jQuery( document.getElementById( 'ec_coupon_code' ) ).val( coupon_code); 2072 2073 var data = { 2074 action: 'ec_ajax_redeem_subscription_coupon_code', 2075 product_id: product_id, 2076 manufacturer_id: manufacturer_id, 2077 couponcode: coupon_code, 2078 nonce: nonce 2079 }; 2080 2081 jQuery.ajax( { 2082 url: wpeasycart_ajax_object.ajax_url, 2083 type: 'post', 2084 data: data, 2085 cache: false, 2086 success: function( data ){ 2087 jQuery( document.getElementById( 'ec_apply_coupon' ) ).show( ); 2088 jQuery( document.getElementById( 'ec_applying_coupon' ) ).hide( ); 2089 jQuery( document.getElementById( 'ec_apply_coupon_mobile' ) ).show( ); 2090 jQuery( document.getElementById( 'ec_applying_coupon_mobile' ) ).hide( ); 2091 2092 var data_arr = JSON.parse( data ); 2093 2094 if( data_arr['coupon_status'] == "valid" ){ 2095 jQuery( document.getElementById( 'ec_coupon_error' ) ).hide( ); 2096 jQuery( document.getElementById( 'ec_coupon_success' ) ).html( data_arr['coupon_message'] ).show( ); 2097 jQuery( document.getElementById( 'ec_coupon_error_mobile' ) ).hide( ); 2098 jQuery( document.getElementById( 'ec_coupon_success_mobile' ) ).html( data_arr['coupon_message'] ).show( ); 2099 }else{ 2100 jQuery( document.getElementById( 'ec_coupon_success' ) ).hide( ); 2101 jQuery( document.getElementById( 'ec_coupon_error' ) ).html( data_arr['coupon_message'] ).show( ); 2102 jQuery( document.getElementById( 'ec_coupon_success_mobile' ) ).hide( ); 2103 jQuery( document.getElementById( 'ec_coupon_error_mobile' ) ).html( data_arr['coupon_message'] ).show( ); 2104 } 2105 2106 wpeasycart_subscription_cart_update_totals( data_arr ); 2107 } 2108 } ); 2109} 2110 2111function ec_apply_gift_card( nonce, is_mobile = false ){ 2112 jQuery( document.getElementById( 'ec_apply_gift_card' ) ).hide( ); 2113 if ( jQuery( '#ec_applying_gift_card_v2' ).length ) { 2114 jQuery( '#ec_applying_gift_card_v2' ).addClass( 'ec_cart_button_working_active' ); 2115 jQuery( '#ec_applying_gift_card_v2_mobile' ).addClass( 'ec_cart_button_working_active' ); 2116 jQuery( document.getElementById( 'ec_a
2116pply_gift_card_mobile' ) ).hide(); 2117 } else { 2118 jQuery( document.getElementById( 'ec_applying_gift_card' ) ).show( ); 2119 } 2120 2121 var gift_card = ( is_mobile ) ? jQuery( document.getElementById( 'ec_gift_card_mobile' ) ).val() : jQuery( document.getElementById( 'ec_gift_card' ) ).val(); 2122 if ( is_mobile ) { 2123 jQuery( document.getElementById( 'ec_gift_card' ) ).val( gift_card ); 2124 } else { 2125 if ( jQuery( document.getElementById( 'ec_gift_card_mobile' ) ).length ) { 2126 jQuery( document.getElementById( 'ec_gift_card_mobile' ) ).val( gift_card ); 2127 } 2128 } 2129 2130 var data = { 2131 action: 'ec_ajax_redeem_gift_card', 2132 ec_v3_24: 'true', 2133 giftcard: gift_card, 2134 nonce: nonce 2135 }; 2136 2137 jQuery.ajax( { 2138 url: wpeasycart_ajax_object.ajax_url, 2139 type: 'post', 2140 data: data, 2141 cache: false, 2142 success: function( data ){ 2143 jQuery( document.getElementById( 'ec_apply_gift_card' ) ).show( ); 2144 if ( jQuery( '#ec_applying_gift_card_v2' ).length ) { 2145 jQuery( '#ec_applying_gift_card_v2' ).removeClass( 'ec_cart_button_working_active' ); 2146 jQuery( '#ec_applying_gift_card_v2_mobile' ).removeClass( 'ec_cart_button_working_active' ); 2147 jQuery( document.getElementById( 'ec_apply_gift_card_mobile' ) ).show( ); 2148 } else { 2149 jQuery( document.getElementById( 'ec_applying_gift_card' ) ).hide( ); 2150 } 2151 2152 // Get Response Data 2153 var response_obj = JSON.parse( data ); 2154 2155 // Update Cart 2156 ec_update_cart( response_obj ); 2157 2158 // Update Gift Card Info 2159 if( response_obj.is_giftcard_valid ){ 2160 jQuery( document.getElementById( 'ec_gift_card_error' ) ).hide( ); 2161 jQuery( document.getElementById( 'ec_gift_card_success' ) ).html( response_obj.giftcard_message ).show( ); 2162 if ( jQuery( '#ec_applying_gift_card_v2' ).length ) { 2163 jQuery( document.getElementById( 'ec_gift_card_error_mobile' ) ).hide( ); 2164 jQuery( document.getElementById( 'ec_gift_card_success_mobile' ) ).html( response_obj.giftcard_message ).show( ); 2165 } 2166 }else{ 2167 jQuery( document.getElementById( 'ec_gift_card_success' ) ).hide( ); 2168 jQuery( document.getElementById( 'ec_gift_card_error' ) ).html( response_obj.giftcard_message ).show( ); 2169 if ( jQuery( '#ec_applying_gift_card_v2' ).length ) { 2170 jQuery( document.getElementById( 'ec_gift_card_success_mobile' ) ).hide( ); 2171 jQuery( document.getElementById( 'ec_gift_card_error_mobile' ) ).html( response_obj.giftcard_message ).show( ); 2172 } 2173 } 2174 } 2175 } ); 2176} 2177 2178function ec_estimate_shipping( nonce ){ 2179 2180 jQuery( document.getElementById( 'ec_estimate_shipping' ) ).hide( ); 2181 jQuery( document.getElementById( 'ec_estimating_shipping' ) ).show( ); 2182 2183 var data = { 2184 action: 'ec_ajax_estimate_shipping', 2185 ec_v3_24: 'true', 2186 zipcode: jQuery( document.getElementById( 'ec_estimate_zip' ) ).val( ), 2187 country: jQuery( document.getElementById( 'ec_estimate_country' ) ).val( ), 2188 nonce: nonce 2189 }; 2190 2191 jQuery.ajax({ 2192 url: wpeasycart_ajax_object.ajax_url, 2193 type: 'post', 2194 data: data, 2195 cache: false, 2196 success: function( data ){ 2197 jQuery( document.getElementById( 'ec_estimate_shipping' ) ).show( ); 2198 jQuery( document.getElementById( 'ec_estimating_shipping' ) ).hide( ); 2199 2200 // Get Response Data 2201 var response_obj = JSON.parse( data ); 2202 2203 // Update Cart 2204 ec_update_cart( response_obj ); 2205 2206 // Show the Shipping Row if Hidden 2207 jQuery( document.getElementById( 'ec_cart_shipping_row' ) ).show( ); 2208 } 2209 } ); 2210} 2211 2212function ec_update_cart( response_obj ){ 2213 2214 if( response_obj.cart.length == 0 ){ 2215 ec_reload_cart( ); 2216 2217 }else{ 2218 // Update Cart Data 2219 for( var i=0; i<response_obj.cart.length; i++ ){ 2220 jQuery( document.getElementById( 'ec_cartitem_details_' + response_obj.cart[i].id ) ).find( '.ec_details_price_promo_discount' ).remove(); 2221 jQuery( document.getElementById( 'ec_cartitem_details_' + response_obj.cart[i].id ) ).find( '.ec_details_price_coupon_discount' ).remove(); 2222 if ( '' != response_obj.cart[i].promo_message ) { 2223 jQuery( document.getElementById( 'ec_cartitem_details_' + response_obj.cart[i].id ) ).append( response_obj.cart[i].promo_message ); 2224 } 2225 jQuery( document.getElementById( 'ec_quantity_' + response_obj.cart[i].id ) ).val( response_obj.cart[i].quantity ); 2226 jQuery( document.getElementById( 'ec_cartitem_price_' + response_obj.cart[i].id ) ).html( response_obj.cart[i].unit_price ); 2227 jQuery( document.getElementById( 'ec_cartitem_total_' + response_obj.cart[i].id ) ).html( response_obj.cart[i].total_price ); 2228 2229 jQuery( '.ec_cartitem_' + response_obj.cart[i].id + ' > .ec_cart_price_row_total_v2' ).html( response_obj.cart[i].total_price ); 2230 2231 if( response_obj.cart[i].allow_backorders == "1" && response_obj.cart[i].use_optionitem_quantity_tracking == "1" && Number( response_obj.cart[i].quantity ) > Number( response_obj.cart[i].optionitem_stock_quantity ) ){ 2232 jQuery( document.getElementById( 'ec_cartitem_backorder_' + response_obj.cart[i].id ) ).show( ); 2233 2234 }else if( response_obj.cart[i].allow_backorders == "1" && response_obj.cart[i].use_optionitem_quantity_tracking == "1" && Number( response_obj.cart[i].quantity ) <= Number( response_obj.cart[i].optionitem_stock_quantity ) ){ 2235 jQuery( document.getElementById( 'ec_cartitem_backorder_' + response_obj.cart[i].id ) ).hide( ); 2236 2237 }else if( response_obj.cart[i].allow_backorders == "1" && response_obj.cart[i].use_optionitem_quantity_tracking == "0" && Number( response_obj.cart[i].quantity ) > Number( response_obj.cart[i].stock_quantity ) ){ 2238 jQuery( document.getElementById( 'ec_cartitem_backorder_' + response_obj.cart[i].id ) ).show( ); 2239 2240 }else if( response_obj.cart[i].allow_backorders == "1" && response_obj.cart[i].use_optionitem_quantity_tracking == "0" && Number( response_obj.cart[i].quantity ) <= Number( response_obj.cart[i].stock_quantity ) ){ 2241 jQuery( document.getElementById( 'ec_cartitem_backorder_' + response_obj.cart[i].id ) ).hide( ); 2242 2243 } 2244 if ( jQuery( document.getElementById( 'ec_cartitem_shipping_restriction_' + response_obj.cart[i].id ) ).length && '1' == response_obj.cart[i].shipping_restricted ) { 2245 jQuery( document.getElementById( 'ec_cartitem_shipping_restriction_' + response_obj.cart[i].id ) ).show( ); 2246 } else if ( jQuery( document.getElementById( 'ec_cartitem_shipping_restriction_' + response_obj.cart[i].id ) ).length ) { 2247 jQuery( document.getElementById( 'ec_cartitem_shipping_restriction_' + response_obj.cart[i].id ) ).hide( ); 2248 } 2249 } 2250 2251 // Update Cart Totals 2252 jQuery( document.getElementById( 'ec_cart_subtotal' ) ).html( response_obj.order_totals.sub_total ); 2253 if ( jQuery( '.paylater_message_v2' ).length ) { 2254 if ( Number( jQuery( '.paylater_message_v2' ).attr( 'data-min-price' ) ) <= Number( response_obj.order_totals.sub_total_amt ) ) { 2255 jQuery( '.paylater_message_v2' ).hide(); 2256 } else { 2257 jQuery( '.paylater_message_v2' ).show(); 2258 } 2259 } 2260 if ( jQuery( '#wpec-payment-method-messaging-element' ).length ) { 2261 ec_cart_stripe_paylater_messaging_v2( Math.round( response_obj.order_totals.sub_total_amt * 100 ) ); 2262 if ( Number( jQuery( '.paylater_message_v2' ).attr( 'data-min-price' ) ) <= Number( response_obj.order_totals.sub_total_amt ) ) { 2263 jQuery( '#wpec-payment-method-messaging-element' ).show(); 2264 } else { 2265 jQuery( '#wpec-payment-method-messaging-element' ).hide(); 2266 } 2267 } 2268 if ( jQuery( '.ec_cart_table_subtotal_amount' ).length ) { 2269 jQuery( '.ec_cart_table_subtotal_amount' ).html( response_obj.order_totals.sub_total ); 2270 } 2271 jQuery( document.getElementById( 'ec_cart_tax' ) ).html( response_obj.order_totals.tax_total ); 2272 if( response_obj.order_totals.has_tax == '1' ){ 2273 jQuery( document.getElementById( 'ec_cart_tax' ) ).parent( ).show( ); 2274 }else{ 2275 jQuery( document.getElementById( 'ec_cart_tax' ) ).parent( ).hide( ); 2276 } 2277 jQuery( document.getElementById( 'ec_cart_shipping' ) ).html( response_obj.order_totals.shipping_total ); 2278 jQuery( document.getElementById( 'ec_cart_duty' ) ).html( response_obj.order_totals.duty_total ); 2279 if( response_obj.order_totals.has_duty == '1' ){ 2280 jQuery( document.getElementById( 'ec_cart_duty' ) ).parent( ).show( ); 2281 }else{ 2282 jQuery( document.getElementById( 'ec_cart_duty' ) ).parent( ).hide( ); 2283 } 2284 jQuery( document.getElementById( 'ec_cart_vat' ) ).html( response_obj.order_totals.vat_total ); 2285 if( response_obj.order_totals.has_vat == '1' ){ 2286 jQuery( document.getElementById( 'ec_cart_vat' ) ).parent( ).show( ); 2287 }else{ 2288 jQuery( document.getElementById( 'ec_cart_vat' ) ).parent( ).hide( ); 2289 } 2290 if( jQuery( document.getElementById( 'ec_cart_vat_rate' ) ).length ){ 2291 jQuery( document.getElementById( 'ec_cart_vat_rate' ) ).html( response_obj.order_totals.vat_rate_formatted ); 2292 } 2293 jQuery( document.getElementById( 'ec_cart_gst' ) ).html( response_obj.order_totals.gst_total ); 2294 if( response_obj.order_totals.has_gst == '1' ){ 2295 jQuery( document.getElementById( 'ec_cart_gst' ) ).parent( ).show( ); 2296 }else{ 2297 jQuery( document.getElementById( 'ec_cart_gst' ) ).parent( ).hide( ); 2298 } 2299 jQuery( document.getElementById( 'ec_cart_hst' ) ).html( response_obj.order_totals.hst_total ); 2300 if( response_obj.order_totals.has_hst == '1' ){ 2301 jQuery( document.getElementById( 'ec_cart_hst' ) ).parent( ).show( ); 2302 }else{ 2303 jQuery( document.getElementById( 'ec_cart_hst' ) ).parent( ).hide( ); 2304 } 2305 jQuery( document.getElementById( 'ec_cart_pst' ) ).html( response_obj.order_totals.pst_total ); 2306 if( response_obj.order_totals.has_pst == '1' ){ 2307 jQuery( document.getElementById( 'ec_cart_pst' ) ).parent( ).show( ); 2308 }else{ 2309 jQuery( document.getElementById( 'ec_cart_pst' ) ).parent( ).hide( ); 2310 } 2311 if( jQuery( document.getElementById( 'ec_cart_tip' ) ).length ){ 2312 jQuery( document.getElementById( 'ec_cart_tip' ) ).html( response_obj.order_totals.tip_total ); 2313 } 2314 if ( response_obj.order_totals.fees ) { 2315 jQuery( '.ec_cart_price_row_fee' ).remove(); 2316 var fee_html = ''; 2317 for ( var j=0; j < response_obj.order_totals.fees.length; j++ ) { 2318 fee_html += '<div class="ec_cart_price_row ec_cart_price_row_fee"><div class="ec_cart_price_row_label">' + response_obj.order_totals.fees[j].fee_label + '</div><div class="ec_cart_price_row_total" id="ec_cart_fee_' + response_obj.order_totals.fees[j].fee_id + '">' + response_obj.order_totals.fees[j].fee_total + '</div></div>'; 2319 }
2320 if ( '' != fee_html ) { 2321 jQuery( fee_html ).insertBefore( '.ec_cart_price_row.ec_order_total' ); 2322 } 2323 } 2324 jQuery( document.getElementById( 'ec_cart_discount' ) ).html( response_obj.order_totals.discount_total ); 2325 jQuery( '.ec_cart_promotions_list.ec_cart_promotions_discount' ).remove(); 2326 if ( '' != response_obj.order_totals.discount_message ) { 2327 jQuery( '.ec_cart_price_row_discount_total > .ec_cart_price_row_label' ).append( response_obj.order_totals.discount_message ); 2328 } 2329 jQuery( '.ec_cart_promotions_list.ec_cart_shipping_discount' ).remove(); 2330 if ( '' != response_obj.order_totals.shipping_discount_message ) { 2331 jQuery( '.ec_cart_price_row_shipping_total > .ec_cart_price_row_label' ).append( response_obj.order_totals.shipping_discount_message ); 2332 } 2333 jQuery( document.getElementById( 'ec_cart_total' ) ).html( response_obj.order_totals.grand_total ); 2334 2335 if ( jQuery( '.wp-easycart-widget-cart-quantity' ).length ) { 2336 jQuery( '.wp-easycart-widget-cart-quantity' ).html( response_obj.items_total ); 2337 } 2338 2339 jQuery( ".ec_cart_items_total" ).html( response_obj.items_total ); 2340 jQuery( ".ec_cart_price_total" ).html( response_obj.order_totals.grand_total ); 2341 2342 // Hide/Show Discount 2343 if( response_obj.has_discount == '1' ){ 2344 jQuery( '.ec_no_discount' ).show( ); 2345 jQuery( '.ec_has_discount' ).show( ); 2346 }else{ 2347 jQuery( '.ec_no_discount' ).hide( ); 2348 jQuery( '.ec_has_discount' ).hide( ); 2349 } 2350 2351 // Hide/Show Backorder 2352 if( response_obj.has_backorder ){ 2353 jQuery( document.getElementById( 'ec_cart_backorder_message' ) ).show( ); 2354 }else{ 2355 jQuery( document.getElementById( 'ec_cart_backorder_message' ) ).hide( ); 2356 } 2357 2358 // Hide/Show Minimum 2359 if( jQuery( '.ec_minimum_purchase_box' ).length ){ 2360 if( Number( response_obj.order_totals.sub_total_amt ) < Number( jQuery( '.ec_minimum_purchase_box' ).attr( 'data-min-cart' ) ) ){ 2361 jQuery( '.ec_minimum_purchase_box' ).show( ); 2362 if( jQuery( document.getElementById( 'sq-walletbox' ) ).length ){ 2363 jQuery( document.getElementById( 'sq-walletbox' ) ).hide( ); 2364 } 2365 }else{ 2366 jQuery( '.ec_minimum_purchase_box' ).hide( ); 2367 if( jQuery( document.getElementById( 'sq-walletbox' ) ).length ){ 2368 jQuery( document.getElementById( 'sq-walletbox' ) ).show( ); 2369 } 2370 } 2371 } 2372 2373 // Stripe Update Wallet 2374 if( jQuery( document.getElementById( 'ec-stripe-wallet-button' ) ).length && ! jQuery( document.getElementById( 'ec_cart_onepage_cart' ) ).length ){ 2375 jQuery( document.getElementById( 'ec-stripe-wallet-button' ) ).replaceWith( response_obj.stripe_wallet ); 2376 } 2377 2378 // PayPal Express Update 2379 if( response_obj.paypal_express_button ){ 2380 jQuery( document.getElementById( 'paypal-button-container' ) ).find( '.paypal-button' ).remove( ); 2381 jQuery( document.getElementById( 'paypal-button-container' ) ).append( response_obj.paypal_express_button ); 2382 } 2383 2384 if ( jQuery( '#ec_cart_onepage_payment' ).length ) { 2385 var header_html = jQuery( document.getElementById( 'ec_cart_onepage_payment' ) ).find( '.ec_cart_header' ); 2386 if ( jQuery( '#ec_cart_onepage_payment' ).length && jQuery( '.ec_cart_payment_table' ).length && response_obj.order_totals.grand_total_amt <= 0 ) { 2387 if ( jQuery( '.ec_cart_payment_table' ).length ) { 2388 jQuery( '.ec_cart_payment_table' ).remove(); 2389 } 2390 jQuery( document.getElementById( 'ec_cart_onepage_payment' ) ).html( '<div id="ec_cart_shipping_loader"><div class="ec_cart_shipping_animate_pulse"><div class="ec_cart_shipping_rounded_loader"></div><div class="ec_cart_shipping_animate_line_container"><div class="ec_cart_shipping_animate_line_top"></div><div class="ec_cart_shipping_animate_line_bottom"></div></div></div><div class="ec_cart_shipping_animate_pulse"><div class="ec_cart_shipping_rounded_loader"></div><div class="ec_cart_shipping_animate_line_container"><div class="ec_cart_shipping_animate_line_top"></div><div class="ec_cart_shipping_animate_line_bottom"></div></div></div></div>' ).prepend( header_html ); 2391 ec_reload_cart(); 2392 } else if ( jQuery( '#ec_cart_onepage_payment' ).length && ! jQuery( '.ec_cart_payment_table' ).length && response_obj.order_totals.grand_total_amt > 0 ) { 2393 jQuery( document.getElementById( 'ec_cart_onepage_payment' ) ).html( '<div id="ec_cart_shipping_loader"><div class="ec_cart_shipping_animate_pulse"><div class="ec_cart_shipping_rounded_loader"></div><div class="ec_cart_shipping_animate_line_container"><div class="ec_cart_shipping_animate_line_top"></div><div class="ec_cart_shipping_animate_line_bottom"></div></div></div><div class="ec_cart_shipping_animate_pulse"><div class="ec_cart_shipping_rounded_loader"></div><div class="ec_cart_shipping_animate_line_container"><div class="ec_cart_shipping_animate_line_top"></div><div class="ec_cart_shipping_animate_line_bottom"></div></div></div></div>' ).prepend( header_html ); 2394 ec_reload_cart(); 2395 } 2396 } 2397 } 2398} 2399 2400function ec_reload_cart( ){ 2401 location.reload( ); 2402} 2403 2404function ec_open_login_click( ){ 2405 jQuery( document.getElementById( 'ec_alt_login' ) ).slideToggle(300); 2406 2407 return false; 2408} 2409 2410function ec_update_shipping_view( ){ 2411 if( jQuery( document.getElementById( 'ec_shipping_selector' ) ).is( ':checked' ) ){ 2412 jQuery( document.getElementById( 'ec_shipping_form' ) ).show( ); 2413 }else{ 2414 jQuery( document.getElementById( 'ec_shipping_form' ) ).hide( ); 2415 } 2416} 2417 2418function ec_cart_toggle_login( ){
2419 if( jQuery( document.getElementById( 'ec_login_selector' ) ).is( ':checked' ) ){ 2420 jQuery( document.getElementById( 'ec_user_login_form' ) ).show( ); 2421 }else{ 2422 jQuery( document.getElementById( 'ec_user_login_form' ) ).hide( ); 2423 } 2424} 2425 2426function ec_cart_toggle_login_v2() { 2427 if ( jQuery( document.getElementById( 'ec_user_login_form' ) ).is( ':visible' ) ) { 2428 jQuery( document.getElementById( 'ec_user_login_form' ) ).hide( ); 2429 jQuery( document.getElementById( 'ec_user_contact_form' ) ).show( ); 2430 jQuery( document.getElementById( 'ec_user_login_link' ) ).show( ); 2431 jQuery( document.getElementById( 'ec_user_login_cancel_link' ) ).hide( ); 2432 jQuery( document.getElementById( 'ec_login_selector' ) ).prop( 'checked', false ); 2433 if ( jQuery( document.getElementById( 'ec_user_create_form' ) ).length ) { 2434 jQuery( document.getElementById( 'ec_user_create_form' ) ).show(); 2435 } 2436 jQuery( '#ec_cart_onepage_info > div.ec_cart_input_row, #ec_cart_onepage_info > .ec_cart_header' ).show( ); 2437 jQuery( document.getElementById( 'ec_cart_onepage_shipping' ) ).show( ); 2438 jQuery( document.getElementById( 'ec_cart_onepage_payment' ) ).show( ); 2439 if ( jQuery( document.getElementById( 'shipping-address-element' ) ).length ) { 2440 jQuery( document.getElementById( 'shipping-address-element' ) ).show(); 2441 } 2442 } else { 2443 jQuery( document.getElementById( 'ec_user_login_form' ) ).show( ); 2444 jQuery( document.getElementById( 'ec_user_contact_form' ) ).hide( ); 2445 jQuery( document.getElementById( 'ec_user_login_link' ) ).hide( ); 2446 jQuery( document.getElementById( 'ec_user_login_cancel_link' ) ).show( ); 2447 jQuery( document.getElementById( 'ec_login_selector' ) ).prop( 'checked', true ); 2448 if ( jQuery( document.getElementById( 'ec_user_create_form' ) ).length ) { 2449 jQuery( document.getElementById( 'ec_user_create_form' ) ).hide(); 2450 } 2451 jQuery( '#ec_cart_onepage_info > div.ec_cart_input_row, #ec_cart_onepage_info > .ec_cart_header' ).hide( ); 2452 jQuery( '#ec_cart_contact_header' ).show( ); 2453 jQuery( document.getElementById( 'ec_cart_onepage_shipping' ) ).hide( ); 2454 jQuery( document.getElementById( 'ec_cart_onepage_payment' ) ).hide( ); 2455 if ( jQuery( document.getElementById( 'shipping-address-element' ) ).length ) { 2456 jQuery( document.getElementById( 'shipping-address-element' ) ).hide(); 2457 } 2458 } 2459 return false; 2460} 2461 2462function ec_cart_validate_login_v2( nonce ) { 2463 var recaptcha_complete = true; 2464 var recaptcha_response = ''; 2465 if ( document.getElementById( 'ec_account_login_recaptcha' ) ) { 2466 recaptcha_response = jQuery( document.getElementById( 'ec_grecaptcha_response_login' ) ).val(); 2467 if ( ! recaptcha_response.length ) { 2468 jQuery( '#ec_account_login_recaptcha > div' ).css( 'border', '1px solid red' ); 2469 recaptcha_complete = false; 2470 } else { 2471 jQuery( '#ec_account_login_recaptcha > div' ).css( 'border', 'none' ); 2472 } 2473 } 2474 if ( ec_validate_cart_login() && recaptcha_complete ) { 2475 jQuery( document.getElementById( 'ec_user_login_form' ) ).append( '<div id="ec_cart_login_form_loader"><style>@keyframes rotation{0% { transform:rotate(0deg); }100%{ transform:rotate(359deg); }}</style><div style=\'font-family: "HelveticaNeue", "HelveticaNeue-Light", "Helvetica Neue Light", helvetica, arial, sans-serif; font-size: 14px; text-align: center; -webkit-box-sizing: border-box; -moz-box-sizing: border-box; -ms-box-sizing: border-box; box-sizing: border-box; width: 350px; top: 50%; left: 50%; position: absolute; margin-left: -165px; margin-top: -80px; cursor: pointer; text-align: center;\'><div><div style="height: 30px; width: 30px; display: inline-block; box-sizing: content-box; opacity: 1; filter: alpha(opacity=100); -webkit-animation: rotation .7s infinite linear; -moz-animation: rotation .7s infinite linear; -o-animation: rotation .7s infinite linear; animation: rotation .7s infinite linear; border-left: 8px solid rgba(0, 0, 0, .2); border-right: 8px solid rgba(0, 0, 0, .2); border-bottom: 8px solid rgba(0, 0, 0, .2); border-top: 8px solid #fff; border-radius: 100%;"></div></div></div></div>' ); 2476 var data = { 2477 action: 'ec_ajax_cart_login_v2', 2478 ec_cart_login_email: jQuery( document.getElementById( 'ec_cart_login_email' ) ).val(), 2479 ec_cart_login_password: jQuery( document.getElementById( 'ec_cart_login_password' ) ).val(), 2480 ec_grecaptcha_response_login: recaptcha_response, 2481 wpeasycart_nonce: nonce 2482 }; 2483 jQuery.ajax( { 2484 url: wpeasycart_ajax_object.ajax_url, 2485 type: 'post', 2486 data: data, 2487 cache: false, 2488 success: function( data ) { 2489 var response_obj = JSON.parse( data );
2490 jQuery( document.getElementById( 'ec_cart_login_invalid_error' ) ).hide(); 2491 jQuery( document.getElementById( 'ec_cart_not_activated_error' ) ).hide(); 2492 if ( response_obj.error ) { 2493 jQuery( document.getElementById( 'ec_cart_login_form_loader' ) ).remove(); 2494 if ( 'not_activated' == response_obj ) { 2495 jQuery( document.getElementById( 'ec_cart_not_activated_error' ) ).show(); 2496 } else { 2497 jQuery( document.getElementById( 'ec_cart_login_invalid_error' ) ).show(); 2498 } 2499 if ( '' != recaptcha_response ) { 2500 jQuery( document.getElementById( 'ec_grecaptcha_response_login' ) ).val( '' ); 2501 grecaptcha.reset( wpeasycart_login_recaptcha ); 2502 } 2503 } else { 2504 window.location.href = response_obj.url; 2505 } 2506 } 2507 } ); 2508 return false; 2509 } else { 2510 return false; 2511 } 2512} 2513 2514function ec_cart_stripe_paylater_messaging_v2( sub_total ) { 2515 if ( jQuery( '#wpec-payment-method-messaging-element' ).length ) { 2516 const appearance = { 2517 theme: jQuery( '#wpec-payment-method-messaging-element' ).attr( 'data-theme' ), 2518 }; 2519 const elements = stripe.elements( appearance ); 2520 const options = { 2521 amount: sub_total, 2522 currency: jQuery( '#wpec-payment-method-messaging-element' ).attr( 'data-currency' ), 2523 paymentMethodTypes: jQuery( '#wpec-payment-method-messaging-element' ).attr( 'data-types' ).split( ',' ), 2524 countryCode: jQuery( '#wpec-payment-method-messaging-element' ).attr( 'data-country' ), 2525 }; 2526 const PaymentMessageElement = 2527 elements.create( 'paymentMethodMessaging', options ); 2528 PaymentMessageElement.mount( '#wpec-payment-method-messaging-element' ); 2529 } 2530} 2531 2532function ec_cart_logout_v2() { 2533 jQuery( document.getElementById( 'ec_cart_logged_in_section' ) ).append( '<style>@keyframes rotation{0% { transform:rotate(0deg); }100%{ transform:rotate(359deg); }}</style><div style=\'font-family: "HelveticaNeue", "HelveticaNeue-Light", "Helvetica Neue Light", helvetica, arial, sans-serif; font-size: 14px; text-align: center; -webkit-box-sizing: border-box; -moz-box-sizing: border-box; -ms-box-sizing: border-box; box-sizing: border-box; width: 350px; top: 50%; left: 50%; position: absolute; margin-left: -165px; margin-top: -80px; cursor: pointer; text-align: center;\'><div><div style="height: 30px; width: 30px; display: inline-block; box-sizing: content-box; opacity: 1; filter: alpha(opacity=100); -webkit-animation: rotation .7s infinite linear; -moz-animation: rotation .7s infinite linear; -o-animation: rotation .7s infinite linear; animation: rotation .7s infinite linear; border-left: 8px solid rgba(0, 0, 0, .2); border-right: 8px solid rgba(0, 0, 0, .2); border-bottom: 8px solid rgba(0, 0, 0, .2); border-top: 8px solid #fff; border-radius: 100%;"></div></div></div>' ); 2534} 2535 2536function ec_cart_toggle_address_edit( ) { 2537 if ( jQuery( document.getElementById( 'ec_cart_billing_form' ) ).is( ':visible' ) ) { 2538 jQuery( document.getElementById( 'ec_cart_billing_form' ) ).hide(); 2539 jQuery( document.getElementById( 'ec_cart_billing_locked' ) ).show(); 2540 if ( jQuery( document.getElementById( 'ec_cart_shipping_locked' ) ).length ) { 2541 jQuery( document.getElementById( 'ec_cart_shipping_locked' ) ).show(); 2542 } 2543 jQuery( document.getElementById( 'ec_cart_subscription_end_form' ) ).show(); 2544 } else { 2545 jQuery( document.getElementById( 'ec_cart_billing_form' ) ).show(); 2546 jQuery( document.getElementById( 'ec_cart_billing_locked' ) ).hide(); 2547 if ( jQuery( document.getElementById( 'ec_cart_shipping_locked' ) ).length ) { 2548 jQuery( document.getElementById( 'ec_cart_shipping_locked' ) ).hide(); 2549 } 2550 jQuery( document.getElementById( 'ec_cart_subscription_end_form' ) ).hide(); 2551 } 2552} 2553 2554function wp_easycart_update_contact_email_v2() { 2555 var data = { 2556 action: 'ec_ajax_update_contact_email', 2557 ec_create_account: ( ( jQuery( document.getElementById( 'ec_user_create_form' ) ).length ) ? 1 : 0 ), 2558 ec_contact_email: jQuery( document.getElementById( 'ec_contact_email' ) ).val(), 2559 wpeasycart_checkout_nonce: jQuery( document.getElementById( 'wpeasycart_checkout_nonce' ) ).val() 2560 }; 2561 jQuery.ajax( { 2562 url: wpeasycart_ajax_object.ajax_url, 2563 type: 'post', 2564 data: data, 2565 cache: false, 2566 success: function( data ) { 2567 var response_obj = JSON.parse( data ); 2568 if ( response_obj.error && 'user_create_error' == response_obj.error && jQuery( document.getElementById( 'ec_user_create_form' ) ).length ) { 2569 jQuery( document.getElementById( 'ec_create_account_email_error' ) ).show(); 2570 } else { 2571 jQuery( document.getElementById( 'ec_create_account_email_error' ) ).hide(); 2572 } 2573 if ( response_obj.coupon_message ) { 2574 jQuery( document.getElementById( 'ec_coupon_success' ) ).hide( ); 2575 jQuery( document.getElementById( 'ec_coupon_error' ) ).html( response_obj.coupon_message ).show( ); 2576 if ( jQuery( '#ec_applying_coupon_v2' ).length ) { 2577 jQuery( document.getElementById( 'ec_coupon_success_mobile' ) ).hide( ); 2578 jQuery( document.getElementById( 'ec_coupon_error_mobile' ) ).html( response_obj.coupon_message ).show( ); 2579 } 2580 if ( jQuery( document.getElementById( 'ec_coupon_code_mobile' ) ).length ) { 2581 jQuery( document.getElementById( 'ec_coupon_code_mobile' ) ).val( '' ); 2582 } 2583 if ( jQuery( document.getElementById( 'ec_coupon_code' ) ).length ) { 2584 jQuery( document.getElementById( 'ec_coupon_code' ) ).val( '' ); 2585 } 2586 } 2587 ec_update_cart( response_obj.cart_data ); 2588 }, 2589 } ); 2590} 2591 2592function wp_easycart_goto_page_v2( page, nonce, add_state = true ) { 2593 if ( 'shipping' == page && jQuery( '#wpeasycart_shipping_page_link' ).hasClass( 'wpeasycart-deactivated-link' ) ) { 2594 return false; 2595 } 2596 if ( 'payment' == page && jQuery( '#wpeasycart_payment_page_link' ).hasClass( 'wpeasycart-deactivated-link' ) ) { 2597 return false; 2598 } 2599 2600 var valid_pages = [ 'cart', 'information', 'shipping', 'payment' ]; 2601 if ( ! valid_pages.includes( page ) ) { 2602 page = 'information'; 2603 } 2604 jQuery( '.ec_cart_left' ).append( '<div id="ec_cart_goto_page_loader"><style>@keyframes rotation{0% { transform:rotate(0deg); }100%{ transform:rotate(359deg); }}</style><div style=\'font-family: "HelveticaNeue", "HelveticaNeue-Light", "Helvetica Neue Light", helvetica, arial, sans-serif; font-size: 14px; text-align: center; -webkit-box-sizing: border-box; -moz-box-sizing: border-box; -ms-box-sizing: border-box; box-sizing: border-box; width: 350px; top: 50%; left: 50%; position: absolute; margin-left: -165px; margin-top: -80px; cursor: pointer; text-align: center;\'><div><div style="height: 30px; width: 30px; display: inline-block; box-sizing: content-box; opacity: 1; filter: alpha(opacity=100); -webkit-animation: rotation .7s infinite linear; -moz-animation: rotation .7s infinite linear; -o-animation: rotation .7s infinite linear; animation: rotation .7s infinite linear; border-left: 8px solid rgba(0, 0, 0, .2); border-right: 8px solid rgba(0, 0, 0, .2); border-bottom: 8px solid rgba(0, 0, 0, .2); border-top: 8px solid #fff; border-radius: 100%;"></div></div></div></div>' ); 2605 2606 if ( add_state ) { 2607 wp_easycart_goto_push_state( page ); 2608 } 2609 2610 var data = { 2611 action: 'ec_ajax_goto_page_v2', 2612 page: page, 2613 wpeasycart_checkout_nonce: nonce, 2614 }; 2615 jQuery.ajax( { 2616 url: wpeasycart_ajax_object.ajax_url, 2617 type: 'post', 2618 data: data, 2619 cache: false, 2620 success: function( data ) { 2621 var response_obj = JSON.parse( data ); 2622 ec_update_cart( response_obj.cart_data ); 2623 if ( jQuery( document.getElementById( 'ec_cart_onepage_cart' ) ).length ) { 2624 jQuery( document.getElementById( 'ec_cart_goto_page_loader' ) ).remove(); 2625 if ( 'cart' == page ) { 2626 jQuery( '.ec_cart_left' ).addClass( 'ec_cart_full' ); 2627 jQuery( '.ec_cart_right' ).hide(); 2628 if ( jQuery( document.getElementById( 'ec_cart_onepage_cart' ) ).length ) { 2629 jQuery( document.getElementById( 'ec_cart_onepage_cart' ) ).show(); 2630 jQuery( document.getElementById( 'ec_cart_onepage_cart' ) ).html( response_obj.html_content ); 2631 } 2632 if ( jQuery( document.getElementById( 'ec_cart_onepage_info' ) ).length ) { 2633 jQuery( document.getElementById( 'ec_cart_onepage_info' ) ).hide(); 2634 } 2635 if ( jQuery( document.getElementById( 'ec_cart_onepage_shipping' ) ).length ) { 2636 jQuery( document.getElementById( 'ec_cart_onepage_shipping' ) ).hide(); 2637 } 2638 if ( jQuery( document.getElementById( 'ec_cart_onepage_payment' ) ).length ) { 2639 jQuery( document.getElementById( 'ec_cart_onepage_payment' ) ).hide(); 2640 } 2641 } else { 2642 jQuery( '.ec_cart_left' ).removeClass( 'ec_cart_full' ); 2643 jQuery( '.ec_cart_right' ).show(); 2644 if ( jQuery( document.getElementById( 'ec_cart_onepage_cart' ) ).length ) { 2645 jQuery( document.getElementById( 'ec_cart_onepage_cart' ) ).remove(); 2646 } 2647 if ( jQuery( document.getElementById( 'ec_cart_onepage_info' ) ).length ) { 2648 jQuery( document.getElementById( 'ec_cart_onepage_info' ) ).remove(); 2649 } 2650 if ( jQuery( document.getElementById( 'ec_cart_onepage_shipping' ) ).length ) { 2651 jQuery( document.getElementById( 'ec_cart_onepage_shipping' ) ).remove(); 2652 } 2653 if ( jQuery( document.getElementById( 'ec_cart_onepage_payment' ) ).length ) { 2654 jQuery( document.getElementById( 'ec_cart_onepage_payment' ) ).remove(); 2655 } 2656 jQuery( document.getElementById( 'wpeasycart_checkout_details_form' ) ).append( response_obj.html_content ); 2657 } 2658 } else { 2659 jQuery( '.ec_cart_left' ).html( response_obj.html_content ); 2660 if ( 'cart' == page ) { 2661 jQuery( '.ec_cart_left' ).addClass( 'ec_cart_full' ); 2662 jQuery( '.ec_cart_right' ).hide(); 2663 } else { 2664 jQuery( '.ec_cart_left' ).removeClass( 'ec_cart_full' ); 2665 jQuery( '.ec_cart_right' ).show(); 2666 } 2667 if ( '1' == response_obj.shipping_allowed ) { 2668 jQuery( '#wpeasycart_shipping_page_link' ).removeClass( 'wpeasycart-deactivated-link' ); 2669 } 2670 if ( '1' == response_obj.payment_allowed ) { 2671 jQuery( '#wpeasycart_payment_page_link' ).removeClass( 'wpeasycart-deactivated-link' ); 2672 } 2673 } 2674 } 2675 } ); 2676 return false; 2677} 2678 2679function wp_easycart_goto_push_state( page ) { 2680 var url = window.location.href; 2681 var var_key = 'eccheckout'; 2682 var re = new RegExp( "([?&])" + var_key + "=.*?(&|$)", "i"); 2683 var separator = url.indexOf( '?' ) !== -1 ? '&' : '?'; 2684 if ( url.match( re ) ) { 2685 url = url.replace( re, '$1' + var_key + "=" + page + '$2'); 2686 } else { 2687 url = url + separator + var_key + "=" + page; 2688 } 2689 window.history.pushState( { eccheckout: page }, document.title, url ); 2690} 2691 2692function wp_easycart_save_order_notes_v2() { 2693 var data = { 2694 action: 'ec_ajax_update_order_notes', 2695 ec_order_notes: jQuery( document.getElementById( 'ec_order_notes' ) ).val(), 2696 wpeasycart_checkout_nonce: jQuery( document.getElementById( 'wpeasycart_checkout_nonce' ) ).val() 2697 }; 2698 jQuery.ajax( { 2699 url: wpeasycart_ajax_object.ajax_url, 2700 type: 'post', 2701 data: data, 2702 cache: false 2703 } ); 2704} 2705 2706function wp_easycart_save_email_other_v2() { 2707 var data = { 2708 action: 'ec_ajax_update_email_other', 2709 ec_email_other: jQuery( document.getElementById( 'ec_email_other' ) ).val(), 2710 wpeasycart_checkout_nonce: jQuery( document.getElementById( 'wpeasycart_checkout_nonce' ) ).val() 2711 }; 2712 jQuery.ajax( { 2713 url: wpeasycart_ajax_object.ajax_url, 2714 type: 'post', 2715 data: data, 2716 cache: false 2717 } ); 2718} 2719 2720function wp_easycart_goto_shipping_v2( should_scroll = false ) { 2721 var has_errors = false; 2722 var scrolled_top = false; 2723 var has_shipping_error = false; 2724 if ( jQuery( document.getElementById( 'ec_contact_email' ) ).length && ! ec_validate_email_block( 'ec_contact' ) ) { 2725 jQuery( document.getElementById( 'ec_email_order2_error' ) ).show(); 2726 has_errors = true; 2727 if ( should_scroll && ! scrolled_top ) { 2728 jQuery( [ document.documentElement, document.body ] ).animate( { 2729 scrollTop: jQuery( document.getElementById( 'ec_cart_contact_header' ) ).offset().top 2730 }, 750 ); 2731 scrolled_top = true; 2732 } 2733 } else { 2734 jQuery( document.getElementById( 'ec_email_order2_error' ) ).hide(); 2735 } 2736 2737 if ( jQuery( document.getElementById( 'ec_user_create_form' ) ).length ) { 2738 jQuery( document.getElementById( 'ec_user_login_form' ) ).hide( ); 2739 jQuery( document.getElementById( 'ec_user_contact_form' ) ).show( ); 2740 jQuery( document.getElementById( 'ec_user_login_link' ) ).show( ); 2741 jQuery( document.getElementById( 'ec_user_login_cancel_link' ) ).hide( ); 2742 jQuery( document.getElementById( 'ec_login_selector' ) ).prop( 'checked', false ); 2743 jQuery( document.getElementById( 'ec_user_create_form' ) ).show(); 2744 if ( ! ec_validate_create_account( 'ec_contact' ) ) { 2745 jQuery( document.getElementById( 'ec_create_account_order_error' ) ).show(); 2746 has_errors = true; 2747 if ( should_scroll && ! scrolled_top ) { 2748 jQuery( [ document.documentElement, document.body ] ).animate( { 2749 scrollTop: jQuery( document.getElementById( 'ec_cart_create_account_header' ) ).offset().top 2750 }, 750 ); 2751 scrolled_top = true; 2752 } 2753 } else { 2754 jQuery( document.getElementById( 'ec_create_account_order_error' ) ).hide(); 2755 } 2756 } 2757 2758 if ( jQuery( document.getElementById( 'ec_shipping_complete' ) ).length ) { 2759 if ( '0' == jQuery( document.getElementById( 'ec_shipping_complete' ) ).val() ) { 2760 jQuery( '#ec_shipping_order_error' ).show(); 2761 has_errors = true; 2762 has_shipping_error = true; 2763 } else { 2764 jQuery( '#ec_shipping_order_error' ).hide(); 2765 } 2766 } else if ( jQuery( document.getElementById( 'ec_cart_shipping_first_name' ) ).length && ! ec_validate_address_block( 'ec_cart_shipping' ) ) { 2767 jQuery( '#ec_shipping_order_error' ).show(); 2768 has_errors = true; 2769 has_shipping_error = true; 2770 } else if ( ! jQuery( document.getElementById( 'ec_cart_shipping_first_name' ) ).length && jQuery( document.getElementById( 'ec_cart_billing_first_name' ) ).length && ! ec_validate_address_block( 'ec_cart_billing' ) ) { 2771 jQuery( '#ec_shipping_order_error' ).show(); 2772 has_errors = true; 2773 has_shipping_error = true; 2774 } else if ( jQuery( document.getElementById( 'ec_shipping_address_line_1' ) ).length && '' == jQuery( document.getElementById( 'ec_shipping_address_line_1' ) ).val() || '' == jQuery( document.getElementById( 'ec_shipping_name' ) ).val() ) { 2775 jQuery( '#ec_shipping_order_error' ).show(); 2776 has_errors = true; 2777 has_shipping_error = true; 2778 } else { 2779 jQuery( '#ec_shipping_order_error' ).hide(); 2780 } 2781 if ( should_scroll && has_shipping_error && ! scrolled_top ) { 2782 jQuery( [ document.documentElement, document.body ] ).animate( { 2783 scrollTop: jQuery( document.getElementById( 'ec_cart_shipping_header' ) ).offset().top 2784 }, 750 ); 2785 scrolled_top = true; 2786 } 2787 2788 if ( has_errors ) { 2789 return false; 2790 } 2791 2792 if( jQuery( document.getElementById( 'ec_cart_onepage_shipping' ) ).length ) { 2793 var header_html = jQuery( document.getElementById( 'ec_cart_onepage_shipping' ) ).find( '.ec_cart_header' ); 2794 jQuery( document.getElementById( 'ec_cart_onepage_shipping' ) ).html( '<div id="ec_cart_shipping_loader"><div class="ec_cart_shipping_animate_pulse"><div class="ec_cart_shipping_rounded_loader"></div><div class="ec_cart_shipping_animate_line_container"><div class="ec_cart_shipping_animate_line_top"></div><div class="ec_cart_shipping_animate_line_bottom"></div></div></div><div class="ec_cart_shipping_animate_pulse"><div class="ec_cart_shipping_rounded_loader"></div><div class="ec_cart_shipping_animate_line_container"><div class="ec_cart_shipping_animate_line_top"></div><div class="ec_cart_shipping_animate_line_bottom"></div></div></div><div class="ec_cart_shipping_animate_pulse"><div class="ec_cart_shipping_rounded_loader"></div><div class="ec_cart_shipping_animate_line_container"><div class="ec_cart_shipping_animate_line_top"></div><div class="ec_cart_shipping_animate_line_bottom"></div></div></div></div>' ).prepend( header_html ); 2795 if ( jQuery( document.getElementById( 'ec_cart_onepage_payment' ) ).find( '.ec_cart_locked_panel' ).length ) { 2796 var payment_header_html = jQuery( document.getElementById( 'ec_cart_onepage_payment' ) ).find( '.ec_cart_header' ); 2797 jQuery( document.getElementById( 'ec_cart_onepage_payment' ) ).html( '<div id="ec_cart_shipping_loader"><div class="ec_cart_shipping_animate_pulse"><div class="ec_cart_shipping_rounded_loader"></div><div class="ec_cart_shipping_animat
2797e_line_container"><div class="ec_cart_shipping_animate_line_top"></div><div class="ec_cart_shipping_animate_line_bottom"></div></div></div><div class="ec_cart_shipping_animate_pulse"><div class="ec_cart_shipping_rounded_loader"></div><div class="ec_cart_shipping_animate_line_container"><div class="ec_cart_shipping_animate_line_top"></div><div class="ec_cart_shipping_animate_line_bottom"></div></div></div></div>' ).prepend( payment_header_html ); 2798 } 2799 2800 } else if( jQuery( document.getElementById( 'ec_cart_onepage_payment' ) ).length ) { 2801 var header_html = jQuery( document.getElementById( 'ec_cart_onepage_payment' ) ).find( '.ec_cart_header' ); 2802 if ( jQuery( document.getElementById( 'ec_cart_onepage_payment' ) ).find( '.ec_cart_locked_panel' ).length ) { 2803 jQuery( document.getElementById( 'ec_cart_onepage_payment' ) ).html( '<div id="ec_cart_shipping_loader"><div class="ec_cart_shipping_animate_pulse"><div class="ec_cart_shipping_rounded_loader"></div><div class="ec_cart_shipping_animate_line_container"><div class="ec_cart_shipping_animate_line_top"></div><div class="ec_cart_shipping_animate_line_bottom"></div></div></div><div class="ec_cart_shipping_animate_pulse"><div class="ec_cart_shipping_rounded_loader"></div><div class="ec_cart_shipping_animate_line_container"><div class="ec_cart_shipping_animate_line_top"></div><div class="ec_cart_shipping_animate_line_bottom"></div></div></div></div>' ).prepend( header_html ); 2804 } 2805 } else { 2806 jQuery( '.ec_cart_left' ).append( '<div id="ec_cart_shipping_loader"><style>@keyframes rotation{0% { transform:rotate(0deg); }100%{ transform:rotate(359deg); }}</style><div style=\'font-family: "HelveticaNeue", "HelveticaNeue-Light", "Helvetica Neue Light", helvetica, arial, sans-serif; font-size: 14px; text-align: center; -webkit-box-sizing: border-box; -moz-box-sizing: border-box; -ms-box-sizing: border-box; box-sizing: border-box; width: 350px; top: 50%; left: 50%; position: absolute; margin-left: -165px; margin-top: -80px; cursor: pointer; text-align: center;\'><div><div style="height: 30px; width: 30px; display: inline-block; box-sizing: content-box; opacity: 1; filter: alpha(opacity=100); -webkit-animation: rotation .7s infinite linear; -moz-animation: rotation .7s infinite linear; -o-animation: rotation .7s infinite linear; animation: rotation .7s infinite linear; border-left: 8px solid rgba(0, 0, 0, .2); border-right: 8px solid rgba(0, 0, 0, .2); border-bottom: 8px solid rgba(0, 0, 0, .2); border-top: 8px solid #fff; border-radius: 100%;"></div></div></div></div>' ); 2807 } 2808 2809 if ( jQuery( document.getElementById( 'ec_shipping_complete' ) ).length || jQuery( document.getElementById( 'ec_cart_shipping_first_name' ) ).length ) { 2810 var shipping_country = ( jQuery( document.getElementById( 'ec_shipping_country' ) ).length ) ? jQuery( document.getElementById( 'ec_shipping_country' ) ).val() : jQuery( document.getElementById( 'ec_cart_shipping_country' ) ).val(); 2811 var shipping_state = ( jQuery( document.getElementById( 'ec_shipping_state' ) ).length ) ? jQuery( document.getElementById( 'ec_shipping_state' ) ).val() : jQuery( document.getElementById( 'ec_cart_shipping_state' ) ).val(); 2812 if ( jQuery( document.getElementById( 'ec_cart_shipping_state_' + shipping_country ) ).length ) { 2813 shipping_state = jQuery( document.getElementById( 'ec_cart_shipping_state_' + shipping_country ) ).val(); 2814 } 2815 2816 var data = { 2817 action: 'ec_ajax_save_checkout_info', 2818 ec_cart_is_subscriber: ( jQuery( document.getElementById( 'ec_cart_is_subscriber' ) ).is( ':checked' ) ) ? '1' : '0', 2819 ec_shipping_selector: jQuery( document.getElementById( 'ec_shipping_selector' ) ).val(), 2820 ec_shipping_address_line_1: ( jQuery( document.getElementById( 'ec_shipping_address_line_1' ) ).length ) ? jQuery( document.getElementById( 'ec_shipping_address_line_1' ) ).val() : jQuery( document.getElementById( 'ec_cart_shipping_address' ) ).val(), 2821 ec_shipping_address_line_2: ( jQuery( document.getElementById( 'ec_shipping_address_line_2' ) ).length ) ? jQuery( document.getElementById( 'ec_shipping_address_line_2' ) ).val() : jQuery( document.getElementById( 'ec_cart_shipping_address2' ) ).val(), 2822 ec_shipping_city: ( jQuery( document.getElementById( 'ec_shipping_city' ) ).length ) ? jQuery( document.getElementById( 'ec_shipping_city' ) ).val() : jQuery( document.getElementById( 'ec_cart_shipping_city' ) ).val(), 2823 ec_shipping_state: shipping_state, 2824 ec_shipping_zip: ( jQuery( document.getElementById( 'ec_shipping_zip' ) ).length ) ? jQuery( document.getElementById( 'ec_shipping_zip' ) ).val() : jQuery( document.getElementById( 'ec_cart_shipping_zip' ) ).val(), 2825 ec_shipping_country: shipping_country, 2826 ec_shipping_phone: ( jQuery( document.getElementById( 'ec_shipping_phone' ) ).length ) ? jQuery( document.getElementById( 'ec_shipping_phone' ) ).val() : jQuery( document.getElementById( 'ec_cart_shipping_phone' ) ).val(), 2827 ec_shipping_name: ( jQuery( document.getElementById( 'ec_shipping_name' ) ).length ) ? jQuery( document.getElementById( 'ec_shipping_name' ) ).val() : jQuery( document.getElementById( 'ec_cart_shipping_first_name' ) ).val(), 2828 ec_shipping_last_name: ( jQuery( document.getElementById( 'ec_shipping_last_name' ) ).length ) ? jQuery( document.getElementById( 'ec_shipping_last_name' ) ).val() : jQuery( document.getElementById( 'ec_cart_shipping_last_name' ) ).val(), 2829 ec_shipping_company_name: ( jQuery( document.getElementById( 'ec_shipping_company_name' ) ).length ) ? jQuery( document.getElementById( 'ec_shipping_company_name' ) ).val() : jQuery( document.getElementById( 'ec_cart_shipping_company_name' ) ).val(), 2830 ec_contact_email: jQuery( document.getElementById( 'ec_contact_email' ) ).val(), 2831 ec_order_notes: jQuery( document.getElementById( 'ec_order_notes' ) ).val(), 2832 wpeasycart_checkout_nonce: jQuery( document.getElementById( 'wpeasycart_checkout_nonce' ) ).val(), 2833 }; 2834 wp_easycart_goto_push_state( 'shipping' ); 2835 } else { 2836 var billing_country = ( jQuery( document.getElementById( 'ec_billing_country' ) ).length ) ? jQuery( document.getElementById( 'ec_billing_country' ) ).val() : jQuery( document.getElementById( 'ec_cart_billing_country' ) ).val(); 2837 var billing_state = ( jQuery( document.getElementById( 'ec_billing_state' ) ).length ) ? jQuery( document.getElementById( 'ec_billing_state' ) ).val() : jQuery( document.getElementById( 'ec_cart_billing_state' ) ).val(); 2838 if ( jQuery( document.getElementById( 'ec_cart_billing_state_' + billing_country ) ).length ) { 2839 billing_state = jQuery( document.getElementById( 'ec_cart_billing_state_' + billing_country ) ).val(); 2840 } 2841 2842 var data = { 2843 action: 'ec_ajax_save_checkout_info', 2844 ec_cart_is_subscriber: ( jQuery( document.getElementById( 'ec_cart_is_subscriber' ) ).is( ':checked' ) ) ? '1' : '0', 2845 ec_billing_address_line_1: ( jQuery( document.getElementById( 'ec_billing_address_line_1' ) ).length ) ? jQuery( document.getElementById( 'ec_billing_address_line_1' ) ).val() : jQuery( document.getElementById( 'ec_cart_billing_address' ) ).val(), 2846 ec_billing_address_line_2: ( jQuery( document.getElementById( 'ec_billing_address_line_2' ) ).length ) ? jQuery( document.getElementById( 'ec_billing_address_line_2' ) ).val() : jQuery( document.getElementById( 'ec_cart_billing_address2' ) ).val(), 2847 ec_billing_city: ( jQuery( document.getElementById( 'ec_billing_city' ) ).length ) ? jQuery( document.getElementById( 'ec_billing_city' ) ).val() : jQuery( document.getElementById( 'ec_cart_billing_city' ) ).val(), 2848 ec_billing_state: billing_state, 2849 ec_billing_zip: ( jQuery( document.getElementById( 'ec_billing_zip' ) ).length ) ? jQuery( document.getElementById( 'ec_billing_zip' ) ).val() : jQuery( document.getElementById( 'ec_cart_billing_zip' ) ).val(), 2850 ec_billing_country: billing_country, 2851 ec_billing_phone: ( jQuery( document.getElementById( 'ec_billing_phone' ) ).length ) ? jQuery( document.getElementById( 'ec_billing_phone' ) ).val() : jQuery( document.getElementById( 'ec_cart_billing_phone' ) ).val(), 2852 ec_billing_name: ( jQuery( document.getElementById( 'ec_billing_name' ) ).length ) ? jQuery( document.getElementById( 'ec_billing_name' ) ).val() : jQuery( document.getElementById( 'ec_cart_billing_first_name' ) ).val(), 2853 ec_billing_last_name: ( jQuery( document.getElementById( 'ec_billing_last_name' ) ).length ) ? jQuery( document.getElementById( 'ec_billing_last_name' ) ).val() : jQuery( document.getElementById( 'ec_cart_billing_last_name' ) ).val(), 2854 ec_billing_company_name: ( jQuery( document.getElementById( 'ec_billing_company_name' ) ).length ) ? jQuery( document.getElementById( 'ec_billing_company_name' ) ).val() : jQuery( document.getElementById( 'ec_cart_billing_company_name' ) ).val(), 2855 ec_contact_email: jQuery( document.getElementById( 'ec_contact_email' ) ).val(), 2856 ec_order_notes: jQuery( document.getElementById( 'ec_order_notes' ) ).val(), 2857 wpeasycart_checkout_nonce: jQuery( document.getElementById( 'wpeasycart_checkout_nonce' ) ).val(), 2858 }; 2859 wp_easycart_goto_push_state( 'payment' ); 2860 } 2861 2862 if ( jQuery( document.getElementById( 'ec_user_create_form' ) ).length ) { 2863 data.ec_create_account = 1; 2864 if ( jQuery( document.getElementById( 'ec_contact_first_name' ) ).length ) { 2865 data.ec_contact_first_name = jQuery( document.getElementById( 'ec_contact_first_name' ) ).val(); 2866 } 2867 if ( jQuery( document.getElementById( 'ec_contact_last_name' ) ).length ) { 2868 data.ec_contact_last_name = jQuery( document.getElementById( 'ec_contact_last_name' ) ).val(); 2869 } 2870 data.ec_contact_password = jQuery( document.getElementById( 'ec_contact_password' ) ).val(); 2871 } 2872 2873 jQuery.ajax( { 2874 url: wpeasycart_ajax_object.ajax_url, 2875 type: 'post', 2876 data: data, 2877 cache: false, 2878 success: function( data ) { 2879 var response_obj = JSON.parse( data ); 2880 jQuery( document.getElementById( 'ec_cart_shipping_loader' ) ).remove(); 2881 if ( response_obj.error && 'user_create_error' == response_obj.error ) { 2882 jQuery( document.getElementById( 'ec_create_account_email_error' ) ).show(); 2883 } else { 2884 jQuery( document.getElementById( 'ec_create_account_email_error' ) ).hide(); 2885 } 2886 ec_update_cart( response_obj.cart_data ); 2887 if( jQuery( document.getElementById( 'ec_cart_onepage_payment' ) ).length ) { 2888 if ( jQuery( document.getElementById( 'ec_cart_onepage_shipping' ) ).length ) { 2889 jQuery( document.getElementById( 'ec_cart_onepage_shipping' ) ).html( response_obj.shipping_content ); 2890 if ( jQuery( 'input[name=ec_cart_shipping_method]:checked' ).length ) { 2891 if ( jQuery( document.getElementById( 'ec_shipping_method_order_error' ) ).length ) { 2892 jQuery( document.getElementById( 'ec_shipping_method_order_error' ) ).hide(); 2893 } 2894 } 2895 } 2896 if ( jQuery( document.getElementById( 'ec_cart_onepage_payment' ) ).find( '.ec_cart_locked_panel' ).length || jQuery( document.getElementById( 'ec_cart_onepage_payment' ) ).find( '.ec_cart_shipping_animate_pulse' ).length ) { 2897 jQuery( document.getElementById( 'ec_cart_onepage_payment' ) ).html( response_obj.payment_content ); 2898 } 2899 } else { 2900 if ( ! response_obj.error ) { 2901 jQuery( '.ec_cart_left' ).html( response_obj.html_content ); 2902 if ( '1' == response_obj.shipping_allowed ) { 2903 jQuery( '#wpeasycart_shipping_page_link' ).removeClass( 'wpeasycart-deactivated-link' ); 2904 } 2905 if ( '1' == response_obj.payment_allowed ) { 2906 jQuery( '#wpeasycart_payment_page_link' ).removeClass( 'wpeasycart-deactivated-link' ); 2907 } 2908 } 2909 } 2910 } 2911 } ); 2912} 2913 2914function wp_easycart_goto_payment_v2() { 2915 jQuery( '.ec_cart_left' ).append( '<style>@keyframes rotation{0% { transform:rotate(0deg); }100%{ transform:rotate(359deg); }}</style><div style=\'font-family: "HelveticaNeue", "HelveticaNeue-Light", "Helvetica Neue Light", helvetica, arial, sans-serif; font-size: 14px; text-align: center; -webkit-box-sizing: border-box; -moz-box-sizing: border-box; -ms-box-sizing: border-box; box-sizing: border-box; width: 350px; top: 50%; left: 50%; position: absolute; margin-left: -165px; margin-top: -80px; cursor: pointer; text-align: center;\'><div><div style="height: 30px; width: 30px; display: inline-block; box-sizing: content-box; opacity: 1; filter: alpha(opacity=100); -webkit-animation: rotation .7s infinite linear; -moz-animation: rotation .7s infinite linear; -o-animation: rotation .7s infinite linear; animation: rotation .7s infinite linear; border-left: 8px solid rgba(0, 0, 0, .2); border-right: 8px solid rgba(0, 0, 0, .2); border-bottom: 8px solid rgba(0, 0, 0, .2); border-top: 8px solid #fff; border-radius: 100%;"></div></div></div>' ); 2916 2917 var ship_express = 0; 2918 var shipping_method = jQuery( '.ec_cart_shipping_method_row > input:checked' ).val(); 2919 if ( jQuery( document.getElementById( 'ec_cart_ship_express' ) ).length ) { 2920 if ( jQuery( document.getElementById( 'ec_cart_ship_express' ) ).is( ':checked' ) ) { 2921 ship_express = 1; 2922 } 2923 } 2924 2925 if ( 'shipexpress' == shipping_method ) { 2926 shipping_method = 'standard'; 2927 if ( jQuery( document.getElementById( 'ec_cart_shipping_method_free' ) ).length ) { 2928 jQuery( document.getElementById( 'ec_cart_shipping_method_free' ) ).prop( 'checked', false ); 2929 } 2930 jQuery( document.getElementById( 'ec_cart_shipping_method' ) ).prop( 'checked', 'checked' ); 2931 2932 } else if( 'free' == shipping_method ) { 2933 if ( jQuery( document.getElementById( 'ec_cart_ship_express' ) ).length ) { 2934 jQuery( document.getElementById( 'ec_cart_ship_express' ) ).prop( 'checked', false ); 2935 } 2936 } 2937 2938 wp_easycart_goto_push_state( 'payment' ); 2939 var data = { 2940 action: 'ec_ajax_save_shipping_method', 2941 shipping_method: shipping_method, 2942 ship_express: ship_express, 2943 wpeasycart_checkout_nonce: jQuery( document.getElementById( 'wpeasycart_checkout_nonce' ) ).val(), 2944 }; 2945 jQuery.ajax( { 2946 url: wpeasycart_ajax_object.ajax_url, 2947 type: 'post', 2948 data: data, 2949 cache: false, 2950 success: function( data ) { 2951 var response_obj = JSON.parse( data ); 2952 jQuery( '.ec_cart_left' ).html( response_obj.html_content ); 2953 if ( '1' == response_obj.shipping_allowed ) { 2954 jQuery( '#wpeasycart_shipping_page_link' ).removeClass( 'wpeasycart-deactivated-link' ); 2955 } 2956 if ( '1' == response_obj.payment_allowed ) { 2957 jQuery( '#wpeasycart_payment_page_link' ).removeClass( 'wpeasycart-deactivated-link' ); 2958 } 2959 } 2960 } ); 2961} 2962 2963function ec_toggle_create_account( ){ 2964 if( jQuery( document.getElementById( 'ec_user_create_form' ) ).is( ':visible' ) ){ 2965 jQuery( document.getElementById( 'ec_user_create_form' ) ).hide( ); 2966 }else{ 2967 jQuery( document.getElementById( 'ec_user_create_form' ) ).show( ); 2968 } 2969} 2970 2971function ec_update_payment_display( nonce ) { 2972 jQuery( '.ec_cart_payment_table_row ' ).removeClass( 'ec_payment_row_selected' ); 2973 2974 var payment_method = "manual_bill"; 2975 2976 jQuery( document.getElementById( 'ec_apple_pay_form' ) ).hide( ); 2977 jQuery( document.getElementById( 'ec_manual_payment_form' ) ).hide( ); 2978 jQuery( document.getElementById( 'ec_amazonpay_form' ) ).hide( ); 2979 jQuery( document.getElementById( 'ec_affirm_form' ) ).hide( ); 2980 jQuery( document.getElementById( 'ec_third_party_form' ) ).hide( ); 2981 jQuery( document.getElementById( 'ec_credit_card_form' ) ).hide( ); 2982 jQuery( document.getElementById( 'ec_ideal_form' ) ).hide( ); 2983 2984 if( jQuery( document.getElementById( 'ec_payment_apple' ) ).is( ':checked' ) ){ 2985 jQuery( '#ec_payment_apple' ).parent().parent().addClass( 'ec_payment_row_selected' ); 2986 2987 jQuery( document.getElementById( 'ec_apple_pay_form' ) ).show( ); 2988 2989 if( jQuery( document.getElementById( 'ec_terms_row' ) ).length ) 2990 jQuery( document.getElementById( 'ec_terms_row' ) ).show( ); 2991 2992 if( jQuery( document.getElementById( 'ec_terms_agreement_row' ) ).length ) 2993 jQuery( document.getElementById( 'ec_terms_agreement_row' ) ).show( ); 2994 2995 if( jQuery( document.getElementById( 'wpeasycart_submit_order_row' ) ).length ) 2996 jQuery( document.getElementById( 'wpeasycart_submit_order_row' ) ).show( ); 2997 2998 if( jQuery( document.getElementById( 'wpeasycart_submit_paypal_order_row' ) ).length ) 2999 jQuery( document.getElementById( 'wpeasycart_submit_paypal_order_row' ) ).hide( ); 3000 3001 3002 payment_method = "apple_pay"; 3003 3004 }else if( jQuery( document.getElementById( 'ec
3004_payment_manual' ) ).is( ':checked' ) ){ 3005 jQuery( '#ec_payment_manual' ).parent().parent().addClass( 'ec_payment_row_selected' ); 3006 3007 jQuery( document.getElementById( 'ec_manual_payment_form' ) ).show( ); 3008 3009 if( jQuery( document.getElementById( 'ec_terms_row' ) ).length ) 3010 jQuery( document.getElementById( 'ec_terms_row' ) ).show( ); 3011 3012 if( jQuery( document.getElementById( 'ec_terms_agreement_row' ) ).length ) 3013 jQuery( document.getElementById( 'ec_terms_agreement_row' ) ).show( ); 3014 3015 if( jQuery( document.getElementById( 'wpeasycart_submit_order_row' ) ).length ) 3016 jQuery( document.getElementById( 'wpeasycart_submit_order_row' ) ).show( ); 3017 3018 if( jQuery( document.getElementById( 'wpeasycart_submit_paypal_order_row' ) ).length ) 3019 jQuery( document.getElementById( 'wpeasycart_submit_paypal_order_row' ) ).hide( ); 3020 3021 3022 payment_method = "manual_bill"; 3023 3024 }else if( jQuery( document.getElementById( 'ec_payment_affirm' ) ).is( ':checked' ) ){ 3025 jQuery( '#ec_payment_affirm' ).parent().parent().addClass( 'ec_payment_row_selected' ); 3026 3027 jQuery( document.getElementById( 'ec_affirm_form' ) ).show( ); 3028 3029 if( jQuery( document.getElementById( 'ec_terms_row' ) ).length ) 3030 jQuery( document.getElementById( 'ec_terms_row' ) ).show( ); 3031 3032 if( jQuery( document.getElementById( 'ec_terms_agreement_row' ) ).length ) 3033 jQuery( document.getElementById( 'ec_terms_agreement_row' ) ).show( ); 3034 3035 if( jQuery( document.getElementById( 'wpeasycart_submit_order_row' ) ).length ) 3036 jQuery( document.getElementById( 'wpeasycart_submit_order_row' ) ).show( ); 3037 3038 if( jQuery( document.getElementById( 'wpeasycart_submit_paypal_order_row' ) ).length ) 3039 jQuery( document.getElementById( 'wpeasycart_submit_paypal_order_row' ) ).hide( ); 3040 3041 payment_method = "affirm"; 3042 3043 }else if( jQuery( document.getElementById( 'ec_payment_third_party' ) ).is( ':checked' ) ){ 3044 jQuery( '#ec_payment_third_party' ).parent().parent().addClass( 'ec_payment_row_selected' ); 3045 3046 jQuery( document.getElementById( 'ec_third_party_form' ) ).show( ); 3047 3048 if( jQuery( document.getElementById( 'wpeasycart_submit_paypal_order_row' ) ).length ){ 3049 3050 jQuery( document.getElementById( 'wpeasycart_submit_paypal_order_row' ) ).show( ); 3051 3052 if( jQuery( document.getElementById( 'ec_terms_row' ) ).length ) 3053 jQuery( document.getElementById( 'ec_terms_row' ) ).show( ); 3054 3055 if( jQuery( document.getElementById( 'ec_submit_order_error' ) ).length ) 3056 jQuery( document.getElementById( 'ec_submit_order_error' ) ).hide( ); 3057 3058 if( jQuery( document.getElementById( 'ec_terms_agreement_row' ) ).length ) 3059 jQuery( document.getElementById( 'ec_terms_agreement_row' ) ).show( ); 3060 3061 if( jQuery( document.getElementById( 'wpeasycart_submit_order_row' ) ).length ) 3062 jQuery( document.getElementById( 'wpeasycart_submit_order_row' ) ).hide( ); 3063 } 3064 3065 payment_method = "third_party"; 3066 3067 }else if( jQuery( document.getElementById( 'ec_payment_credit_card' ) ).is( ':checked' ) ){ 3068 jQuery( '#ec_payment_credit_card' ).parent().parent().addClass( 'ec_payment_row_selected' ); 3069 3070 jQuery( document.getElementById( 'ec_credit_card_form' ) ).show( ); 3071 3072 if( jQuery( document.getElementById( 'ec_terms_row' ) ).length ) 3073 jQuery( document.getElementById( 'ec_terms_row' ) ).show( ); 3074 3075 if( jQuery( document.getElementById( 'ec_terms_agreement_row' ) ).length ) 3076 jQuery( document.getElementById( 'ec_terms_agreement_row' ) ).show( ); 3077 3078 if( jQuery( document.getElementById( 'wpeasycart_submit_order_row' ) ).length ) 3079 jQuery( document.getElementById( 'wpeasycart_submit_order_row' ) ).show( ); 3080 3081 if( jQuery( document.getElementById( 'wpeasycart_submit_paypal_order_row' ) ).length ) 3082 jQuery( document.getElementById( 'wpeasycart_submit_paypal_order_row' ) ).hide( ); 3083 3084 payment_method = "credit_card"; 3085 3086 }else if( jQuery( document.getElementById( 'ec_payment_ideal' ) ).is( ':checked' ) ){ 3087 jQuery( '#ec_payment_ideal' ).parent().parent().addClass( 'ec_payment_row_selected' ); 3088 3089 jQuery( document.getElementById( 'ec_ideal_form' ) ).show( ); 3090 3091 if( jQuery( document.getElementById( 'ec_terms_row' ) ).length ) 3092 jQuery( document.getElementById( 'ec_terms_row' ) ).show( ); 3093 3094 if( jQuery( document.getElementById( 'ec_terms_agreement_row' ) ).length ) 3095 jQuery( document.getElementById( 'ec_terms_agreement_row' ) ).show( ); 3096 3097 if( jQuery( document.getElementById( 'wpeasycart_submit_order_row' ) ).length ) 3098 jQuery( document.getElementById( 'wpeasycart_submit_order_row' ) ).show( ); 3099 3100 if( jQuery( document.getElementById( 'wpeasycart_submit_paypal_order_row' ) ).length ) 3101 jQuery( document.getElementById( 'wpeasycart_submit_paypal_order_row' ) ).hide( ); 3102 3103 payment_method = "ideal"; 3104 3105 }else if( jQuery( document.getElementById( 'ec_amazonpay' ) ).is( ':checked' ) ){ 3106 jQuery( '#ec_amazonpay' ).parent().parent().addClass( 'ec_payment_row_selected' ); 3107 3108 jQuery( document.getElementById( 'ec_amazonpay_form' ) ).show( ); 3109 3110 if( jQuery( document.getElementById( 'ec_terms_row' ) ).length ) 3111 jQuery( document.getElementById( 'ec_terms_row' ) ).show( ); 3112 3113 if( jQuery( document.getElementById( 'ec_terms_agreement_row' ) ).length ) 3114 jQuery( document.getElementById( 'ec_terms_agreement_row' ) ).show( ); 3115 3116 if( jQuery( document.getElementById( 'wpeasycart_submit_order_row' ) ).length ) 3117 jQuery( document.getElementById( 'wpeasycart_submit_order_row' ) ).show( ); 3118 3119 if( jQuery( document.getElementById( 'wpeasycart_submit_paypal_order_row' ) ).length ) 3120 jQuery( document.getElementById( 'wpeasycart_submit_paypal_order_row' ) ).hide( ); 3121 3122 payment_method = "amazonpay"; 3123 } 3124 3125 var data = { 3126 action: 'ec_ajax_update_payment_method', 3127 payment_method: payment_method, 3128 nonce: nonce 3129 }; 3130 3131 jQuery.ajax( { 3132 url: wpeasycart_ajax_object.ajax_url, 3133 type: 'post', 3134 data: data, 3135 cache: false, 3136 success: function( response ){ 3137 var response_obj = JSON.parse( response ); 3138 ec_update_cart( response_obj.cart_data ); 3139 } 3140 } ); 3141 3142} 3143 3144function ec_update_billing_address_display( billing_address_type, nonce ) { 3145 jQuery( '.ec_cart_billing_table_row' ).removeClass( 'ec_billing_row_selected' ); 3146 jQuery( '.ec_cart_billing_table_column > input[value="' + billing_address_type + '"]' ).parent().parent().addClass( 'ec_billing_row_selected' ); 3147 3148 if ( '0' == billing_address_type ) { 3149 jQuery( '.ec_cart_billing_table_address' ).hide(); 3150 if ( jQuery( document.getElementById( 'ec_shipping_selector' ) ).length ) { 3151 jQuery( document.getElementById( 'ec_shipping_selector' ) ).val( '0' ); 3152 } 3153 jQuery( document.getElementById( 'ec_billing_order_error' ) ).hide(); 3154 } else { 3155 jQuery( '.ec_cart_billing_table_address' ).show(); 3156 if ( jQuery( document.getElementById( 'ec_shipping_selector' ) ).length ) { 3157 jQuery( document.getElementById( 'ec_shipping_selector' ) ).val( '1' ); 3158 } 3159 } 3160 3161 var billing_country = ( ( jQuery( document.getElementById( 'ec_billing_country' ) ).length ) ? jQuery( document.getElementById( 'ec_billing_country' ) ).val() : jQuery( document.getElementById( 'ec_cart_billing_country' ) ).val() ); 3162 var billing_state = ''; 3163 if ( jQuery( document.getElementById( 'ec_billing_state' ) ).length ) { 3164 billing_state = jQuery( document.getElementById( 'ec_billing_state' ) ).val(); 3165 } else if ( jQuery( document.getElementById( 'ec_cart_billing_state_' + billing_country ) ).length ) { 3166 billing_state = jQuery( document.getElementById( 'ec_cart_billing_state_' + billing_country ) ).val(); 3167 } else { 3168 billing_state = jQuery( document.getElementById( 'ec_cart_billing_state' ) ).val() 3169 } 3170 var data = { 3171 action: 'ec_ajax_update_billing_address_type', 3172 billing_address_type: billing_address_type, 3173 ec_billing_address_line_1: ( ( jQuery( document.getElementById( 'ec_billing_address_line_1' ) ).length ) ? jQuery( document.getElementById( 'ec_billing_address_line_1' ) ).val() : jQuery( document.getElementById( 'ec_cart_billing_address' ) ).val() ), 3174 ec_billing_address_line_2: ( ( jQuery( document.getElementById( 'ec_billing_address_line_2' ) ).length ) ? jQuery( document.getElementById( 'ec_billing_address_line_2' ) ).val() : jQuery( document.getElementById( 'ec_cart_billing_address2' ) ).val() ), 3175 ec_billing_city: ( ( jQuery( document.getElementById( 'ec_billing_city' ) ).length ) ? jQuery( document.getElementById( 'ec_billing_city' ) ).val() : jQuery( document.getElementById( 'ec_cart_billing_city' ) ).val() ), 3176 ec_billing_state: billing_state, 3177 ec_billing_zip: ( ( jQuery( document.getElementById( 'ec_billing_zip' ) ).length ) ? jQuery( document.getElementById( 'ec_billing_zip' ) ).val() : jQuery( document.getElementById( 'ec_cart_billing_zip' ) ).val() ), 3178 ec_billing_country: billing_country, 3179 ec_billing_phone: ( ( jQuery( document.getElementById( 'ec_billing_phone' ) ).length ) ? jQuery( document.getElementById( 'ec_billing_phone' ) ).val() : jQuery( document.getElementById( 'ec_cart_billing_phone' ) ).val() ), 3180 ec_billing_name: ( ( jQuery( document.getElementById( 'ec_billing_name' ) ).length ) ? jQuery( document.getElementById( 'ec_billing_name' ) ).val() : jQuery( document.getElementById( 'ec_cart_billing_first_name' ) ).val() ), 3181 ec_billing_last_name: ( ( jQuery( document.getElementById( 'ec_billing_last_name' ) ).length ) ? jQuery( document.getElementById( 'ec_billing_last_name' ) ).val() : jQuery( document.getElementById( 'ec_cart_billing_last_name' ) ).val() ), 3182 ec_billing_company_name: ( ( jQuery( document.getElementById( 'ec_billing_company_name' ) ).length ) ? jQuery( document.getElementById( 'ec_billing_company_name' ) ).val() : jQuery( document.getElementById( 'ec_cart_billing_company_name' ) ).val() ), 3183 nonce: nonce 3184 }; 3185 3186 jQuery.ajax({ 3187 url: wpeasycart_ajax_object.ajax_url, 3188 type: 'post', 3189 data: data, 3190 cache: false 3191 } ); 3192} 3193 3194function ec_show_cc_type( type ){ 3195 3196 if( jQuery( document.getElementById( 'ec_card_visa' ) ) ){ 3197 if( type == "visa" || type == "all" ){ 3198 jQuery( document.getElementById( 'ec_card_visa' ) ).show( ); 3199 jQuery( document.getElementById( 'ec_card_visa_inactive' ) ).hide( ); 3200 }else{ 3201 jQuery( document.getElementById( 'ec_card_visa' ) ).hide( ); 3202 jQuery( document.getElementById( 'ec_card_visa_inactive' ) ).show( ); 3203 } 3204 } 3205 3206 if( jQuery( document.getElementById( 'ec_card_discover' ) ) ){ 3207 if( type == "discover" || type == "all" ){ 3208 jQuery( document.getElementById( 'ec_card_discover' ) ).show( ); 3209 jQuery( document.getElementById( 'ec_card_discover_inactive' ) ).hide( ); 3210 }else{ 3211 jQuery( document.getElementById( 'ec_card_discover' ) ).hide( ); 3212 jQuery( document.getElementById( 'ec_card_discover_inactive' ) ).show( ); 3213 } 3214 } 3215 3216 if( jQuery( document.getElementById( 'ec_card_mastercard' ) ) ){ 3217 if( type == "mastercard" || type == "all" ){ 3218 jQuery( document.getElementById( 'ec_card_mastercard' ) ).show( ); 3219 jQuery( document.getElementById( 'ec_card_mastercard_inactive' ) ).hide( ); 3220 }else{ 3221 jQuery( document.getElementById( 'ec_card_mastercard' ) ).hide( ); 3222 jQuery( document.getElementById( 'ec_card_mastercard_inactive' ) ).show( ); 3223 } 3224 } 3225 3226 if( jQuery( document.getElementById( 'ec_card_amex' ) ) ){ 3227 if( type == "amex" || type == "all" ){ 3228 jQuery( document.getElementById( 'ec_card_amex' ) ).show( ); 3229 jQuery( document.getElementById( 'ec_card_amex_inactive' ) ).hide( ); 3230 }else{ 3231 jQuery( document.getElementById( 'ec_card_amex' ) ).hide( ); 3232 jQuery( document.getElementById( 'ec_card_amex_inactive' ) ).show( ); 3233 } 3234 } 3235 3236 if( jQuery( document.getElementById( 'ec_card_jcb' ) ) ){ 3237 if( type == "jcb" || type == "all" ){ 3238 jQuery( document.getElementById( 'ec_card_jcb' ) ).show( ); 3239 jQuery( document.getElementById( 'ec_card_jcb_inactive' ) ).hide( ); 3240 }else{ 3241 jQuery( document.getElementById( 'ec_card_jcb' ) ).hide( ); 3242 jQuery( document.getElementById( 'ec_card_jcb_inactive' ) ).show( ); 3243 } 3244 } 3245 3246 if( jQuery( document.getElementById( 'ec_card_diners' ) ) ){ 3247 if( type == "diners" || type == "all" ){ 3248 jQuery( document.getElementById( 'ec_card_diners' ) ).show( ); 3249 jQuery( document.getElementById( 'ec_card_diners_inactive' ) ).hide( ); 3250 }else{ 3251 jQuery( document.getElementById( 'ec_card_diners' ) ).hide( ); 3252 jQuery( document.getElementById( 'ec_card_diners_inactive' ) ).show( ); 3253 } 3254 } 3255 3256 if( jQuery( document.getElementById( 'ec_card_laser' ) ) ){ 3257 if( type == "laser" || type == "all" ){ 3258 jQuery( document.getElementById( 'ec_card_laser' ) ).show( ); 3259 jQuery( document.getElementById( 'ec_card_laser_inactive' ) ).hide( ); 3260 }else{ 3261 jQuery( document.getElementById( 'ec_card_laser' ) ).hide( ); 3262 jQuery( document.getElementById( 'ec_card_laser_inactive' ) ).show( ); 3263 } 3264 } 3265 3266 if( jQuery( document.getElementById( 'ec_card_maestro' ) ) ){ 3267 if( type == "maestro" || type == "all" ){ 3268 jQuery( document.getElementById( 'ec_card_maestro' ) ).show( ); 3269 jQuery( document.getElementById( 'ec_card_maestro_inactive' ) ).hide( ); 3270 }else{ 3271 jQuery( document.getElementById( 'ec_card_maestro' ) ).hide( ); 3272 jQuery( document.getElementById( 'ec_card_maestro_inactive' ) ).show( ); 3273 } 3274 } 3275 3276} 3277 3278function wpeasycart_bluecheck_verify( ){ 3279 try { 3280 3281 BlueCheckService.showModal(); 3282 return false; 3283 3284 } catch(e) { 3285 console.error('[BlueCheckService::customValidation]', e); 3286 BlueCheckService.BcWebLogger('Error: ' + (e.message || e)); 3287 return false; 3288 } 3289} 3290 3291function ec_validate_cart_details( ){ 3292 3293 var login_complete = true; 3294 var billing_complete = ec_validate_address_block( 'ec_cart_billing' ); 3295 var shipping_complete = true; 3296 var email_complete = true; 3297 var create_account_complete = true; 3298 var terms_complete = true; 3299 var recaptcha_complete = true; 3300 var bluecheck_complete = true; 3301 3302 if( jQuery( document.getElementById( 'ec_login_selector' ) ).is( ':checked' ) ) 3303 login_complete = ec_validate_cart_login( ); 3304 3305 if( jQuery( document.getElementById( 'ec_shipping_selector' ) ).is( ':checked' ) ) 3306 shipping_complete = ec_validate_address_block( 'ec_cart_shipping' ); 3307 3308 if( jQuery( document.getElementById( 'ec_contact_email' ) ).length ) 3309 email_complete = ec_validate_email_block( 'ec_contact' ); 3310 3311 if( jQuery( document.getElementById( 'ec_create_account_selector' ) ).is( ':checked' ) || ( jQuery( document.getElementById( 'ec_create_account_selector' ) ).is(':hidden' ) && jQuery( document.getElementById( 'ec_create_account_selector' ) ).val( ) == "create_account" ) ) { 3312 create_account_complete = ec_validate_create_account( 'ec_contact' ); 3313 terms_complete = ec_validate_terms_section(); 3314 } 3315 3316 if( document.getElementById( 'ec_account_register_recaptcha' ) ){ 3317 var recaptcha_response = jQuery( document.getElementById( 'ec_grecaptcha_response_register' ) ).val( ); 3318 if( !recaptcha_response.length ){ 3319 jQuery( '#ec_account_register_recaptcha > div' ).css( 'border', '1px solid red' ); 3320 recaptcha_complete = false; 3321 }else{ 3322 jQuery( '#ec_account_register_recaptcha > div' ).css( 'border', 'none' ); 3323 } 3324 } 3325 3326 if( document.getElementById( 'bcvTrigger' ) ){
3327 bluecheck_complete = wpeasycart_bluecheck_verify( ); 3328 if( !bluecheck_complete ) 3329 return false; 3330 } 3331 3332 if( login_complete && billing_complete && shipping_complete && email_complete && create_account_complete && terms_complete && recaptcha_complete ){ 3333 ec_hide_error( 'ec_checkout' ); 3334 ec_hide_error( 'ec_checkout2' ); 3335 jQuery( '.ec_checkout_details_submit' ).parent().addClass( 'wp-easycart-running' ); 3336 return true; 3337 }else{ 3338 ec_show_error( 'ec_checkout' ); 3339 ec_show_error( 'ec_checkout2' ); 3340 return false; 3341 } 3342 3343} 3344 3345function ec_validate_paypal_express_submit_order( ){ 3346 var terms_complete = ec_validate_terms( ); 3347 if( terms_complete ){ 3348 jQuery( document.getElementById( 'ec_cart_submit_order' ) ).hide( ); 3349 jQuery( document.getElementById( 'ec_cart_submit_order_working' ) ).show( ); 3350 ec_hide_error( 'ec_submit_order' ); 3351 return true; 3352 }else{ 3353 jQuery( document.getElementById( 'ec_cart_submit_order' ) ).show( ); 3354 jQuery( document.getElementById( 'ec_cart_submit_order_working' ) ).hide( ); 3355 ec_show_error( 'ec_submit_order' ); 3356 return false; 3357 } 3358} 3359 3360function ec_validate_submit_order( ){ 3361 var email_complete = true; 3362 var create_account_complete = true; 3363 var shipping_info_complete = true; 3364 var shipping_method_complete = true; 3365 var billing_info_complete = true; 3366 var pickup_info_complete = true; 3367 var scrolled_top = false; 3368 if ( jQuery( document.getElementById( 'ec_user_create_form' ) ).length ) { 3369 wp_easycart_update_contact_email_v2(); 3370 } 3371 if ( jQuery( document.getElementById( 'ec_contact_email_complete' ) ).length ) { 3372 if ( '0' == jQuery( document.getElementById( 'ec_contact_email_complete' ) ).val() ) { 3373 email_complete = false; 3374 if ( ! scrolled_top ) { 3375 jQuery( [ document.documentElement, document.body ] ).animate( { 3376 scrollTop: jQuery( document.getElementById( 'ec_cart_onepage_info' ) ).offset().top 3377 }, 750 ); 3378 scrolled_top = true; 3379 } 3380 } 3381 } else if ( jQuery( document.getElementById( 'ec_contact_email' ) ).length ) { 3382 if ( ! ec_validate_email_block( 'ec_contact' ) || ( jQuery( document.getElementById( 'ec_create_account_email_error' ) ).length && jQuery( document.getElementById( 'ec_create_account_email_error' ) ).is( ':visible' ) ) ) { 3383 email_complete = false; 3384 if ( ! scrolled_top ) { 3385 jQuery( [ document.documentElement, document.body ] ).animate( { 3386 scrollTop: jQuery( document.getElementById( 'ec_cart_contact_header' ) ).offset().top 3387 }, 750 ); 3388 scrolled_top = true; 3389 } 3390 } 3391 } 3392 if ( jQuery( document.getElementById( 'ec_user_create_form' ) ).length ) { 3393 jQuery( document.getElementById( 'ec_user_login_form' ) ).hide( ); 3394 jQuery( document.getElementById( 'ec_user_contact_form' ) ).show( ); 3395 jQuery( document.getElementById( 'ec_user_login_link' ) ).show( ); 3396 jQuery( document.getElementById( 'ec_user_login_cancel_link' ) ).hide( ); 3397 jQuery( document.getElementById( 'ec_login_selector' ) ).prop( 'checked', false ); 3398 jQuery( document.getElementById( 'ec_user_create_form' ) ).show(); 3399 if ( ! ec_validate_create_account( 'ec_contact' ) ) { 3400 jQuery( document.getElementById( 'ec_create_account_order_error' ) ).show(); 3401 create_account_complete = false; 3402 if ( ! scrolled_top ) { 3403 jQuery( [ document.documentElement, document.body ] ).animate( { 3404 scrollTop: jQuery( document.getElementById( 'ec_cart_create_account_header' ) ).offset().top 3405 }, 750 ); 3406 scrolled_top = true; 3407 } 3408 } else { 3409 jQuery( document.getElementById( 'ec_create_account_order_error' ) ).hide(); 3410 } 3411 } 3412 if ( jQuery( document.getElementById( 'ec_cart_onepage_info' ) ).length ) { 3413 if ( '0' == jQuery( document.getElementById( 'ec_shipping_complete' ) ).val() ) { 3414 shipping_info_complete = false; 3415 if ( ! scrolled_top ) { 3416 jQuery( [ document.documentElement, document.body ] ).animate( { 3417 scrollTop: jQuery( document.getElementById( 'ec_cart_onepage_info' ) ).offset().top 3418 }, 750 ); 3419 scrolled_top = true; 3420 } 3421 } else if ( jQuery( document.getElementById( 'ec_cart_shipping_country' ) ).length ) { 3422 if ( ! ec_validate_address_block( 'ec_cart_shipping' ) ) { 3423 shipping_info_complete = false; 3424 if ( ! scrolled_top ) { 3425 jQuery( [ document.documentElement, document.body ] ).animate( { 3426 scrollTop: jQuery( document.getElementById( 'ec_cart_onepage_info' ) ).offset().top 3427 }, 750 ); 3428 scrolled_top = true; 3429 } 3430 } 3431 } else if ( jQuery( document.getElementById( 'ec_cart_billing_country' ) ).length ) { 3432 if ( ! ec_validate_address_block( 'ec_cart_billing' ) ) { 3433 billing_info_complete = false; 3434 if ( ! scrolled_top ) { 3435 jQuery( [ document.documentElement, document.body ] ).animate( { 3436 scrollTop: jQuery( document.getElementById( 'ec_cart_onepage_info' ) ).offset().top 3437 }, 750 ); 3438 scrolled_top = true; 3439 } 3440 } 3441 } 3442 } 3443 if ( jQuery( document.getElementById( 'ec_cart_onepage_shipping' ) ).length ) { 3444 if ( ! jQuery( 'input[name=ec_cart_shipping_method]:checked' ).length ) { 3445 shipping_method_complete = false; 3446 if ( ! scrolled_top ) { 3447 jQuery( [ document.documentElement, document.body ] ).animate( { 3448 scrollTop: jQuery( document.getElementById( 'ec_cart_onepage_shipping' ) ).offset().top - 50 3449 }, 750 ); 3450 scrolled_top = true; 3451 } 3452 } 3453 } 3454 if ( jQuery( document.getElementById( 'billing_address_type_different' ) ).length && jQuery( document.getElementById( 'billing_address_type_different' ) ).is( ':checked' ) ) { 3455 if ( jQuery( document.getElementById( 'ec_billing_complete' ) ).length && '0' == jQuery( document.getElementById( 'ec_billing_complete' ) ).val() ) { 3456 billing_info_complete = false; 3457 } else if ( jQuery( document.getElementById( 'ec_cart_billing_country' ) ).length && ! ec_validate_address_block( 'ec_cart_billing' ) ) { 3458 billing_info_complete = false; 3459 } 3460 } 3461 3462 if ( jQuery( '#preorder_pickup_date' ).length ) { 3463 if ( ! jQuery( '#preorder_pickup_date' ).datepicker( 'getDate' ) ) { 3464 pickup_info_complete = false; 3465 jQuery( '#ec_preorder_pickup_error' ).show(); 3466 } else if ( '' == jQuery( '#preorder_pickup_time' ).val() ) { 3467 pickup_info_complete = false; 3468 jQuery( '#ec_preorder_pickup_error' ).show(); 3469 } else { 3470 jQuery( '#ec_preorder_pickup_error' ).hide(); 3471 } 3472 } 3473 3474 var payment_method_complete = ec_validate_payment_method( ); 3475 var terms_complete = ec_validate_terms( ); 3476 3477 if ( jQuery( document.getElementById( 'ec_email_order1_error' ) ).length ) { 3478 if ( email_complete ) { 3479 ec_hide_error( 'ec_email_order1' ); 3480 ec_hide_error( 'ec_email_order2' ); 3481 } else { 3482 ec_show_error( 'ec_email_order1' ); 3483 ec_show_error( 'ec_email_order2' ); 3484 } 3485 } 3486 3487 if ( jQuery( document.getElementById( 'ec_shipping_order_error' ) ).length ) { 3488 if ( shipping_info_complete ) { 3489 ec_hide_error( 'ec_shipping_order' ); 3490 } else { 3491 ec_show_error( 'ec_shipping_order' ); 3492 } 3493 } 3494 3495 if ( jQuery( document.getElementById( 'ec_shipping_method_order_error' ) ).length ) { 3496 if ( shipping_method_complete ) { 3497 ec_hide_error( 'ec_shipping_method_order' ); 3498 } else { 3499 ec_show_error( 'ec_shipping_method_order' ); 3500 } 3501 } 3502 3503 if ( billing_info_complete ) { 3504 ec_hide_error( 'ec_billing_order' ); 3505 } else { 3506 ec_show_error( 'ec_billing_order' ); 3507 } 3508 3509 if ( payment_method_complete && terms_complete && email_complete && shipping_info_complete && shipping_method_complete && billing_info_complete && pickup_info_complete ) { 3510 if( !document.getElementById( 'ec_stripe_card_row' ) && !document.getElementById( 'wpec_braintree_dropin' ) ){ 3511 jQuery( document.getElementById( 'ec_cart_submit_order' ) ).hide( ); 3512 jQuery( document.getElementById( 'ec_cart_submit_order_working' ) ).show( ); 3513 ec_hide_error( 'ec_submit_order' ); 3514 if( jQuery( document.getElementById( 'ec_card_number' ) ).length ) 3515 jQuery( document.getElementById( 'ec_card_number' ) ).val( jQuery( document.getElementById( 'ec_card_number' ) ).val( ).replace( /\s+/g, '' ) ); 3516 } 3517 return true; 3518 }else{ 3519 jQuery( document.getElementById( 'ec_cart_submit_order' ) ).show( ); 3520 jQuery( document.getElementById( 'ec_cart_submit_order_working' ) ).hide( ); 3521 ec_show_error( 'ec_submit_order' ); 3522 return false; 3523 } 3524 3525} 3526 3527function ec_validate_submit_invoice( ){ 3528 3529 var payment_method_complete = ec_validate_payment_method( ); 3530 var terms_complete = ec_validate_terms( ); 3531 var billing_complete = ec_validate_address_block( 'ec_cart_billing' ); 3532 3533 if( payment_method_complete && terms_complete && billing_complete ){ 3534 if( !document.getElementById( 'ec_stripe_card_row' ) && !document.getElementById( 'wpec_braintree_dropin' ) ){ 3535 jQuery( document.getElementById( 'ec_cart_submit_order' ) ).hide( ); 3536 jQuery( document.getElementById( 'ec_cart_submit_order_working' ) ).show( ); 3537 ec_hide_error( 'ec_submit_order' ); 3538 if( jQuery( document.getElementById( 'ec_card_number' ) ).length ) 3539 jQuery( document.getElementById( 'ec_card_number' ) ).val( jQuery( document.getElementById( 'ec_card_number' ) ).val( ).replace( /\s+/g, '' ) ); 3540 } 3541 return true; 3542 }else{ 3543 jQuery( document.getElementById( 'ec_cart_submit_order' ) ).show( ); 3544 jQuery( document.getElementById( 'ec_cart_submit_order_working' ) ).hide( ); 3545 ec_show_error( 'ec_submit_order' ); 3546 return false; 3547 } 3548 3549} 3550 3551function ec_validate_submit_subscription( ){ 3552 var login_complete = true; 3553 var billing_complete = ec_validate_address_block( 'ec_cart_billing' ); 3554 var shipping_complete = true; 3555 var email_complete = true; 3556 var create_account_complete = true; 3557 var payment_method_complete = ec_validate_payment_method( ); 3558 var terms_complete = ec_validate_terms( ); 3559 3560 if ( jQuery( document.getElementById( 'ec_user_login_form' ) ).is( ':visible' ) ) { 3561 login_complete = ec_validate_cart_login( ); 3562 } 3563 3564 if ( jQuery( document.getElementById( 'ec_user_contact_form' ) ).is( ':visible' ) ) { 3565 email_complete = ec_validate_email_block( 'ec_contact' ); 3566 } 3567 3568 if ( jQuery( document.getElementById( 'ec_user_contact_form' ) ).is( ':visible' ) ) { 3569 create_account_complete = ec_validate_create_account( 'ec_contact' ); 3570 } 3571 3572 if ( jQuery( document.getElementById( 'ec_shipping_selector' ) ).is( ':checked' ) ) { 3573 shipping_complete = ec_validate_address_block( 'ec_cart_shipping' ); 3574 } 3575 3576 if( login_complete && billing_complete && shipping_complete && email_complete && create_account_complete && payment_method_complete && terms_complete ){ 3577 if( !document.getElementById( 'ec_stripe_card_row' ) && !document.getElementById( 'wpec_braintree_dropin' ) ){ 3578 ec_hide_error( 'ec_checkout' ); 3579 jQuery( document.getElementById( 'ec_cart_submit_order' ) ).hide( ); 3580 jQuery( document.getElementById( 'ec_cart_submit_order_working' ) ).show( ); 3581 } 3582 return true; 3583 }else{ 3584 ec_show_error( 'ec_checkout' ); 3585 return false; 3586 } 3587 3588} 3589 3590function ec_validate_cart_login( ){
3591 3592 var errors = false; 3593 var email = jQuery( document.getElementById( 'ec_cart_login_email' ) ).val( ).trim( ); 3594 var password = jQuery( document.getElementById( 'ec_cart_login_password' ) ).val( ); 3595 3596 if( !ec_validate_email( email ) ){ 3597 errors = true; 3598 ec_show_error( 'ec_cart_login_email' ); 3599 }else{ 3600 ec_hide_error( 'ec_cart_login_email' ); 3601 } 3602 3603 if( !ec_validate_text( password ) ){ 3604 errors = true; 3605 ec_show_error( 'ec_cart_login_password' ); 3606 }else{ 3607 ec_hide_error( 'ec_cart_login_password' ); 3608 } 3609 3610 if( jQuery( document.getElementById( 'ec_account_login_recaptcha' ) ).length ){ 3611 var recaptcha_response = jQuery( document.getElementById( 'ec_grecaptcha_response_login' ) ).val( ); 3612 if( !recaptcha_response.length ){ 3613 jQuery( '#ec_account_login_recaptcha > div' ).css( 'border', '1px solid red' ); 3614 errors = true; 3615 }else{ 3616 jQuery( '#ec_account_login_recaptcha > div' ).css( 'border', 'none' ); 3617 } 3618 } 3619 3620 return ( !errors ); 3621 3622} 3623 3624function ec_validate_address_block( prefix ){ 3625 3626 var errors = false; 3627 var country = jQuery( document.getElementById( '' + prefix + '_country' ) ).val( ); 3628 var first_name = jQuery( document.getElementById( '' + prefix + '_first_name' ) ).val( ); 3629 var last_name = jQuery( document.getElementById( '' + prefix + '_last_name' ) ).val( ); 3630 var city = jQuery( document.getElementById( '' + prefix + '_city' ) ).val( ); 3631 var address = jQuery( document.getElementById( '' + prefix + '_address' ) ).val( ); 3632 if( jQuery( document.getElementById( '' + prefix + '_state_' + country ) ) ) 3633 var state = jQuery( document.getElementById( '' + prefix + '_state_' + country ) ).val( ); 3634 else 3635 var state = jQuery( document.getElementById( '' + prefix + '_state' ) ).val( ); 3636 var zip = jQuery( document.getElementById( '' + prefix + '_zip' ) ).val( ); 3637 var phone = jQuery( document.getElementById( '' + prefix + '_phone' ) ).val( ); 3638 var company_name = ( jQuery( document.getElementById( '' + prefix + '_company_name' ) ).length ) ? jQuery( document.getElementById( '' + prefix + '_company_name' ) ).val( ) : ''; 3639 3640 if( !ec_validate_select( country ) ){ 3641 errors = true; 3642 ec_show_error( prefix + '_country' ); 3643 }else{ 3644 ec_hide_error( prefix + '_country' ); 3645 } 3646 3647 if( !ec_validate_text( first_name ) ){ 3648 errors = true; 3649 ec_show_error( prefix + '_first_name' ); 3650 }else{ 3651 ec_hide_error( prefix + '_first_name' ); 3652 } 3653 3654 if( !ec_validate_text( last_name ) ){ 3655 errors = true; 3656 ec_show_error( prefix + '_last_name' ); 3657 }else{ 3658 ec_hide_error( prefix + '_last_name' ); 3659 } 3660 3661 if( !ec_validate_text( city ) ){ 3662 errors = true; 3663 ec_show_error( prefix + '_city' ); 3664 }else{ 3665 ec_hide_error( prefix + '_city' ); 3666 } 3667 3668 if( !ec_validate_text( address ) ){ 3669 errors = true; 3670 ec_show_error( prefix + '_address' ); 3671 }else{ 3672 ec_hide_error( prefix + '_address' ); 3673 } 3674 3675 if( jQuery( document.getElementById( '' + prefix + '_state_' + country ) ).length ){ 3676 if( !ec_validate_select( state ) ){ 3677 errors = true; 3678 ec_show_error( prefix + '_state' ); 3679 }else{ 3680 ec_hide_error( prefix + '_state' ); 3681 } 3682 }else{ 3683 ec_hide_error( prefix + '_state' ); 3684 } 3685 3686 if( !ec_validate_zip_code( zip, country ) ){ 3687 errors = true; 3688 ec_show_error( prefix + '_zip' ); 3689 }else{ 3690 ec_hide_error( prefix + '_zip' ); 3691 } 3692 3693 if( jQuery( document.getElementById( '' + prefix + '_phone_error' ) ).length ){ 3694 if( jQuery( document.getElementById( '' + prefix + '_phone' ) ).length && !ec_validate_text( phone ) ){ 3695 errors = true; 3696 ec_show_error( prefix + '_phone' ); 3697 }else{ 3698 ec_hide_error( prefix + '_phone' ); 3699 } 3700 } 3701 3702 if( jQuery( document.getElementById( '' + prefix + '_company_name_error' ) ).length ){ 3703 if( jQuery( document.getElementById( '' + prefix + '_company_name' ) ).length && !ec_validate_text( company_name ) ){ 3704 errors = true; 3705 ec_show_error( prefix + '_company_name' ); 3706 }else{ 3707 ec_hide_error( prefix + '_company_name' ); 3708 } 3709 } 3710 3711 return ( !errors ); 3712 3713} 3714 3715function ec_validate_email_block( prefix ){ 3716 3717 var errors = false; 3718 var email = jQuery( document.getElementById( '' + prefix + '_email' ) ).val( ).trim(); 3719 var retype_email = ""; 3720 if( jQuery( document.getElementById( '' + prefix + '_email_retype' ) ).length ) { 3721 retype_email = jQuery( document.getElementById( '' + prefix + '_email_retype' ) ).val( ).trim(); 3722 } else if ( jQuery( document.getElementById( '' + prefix + '_retype_email' ) ).length ) { 3723 retype_email = jQuery( document.getElementById( '' + prefix + '_retype_email' ) ).val( ).trim(); 3724 } else { 3725 retype_email = email; 3726 } 3727 3728 if( !ec_validate_email( email ) ){
3729 errors = true; 3730 ec_show_error( prefix + '_email' ); 3731 if ( jQuery( document.getElementById( 'ec_create_account_email_error' ) ).length ) { 3732 jQuery( document.getElementById( 'ec_create_account_email_error' ) ).hide(); 3733 } 3734 }else{ 3735 ec_hide_error( prefix + '_email' ); 3736 } 3737 3738 if( !ec_validate_match( email, retype_email) ){ 3739 errors = true; 3740 ec_show_error( prefix + '_email_retype' ); 3741 }else{ 3742 ec_hide_error( prefix + '_email_retype' ); 3743 } 3744 3745 return ( !errors ); 3746 3747} 3748 3749function ec_validate_create_account( prefix ){ 3750 3751 var errors = false; 3752 var first_name = ( jQuery( document.getElementById( '' + prefix + '_first_name' ) ).length ) ? jQuery( document.getElementById( '' + prefix + '_first_name' ) ).val() : ''; 3753 var last_name = ( jQuery( document.getElementById( '' + prefix + '_last_name' ) ).length ) ? jQuery( document.getElementById( '' + prefix + '_last_name' ) ).val() : ''; 3754 var password = jQuery( document.getElementById( '' + prefix + '_password' ) ).val( ); 3755 var retype_password = ''; 3756 3757 if ( jQuery( document.getElementById( '' + prefix + '_password_retype' ) ).length ) { 3758 retype_password = jQuery( document.getElementById( '' + prefix + '_password_retype' ) ).val( ); 3759 } else { 3760 retype_password = password; 3761 } 3762 3763 if( jQuery( document.getElementById( '' + prefix + '_first_name' ) ).length && ! ec_validate_text( first_name ) ){ 3764 errors = true; 3765 ec_show_error( prefix + '_first_name' ); 3766 }else{ 3767 ec_hide_error( prefix + '_first_name' ); 3768 } 3769 3770 if( jQuery( document.getElementById( '' + prefix + '_last_name' ) ).length && ! ec_validate_text( last_name ) ){ 3771 errors = true; 3772 ec_show_error( prefix + '_last_name' ); 3773 }else{ 3774 ec_hide_error( prefix + '_last_name' ); 3775 } 3776 3777 if ( ! ec_validate_password( password, retype_password ) ) { 3778 errors = true; 3779 ec_show_error( prefix + '_password' ); 3780 } else { 3781 ec_hide_error( prefix + '_password' ); 3782 } 3783 3784 if( jQuery( document.getElementById( prefix + '_password_retype' ) ).length && ! ec_validate_match( password, retype_password ) ){ 3785 errors = true; 3786 ec_show_error( prefix + '_password_retype' ); 3787 }else{ 3788 ec_hide_error( prefix + '_password_retype' ); 3789 } 3790 3791 return ( !errors ); 3792 3793} 3794 3795function ec_validate_terms_section() { 3796 var errors = false; 3797 if ( jQuery( document.getElementById( 'ec_terms_agree' ) ).length ) { 3798 if ( ! ec_validate_terms() ) { 3799 errors = true; 3800 } 3801 } 3802 return ( ! errors ); 3803} 3804 3805function ec_validate_payment_method( ){ 3806 3807 var errors = false; 3808 var payment_method = "credit_card"; 3809 if( jQuery( 'input:radio[name=ec_cart_payment_selection]:checked' ).length ){ 3810 ec_hide_error( 'ec_payment_method' ); 3811 payment_method = jQuery( 'input:radio[name=ec_cart_payment_selection]:checked' ).val( ); 3812 }else if( jQuery( 'input:radio[name=ec_cart_payment_selection]' ).length ){ 3813 ec_show_error( 'ec_payment_method' ); 3814 return false; 3815 }else{ // free order or no payment methods 3816 ec_hide_error( 'ec_payment_method' ); 3817 return true; 3818 } 3819 3820 var card_holder_name = "-1"; 3821 if( document.getElementById( 'ec_card_holder_name' ) ){ 3822 card_holder_name = jQuery( document.getElementById( 'ec_card_holder_name' ) ).val( ); 3823 } 3824 3825 if( payment_method == "affirm" ){ 3826 ec_checkout_with_affirm( ); 3827 ec_hide_error( 'ec_submit_order' ); 3828 return false; 3829 3830 }else if( payment_method == "credit_card" && jQuery( document.getElementById( 'wp-easycart-square-card-container' ) ).length ) { 3831 return true; 3832 3833 }else if( payment_method == "credit_card" && ( document.getElementById( 'ec_stripe_card_row' ) || document.getElementById( 'wpec_braintree_dropin' ) ) ){ 3834 return true; 3835 3836 }else if( payment_method == "credit_card" && document.getElementById( 'cardpointe_token' ) ){ 3837 if( jQuery( document.getElementById( 'cardpointe_token' ) ).val( ) == '' ){ 3838 return false; 3839 }else{ 3840 return true; 3841 } 3842 3843 }else if( payment_method == "credit_card" ){ 3844 3845 var cardType = jQuery.payment.cardType( jQuery( document.getElementById( 'ec_card_number' ) ).val( ) ); 3846 3847 if( card_holder_name != "-1" && card_holder_name == "" ){ 3848 errors = true; 3849 ec_show_error( 'ec_card_holder_name' ); 3850 }else{ 3851 ec_hide_error( 'ec_card_holder_name' ); 3852 } 3853 3854 if( !jQuery.payment.validateCardNumber( jQuery( document.getElementById( 'ec_card_number' ) ).val( ) ) ){ 3855 errors = true; 3856 ec_show_error( 'ec_card_number' ); 3857 }else{ 3858 ec_hide_error( 'ec_card_number' ); 3859 } 3860 3861 if( !jQuery.payment.validateCardExpiry( jQuery( document.getElementById( 'ec_cc_expiration' ) ).payment( 'cardExpiryVal' ) ) ){ 3862 errors = true; 3863 ec_show_error( 'ec_expiration_date' ); 3864 }else{ 3865 ec_hide_error( 'ec_expiration_date' ); 3866 } 3867 3868 if( !jQuery.payment.validateCardCVC( jQuery( document.getElementById( 'ec_security_code' ) ).val( ), cardType) ){ 3869 errors = true; 3870 ec_show_error( 'ec_security_code' ); 3871 }else{ 3872 ec_hide_error( 'ec_security_code' ); 3873 } 3874 3875 } 3876 3877 return ( !errors ); 3878 3879} 3880 3881function ec_validate_terms( ){ 3882 3883 var errors = false; 3884 3885 if( jQuery( document.getElementById( 'ec_terms_agree' ) ).is( ':checked' ) || jQuery( document.getElementById( 'ec_terms_agree' ) ).val( ) == '2' ){ 3886 ec_hide_error( 'ec_terms' ); 3887 }else{ 3888 errors = true; 3889 ec_show_error( 'ec_terms' ); 3890 } 3891 3892 return ( !errors ); 3893 3894} 3895 3896function ec_validate_email( email ){ 3897 3898 return /^([^\x00-\x20\x22\x28\x29\x2c\x2e\x3a-\x3c\x3e\x40\x5b-\x5
3898d\x7f-\xff]+|\x22([^\x0d\x22\x5c\x80-\xff]|\x5c[\x00-\x7f])*\x22)(\x2e([^\x00-\x20\x22\x28\x29\x2c\x2e\x3a-\x3c\x3e\x40\x5b-\x5d\x7f-\xff]+|\x22([^\x0d\x22\x5c\x80-\xff]|\x5c[\x00-\x7f])*\x22))*\x40([^\x00-\x20\x22\x28\x29\x2c\x2e\x3a-\x3c\x3e\x40\x5b-\x5d\x7f-\xff]+|\x5b([^\x0d\x5b-\x5d\x80-\xff]|\x5c[\x00-\x7f])*\x5d)(\x2e([^\x00-\x20\x22\x28\x29\x2c\x2e\x3a-\x3c\x3e\x40\x5b-\x5d\x7f-\xff]+|\x5b([^\x0d\x5b-\x5d\x80-\xff]|\x5c[\x00-\x7f])*\x5d))*$/.test( email ); 3899 3900} 3901 3902function ec_validate_password( pw ){ 3903 3904 if( pw && pw.length > 5 ) 3905 return true; 3906 else 3907 return false; 3908 3909} 3910 3911function ec_validate_text( str ){ 3912 3913 if( str && str.length > 0 ) 3914 return true; 3915 else 3916 return false; 3917 3918} 3919 3920function ec_validate_select( val ){ 3921 3922 if( val && val != 0 ) 3923 return true; 3924 else 3925 return false; 3926 3927} 3928 3929function ec_validate_match( val1, val2 ){ 3930 3931 if( val1 == val2 ) 3932 return true; 3933 else 3934 return false; 3935 3936} 3937 3938function ec_validate_zip_code( zip, country ){ 3939 3940 zip = zip.trim( ); 3941 3942 if( country == "US" ) 3943 return /(^\d{5}$)|(^\d{5}-\d{4}$)/.test( zip ); 3944 else if( country == "AU" ) 3945 return /^([0-9]{4})$/.test( zip ); 3946 else if( country == "CA" ){ 3947 var regex = new RegExp( /^[ABCEGHJKLMNPRSTVXY]\d[ABCEGHJKLMNPRSTVWXYZ]( )?\d[ABCEGHJKLMNPRSTVWXYZ]\d$/i ); 3948 return regex.test( zip ); 3949 }else if( country == "GB" ){ 3950 var postcode = zip.replace(/\s/g, ""); 3951 var regex = /^(([A-Za-z]{2}[0-9][A-Za-z] ?[0-9][A-Za-z]{2})|([A-Za-z][0-9][A-Za-z] ?[0-9][A-Za-z]{2})|([A-Za-z][0-9] ?[0-9][A-Za-z]{2})|([A-Za-z][0-9]{2} ?[0-9][A-Za-z]{2})|([A-Za-z]{2}[0-9] ?[0-9][A-Za-z]{2})|([A-Za-z]{2}[0-9]{2} ?[0-9][A-Za-z]{2}))$/i; 3952 return regex.test( postcode ); 3953 }else 3954 return ec_validate_text( zip ); 3955 3956} 3957 3958function ec_is_state_required( country ){ 3959 if( country == "AU" || country == "BR" || country == "CA" || country == "CN" || country == "GB" || country == "IN" || country == "JP" || country == "US" ) 3960 return true; 3961 else 3962 return false; 3963} 3964 3965function ec_get_card_type( card_number ){ 3966 3967 var num = card_number; 3968 3969 num = num.replace(/[^\d]/g,''); 3970 3971 if( num.match( /^5[1-5]\d{14}$/ ) ) return "mastercard"; 3972 else if( num.match( /^4\d{15}/ ) || num.match( /^4\d{12}/ ) ) return "visa"; 3973 else if( num.match( /(^3[47])((\d{11}$)|(\d{13}$))/ ) ) return "amex"; 3974 else if( num.match( /^6(?:011\d{12}|5\d{14}|4[4-9]\d{13}|22(?:1(?:2[6-9]|[3-9]\d)|[2-8]\d{2}|9(?:[01]\d|2[0-5]))\d{10})$/ ) ) 3975 return "discover"; 3976 else if( num.match( /^(?:5[0678]\d\d|6304|6390|67\d\d)\d{8,15}$/ ) ) return "maestro"; 3977 else if( num.match( /(^(352)[8-9](\d{11}$|\d{12}$))|(^(35)[3-8](\d{12}$|\d{13}$))/ ) ) return "jcb"; 3978 else if( num.match( /(^(30)[0-5]\d{11}$)|(^(36)\d{12}$)|(^(38[0-8])\d{11}$)/ ) ) return "diners"; 3979 else return "all"; 3980 3981} 3982 3983function ec_validate_credit_card( card_number ){ 3984 3985 var card_type = ec_get_card_type( card_number ); 3986 3987 if( card_type == "visa" || card_type == "delta" || card_type == "uke" ){ 3988 if( /^4[0-9]{12}(?:[0-9]{3}|[0-9]{6})?$/.test( card_number ) ) return true; 3989 else return false; 3990 3991 }else if( card_type == "discover" ){ 3992 if( /^6(?:011\d{12}|5\d{14}|4[4-9]\d{13}|22(?:1(?:2[6-9]|[3-9]\d)|[2-8]\d{2}|9(?:[01]\d|2[0-5]))\d{10})$/.test( card_number ) ) 3993 return true; 3994 else return false; 3995 3996 }else if( card_type == "mastercard" || card_type == "mcdebit" ){ 3997 if( /^5[1-5]\d{14}$/.test( card_number ) ) return true; 3998 else return false; 3999 4000 }else if( card_type == "amex" ){ 4001 if( /^3[47][0-9]{13}$/.test( card_number ) ) return true; 4002 else return false; 4003 4004 }else if( card_type == "diners" ){ 4005 if( /^3(?:0[0-5]|[68][0-9])[0-9]{11}$/.test( card_number ) ) return true; 4006 else return false; 4007 4008 }else if( card_type == "jcb" ){ 4009 if( /^(?:2131|1800|35\d{3})\d{11}$/.test( card_number ) ) return true; 4010 else return false; 4011 4012 }else if( card_type == "maestro" ){ 4013 if( /(^(5[0678]\d{11,18}$))|(^(6[^0357])\d{11,18}$)|(^(3)\d{13,20}$)/.test( card_number ) ) return true; 4014 else return false; 4015 } 4016} 4017 4018function ec_validate_security_code( security_code ){ 4019 4020 if( /^[0-9]{3,4}$/.test( security_code ) ) return true; 4021 else return false; 4022 4023} 4024 4025function ec_show_error( error_field ){
4026 jQuery( document.getElementById( '' + error_field + '_error' ) ).show( ); 4027} 4028 4029function ec_hide_error( error_field ){ 4030 jQuery( document.getElementById( '' + error_field + '_error' ) ).hide( ); 4031} 4032 4033function ec_cart_subscription_shipping_method_change( shipping_method, price, nonce ){ 4034 jQuery( document.getElementById( 'ec_cart_subscription_shipping_methods_loader' ) ).show(); 4035 4036 var ship_express = 0; 4037 if ( jQuery( document.getElementById( 'ec_cart_ship_express' ) ).length ) { 4038 if ( jQuery( document.getElementById( 'ec_cart_ship_express' ) ).is( ':checked' ) ) { 4039 ship_express = 1; 4040 } 4041 } 4042 4043 if ( 'shipexpress' == shipping_method ) { 4044 shipping_method = 'standard'; 4045 if ( jQuery( document.getElementById( 'ec_cart_shipping_method_free' ) ).length ) { 4046 jQuery( document.getElementById( 'ec_cart_shipping_method_free' ) ).prop( 'checked', false ); 4047 } 4048 jQuery( document.getElementById( 'ec_cart_shipping_method' ) ).prop( 'checked', 'checked' ); 4049 4050 } else if( 'free' == shipping_method ) { 4051 if ( jQuery( document.getElementById( 'ec_cart_ship_express' ) ).length ) { 4052 jQuery( document.getElementById( 'ec_cart_ship_express' ) ).prop( 'checked', false ); 4053 } 4054 } 4055 4056 var data = { 4057 action: 'ec_ajax_update_subscription_shipping_method', 4058 product_id: jQuery( document.getElementById( 'product_id' ) ).val(), 4059 shipping_method: shipping_method, 4060 ship_express: ship_express, 4061 nonce: nonce 4062 }; 4063 4064 jQuery.ajax({ 4065 url: wpeasycart_ajax_object.ajax_url, 4066 type: 'post', 4067 data: data, 4068 cache: false, 4069 success: function( response ){ 4070 var data_arr = JSON.parse( response ); 4071 wpeasycart_subscription_cart_update_totals( data_arr ); 4072 jQuery( document.getElementById( 'ec_cart_subscription_shipping_methods_loader' ) ).hide(); 4073 } 4074 } ); 4075 4076} 4077 4078function ec_cart_shipping_method_change( shipping_method, price, nonce ){ 4079 jQuery( '.ec_cart_shipping_method_row' ).removeClass( 'ec_method_selected' ); 4080 jQuery( '.ec_cart_shipping_method_row > input[value="' + shipping_method + '"]' ).parent().addClass( 'ec_method_selected' ); 4081 jQuery( '.ec_cart_price_row.ec_cart_price_row_shipping_total, .ec_cart_price_row.ec_order_total' ).addClass( 'ec_cart_price_row_loading' ); 4082 4083 var ship_express = 0; 4084 if ( jQuery( document.getElementById( 'ec_cart_ship_express' ) ).length ) { 4085 if ( jQuery( document.getElementById( 'ec_cart_ship_express' ) ).is( ':checked' ) ) { 4086 ship_express = 1; 4087 } 4088 } 4089 4090 if ( 'shipexpress' == shipping_method ) { 4091 shipping_method = 'standard'; 4092 if ( jQuery( document.getElementById( 'ec_cart_shipping_method_free' ) ).length ) { 4093 jQuery( document.getElementById( 'ec_cart_shipping_method_free' ) ).prop( 'checked', false ); 4094 } 4095 jQuery( document.getElementById( 'ec_cart_shipping_method' ) ).prop( 'checked', 'checked' ); 4096 4097 } else if( 'free' == shipping_method ) { 4098 if ( jQuery( document.getElementById( 'ec_cart_ship_express' ) ).length ) { 4099 jQuery( document.getElementById( 'ec_cart_ship_express' ) ).prop( 'checked', false ); 4100 } 4101 } 4102 4103 var data = { 4104 action: 'ec_ajax_update_shipping_method', 4105 shipping_method: shipping_method, 4106 ship_express: ship_express, 4107 nonce: nonce 4108 }; 4109 4110 jQuery.ajax({ 4111 url: wpeasycart_ajax_object.ajax_url, 4112 type: 'post', 4113 data: data, 4114 cache: false, 4115 success: function( data ){ 4116 var response_obj = JSON.parse( data ); 4117 ec_update_cart( response_obj ); 4118 jQuery( '.ec_cart_price_row.ec_cart_price_row_shipping_total, .ec_cart_price_row.ec_order_total' ).removeClass( 'ec_cart_price_row_loading' ); 4119 } 4120 } ); 4121 4122} 4123 4124jQuery( document ).ready( function( $ ){ 4125 $( ".ec_menu_vertical" ).accordion({ 4126 accordion:true, 4127 speed: 500, 4128 closedSign: '[+]', 4129 openedSign: '[-]' 4130 }); 4131}); 4132(function(jQuery){ 4133 jQuery.fn.extend({ 4134 accordion: function(options) { 4135 4136 var defaults = { 4137 accordion: 'true', 4138 speed: 300, 4139 closedSign: '[+]', 4140 openedSign: '[-]' 4141 }; 4142 var opts = jQuery.extend(defaults, options); 4143 var jQuerythis = jQuery(this); 4144 jQuerythis.find("li").each(function() { 4145 if(jQuery(this).find("ul").size() != 0){ 4146 jQuery(this).find("a:first").append("<span>"+ opts.closedSign +"</span>"); 4147 if(jQuery(this).find("a:first").attr('href') == "#"){ 4148 jQuery(this).find("a:first").click(function(){return false;}); 4149 } 4150 } 4151 }); 4152 jQuerythis.find("li.active").each(function() { 4153 jQuery(this).parents("ul").slideDown(opts.speed); 4154 jQuery(this).parents("ul").parent("li").find("span:first").html(opts.openedSign); 4155 }); 4156 jQuerythis.find("li a").click(function() { 4157 if(jQuery(this).parent().find("ul").size() != 0){ 4158 if(opts.accordion){ 4159 if(!jQuery(this).parent().find("ul").is(':visible')){ 4160 parents = jQuery(this).parent().parents("ul"); 4161 visible = jQuerythis.find("ul:visible"); 4162 visible.each(function(visibleIndex){ 4163 var close = true; 4164 parents.each(function(parentIndex){ 4165 if(parents[parentIndex] == visible[visibleIndex]){ 4166 close = false; 4167 return false; 4168 } 4169 });
4170 if(close){ 4171 if(jQuery(this).parent().find("ul") != visible[visibleIndex]){ 4172 jQuery(visible[visibleIndex]).slideUp(opts.speed, function(){ 4173 jQuery(this).parent("li").find("span:first").html(opts.closedSign); 4174 }); 4175 4176 } 4177 } 4178 }); 4179 } 4180 } 4181 if(jQuery(this).parent().find("ul:first").is(":visible")){ 4182 jQuery(this).parent().find("ul:first").slideUp(opts.speed, function(){ 4183 jQuery(this).parent("li").find("span:first").delay(opts.speed).html(opts.closedSign); 4184 }); 4185 4186 4187 }else{ 4188 jQuery(this).parent().find("ul:first").slideDown(opts.speed, function(){ 4189 jQuery(this).parent("li").find("span:first").delay(opts.speed).html(opts.openedSign); 4190 }); 4191 } 4192 } 4193 }); 4194 } 4195}); 4196})(jQuery); 4197 4198function ec_cart_widget_click( ){ 4199 if( !jQuery('.ec_cart_widget_minicart_wrap').is(':visible') ) 4200 jQuery('.ec_cart_widget_minicart_wrap').fadeIn( 200 ); 4201 else 4202 jQuery('.ec_cart_widget_minicart_wrap').fadeOut( 100 ); 4203} 4204 4205function ec_cart_widget_mouseover( ){ 4206 if( !jQuery('.ec_cart_widget_minicart_wrap').is(':visible') ){ 4207 jQuery('.ec_cart_widget_minicart_wrap').fadeIn( 200 ); 4208 jQuery('.ec_cart_widget_minicart_bg').css( "display", "block" ); 4209 } 4210} 4211 4212function ec_cart_widget_mouseout( ){ 4213 if( jQuery('.ec_cart_widget_minicart_wrap').is(':visible') ) { 4214 jQuery('.ec_cart_widget_minicart_wrap').fadeOut( 100 ); 4215 jQuery('.ec_cart_widget_minicart_bg').css( "display", "none" ); 4216 } 4217} 4218 4219var wpeasycart_last_search = ""; 4220function ec_live_search_update( nonce ){ 4221 4222 var code = event.which || event.keyCode; 4223 var search_val = jQuery( '.ec_search_input' ).val( ); 4224 4225 if( code != 16 && code != 17 && code != 18 && code != 20 && code != 37 && code != 38 && code != 39 && code != 40 && wpeasycart_last_search != search_val ){ 4226 4227 wpeasycart_last_search = search_val; 4228 4229 var data = { 4230 action: 'ec_ajax_live_search', 4231 search_val: search_val, 4232 nonce: nonce 4233 }; 4234 4235 jQuery.ajax( { 4236 url: wpeasycart_ajax_object.ajax_url, 4237 type: 'post', 4238 data: data, 4239 cache: false, 4240 success: function( data ){ 4241 if( wpeasycart_last_search == search_val ){ 4242 data = JSON.parse( data ); 4243 jQuery( document.getElementById( 'ec_search_suggestions' ) ).empty( ); 4244 for( var i=0; i<data.length; i++ ){ 4245 jQuery( document.getElementById( 'ec_search_suggestions' ) ).append( "<option value='" + data[i].title + "'>" ); 4246 } 4247 } 4248 } 4249 } ); 4250 } 4251} 4252 4253function ec_account_forgot_password_button_click() { 4254 var errors = false; 4255 var email = jQuery( document.getElementById( 'ec_account_forgot_password_email' ) ).val(); 4256 if ( ! ec_validate_email( email ) ) { 4257 errors = true; 4258 ec_show_error( 'ec_account_forgot_password_email' ); 4259 } else { 4260 ec_hide_error( 'ec_account_forgot_password_email' ); 4261 } 4262 return( ! errors ); 4263} 4264 4265function ec_account_register_button_click2() { 4266 var top_half = ec_account_register_button_click( ); 4267 var bottom_half = true; 4268 4269 if( jQuery( document.getElementById( 'ec_account_billing_information_country' ) ).length ) 4270 bottom_half = ec_account_billing_information_update_click( ); 4271 4272 var extra_notes_validated = ec_account_register_validate_notes( ); 4273 4274 var recaptcha_validated = true; 4275 if( jQuery( document.getElementById( 'ec_account_register_recaptcha' ) ).length ){ 4276 var recaptcha_response = jQuery( document.getElementById( 'ec_grecaptcha_response_register' ) ).val( ); 4277 if( !recaptcha_response.length ){ 4278 jQuery( '#ec_account_register_recaptcha > div' ).css( 'border', '1px solid red' ); 4279 recaptcha_validated = false; 4280 }else{ 4281 jQuery( '#ec_account_register_recaptcha > div' ).css( 'border', 'none' ); 4282 } 4283 } 4284 4285 if( top_half && bottom_half && extra_notes_validated && recaptcha_validated ){ 4286 return true; 4287 }else{ 4288 return false; 4289 } 4290} 4291 4292function ec_account_register_button_click( ){ 4293 var email_validated = ec_validate_email_block( 'ec_account_register' ); 4294 var contact_validated = ec_validate_create_account( 'ec_account_register' ); 4295 var terms_validated = ec_validate_terms_section(); 4296 4297 var recaptcha_validated = true; 4298 if( jQuery( document.getElementById( 'ec_account_register_recaptcha' ) ).length ){ 4299 var recaptcha_response = jQuery( document.getElementById( 'ec_grecaptcha_response_register' ) ).val( ); 4300 if( !recaptcha_response.length ){ 4301 jQuery( '#ec_account_register_recaptcha > div' ).css( 'border', '1px solid red' ); 4302 recaptcha_validated = false; 4303 }else{ 4304 jQuery( '#ec_account_register_recaptcha > div' ).css( 'border', 'none' ); 4305 } 4306 } 4307 4308 if( email_validated && contact_validated && terms_validated && recaptcha_validated ) 4309 return true; 4310 else
4311 return false; 4312 4313} 4314 4315function ec_account_billing_information_update_click( ){ 4316 var address_validated = ec_validate_address_block( 'ec_account_billing_information' ); 4317 4318 if( address_validated ) 4319 return true; 4320 else 4321 return false; 4322 4323} 4324 4325function ec_account_shipping_information_update_click( ){ 4326 var address_validated = ec_validate_address_block( 'ec_account_shipping_information' ); 4327 4328 if( address_validated ) 4329 return true; 4330 else 4331 return false; 4332 4333} 4334 4335function ec_account_personal_information_update_click( ){ 4336 4337 var errors = false; 4338 var email = jQuery( document.getElementById( 'ec_account_personal_information_email' ) ).val( ); 4339 4340 if( jQuery( document.getElementById( 'ec_account_personal_information_first_name' ) ).length && !ec_validate_text( jQuery( document.getElementById( 'ec_account_personal_information_first_name' ) ).val( ) ) ){ 4341 errors = true; 4342 ec_show_error( 'ec_account_personal_information_first_name' ); 4343 }else{ 4344 ec_hide_error( 'ec_account_personal_information_first_name' ); 4345 } 4346 4347 if( jQuery( document.getElementById( 'ec_account_personal_information_last_name' ) ).length && !ec_validate_text( jQuery( document.getElementById( 'ec_account_personal_information_last_name' ) ).val( ) ) ){ 4348 errors = true; 4349 ec_show_error( 'ec_account_personal_information_last_name' ); 4350 }else{ 4351 ec_hide_error( 'ec_account_personal_information_last_name' ); 4352 } 4353 4354 if( !ec_validate_email( email ) ){ 4355 errors = true; 4356 ec_show_error( 'ec_account_personal_information_email' ); 4357 }else{ 4358 ec_hide_error( 'ec_account_personal_information_email' ); 4359 } 4360 4361 return( !errors ); 4362} 4363 4364function ec_account_password_button_click( ){ 4365 4366 var errors = false; 4367 var current_password = jQuery( document.getElementById( 'ec_account_password_current_password' ) ).val( ); 4368 var new_password = jQuery( document.getElementById( 'ec_account_password_new_password' ) ).val( ); 4369 var retype_password = jQuery( document.getElementById( 'ec_account_password_retype_new_password' ) ).val( ); 4370 4371 if( !ec_validate_password( current_password ) ){ 4372 errors = true; 4373 ec_show_error( 'ec_account_password_current_password' ); 4374 }else{ 4375 ec_hide_error( 'ec_account_password_current_password' ); 4376 } 4377 4378 if( !ec_validate_password( new_password ) ){ 4379 errors = true; 4380 ec_show_error( 'ec_account_password_new_password' ); 4381 }else{ 4382 ec_hide_error( 'ec_account_password_new_password' ); 4383 } 4384 4385 if( !ec_validate_match( new_password, retype_password ) ){ 4386 errors = true; 4387 ec_show_error( 'ec_account_password_retype_new_password' ); 4388 }else{ 4389 ec_hide_error( 'ec_account_password_retype_new_password' ); 4390 } 4391 4392 return( !errors ); 4393 4394} 4395 4396function ec_account_register_validate_notes( ){ 4397 if( !jQuery( document.getElementById( 'ec_account_register_user_notes' ) ).length || ( jQuery( document.getElementById( 'ec_account_register_user_notes' ) ).length && jQuery( document.getElementById( 'ec_account_register_user_notes' ) ).val( ) != "" ) ){ 4398 ec_hide_error( 'ec_account_register_user_notes' ); 4399 return true; 4400 }else{ 4401 ec_show_error( 'ec_account_register_user_notes' ); 4402 return false; 4403 } 4404} 4405 4406function ec_account_login_button_click( ){ 4407 4408 var errors = false; 4409 var email = jQuery( document.getElementById( 'ec_account_login_email' ) ).val( ); 4410 var password = jQuery( document.getElementById( 'ec_account_login_password' ) ).val( ); 4411 4412 if( !ec_validate_email( email ) ){ 4413 errors = true; 4414 ec_show_error( 'ec_account_login_email' ); 4415 }else{ 4416 ec_hide_error( 'ec_account_login_email' ); 4417 } 4418 4419 if( !ec_validate_text( password ) ){ 4420 errors = true; 4421 ec_show_error( 'ec_account_login_password' ); 4422 }else{ 4423 ec_hide_error( 'ec_account_login_password' ); 4424 } 4425 4426 if( jQuery( document.getElementById( 'ec_account_login_recaptcha' ) ).length ){ 4427 var recaptcha_response = jQuery( document.getElementById( 'ec_grecaptcha_response_login' ) ).val( ); 4428 if( !recaptcha_response.length ){ 4429 jQuery( '#ec_account_login_recaptcha > div' ).css( 'border', '1px solid red' ); 4430 errors = true; 4431 }else{ 4432 jQuery( '#ec_account_login_recaptcha > div' ).css( 'border', 'none' ); 4433 } 4434 } 4435 4436 return ( !errors ); 4437 4438} 4439 4440function ec_account_login_widget_button_click( ){ 4441 4442 var errors = false; 4443 var email = jQuery( document.getElementById( 'ec_account_login_widget_email' ) ).val( ); 4444 var password = jQuery( document.getElementById( 'ec_account_login_widget_password' ) ).val( ); 4445 4446 if( !ec_validate_email( email ) ){
4447 errors = true; 4448 ec_show_error( 'ec_account_login_widget_email' ); 4449 }else{ 4450 ec_hide_error( 'ec_account_login_widget_email' ); 4451 } 4452 4453 if( !ec_validate_text( password ) ){ 4454 errors = true; 4455 ec_show_error( 'ec_account_login_widget_password' ); 4456 }else{ 4457 ec_hide_error( 'ec_account_login_widget_password' ); 4458 } 4459 4460 if( jQuery( document.getElementById( 'ec_account_login_widget_recaptcha' ) ).length ){ 4461 var recaptcha_response = jQuery( document.getElementById( 'ec_grecaptcha_response_login_widget' ) ).val( ); 4462 if( ! recaptcha_response.length ){ 4463 jQuery( '#ec_account_login_widget_recaptcha > div' ).css( 'border', '1px solid red' ); 4464 errors = true; 4465 }else{ 4466 jQuery( '#ec_account_login_widget_recaptcha > div' ).css( 'border', 'none' ); 4467 } 4468 } 4469 4470 return ( !errors ); 4471 4472} 4473 4474function ec_close_popup_newsletter( nonce ){ 4475 4476 jQuery( '.ec_newsletter_container' ).fadeOut( 'slow' ); 4477 4478 var data = { 4479 action: 'ec_ajax_close_newsletter', 4480 nonce: nonce 4481 }; 4482 4483 jQuery.ajax( { 4484 url: wpeasycart_ajax_object.ajax_url, 4485 type: 'post', 4486 data: data, 4487 cache: false 4488 } ); 4489} 4490 4491function ec_submit_newsletter_signup( nonce ){ 4492 4493 jQuery( '.ec_newsletter_pre_submit' ).hide( ); 4494 jQuery( '.ec_newsletter_post_submit' ).show( ); 4495 4496 var email_address = jQuery( document.getElementById( 'ec_newsletter_email' ) ).val( ); 4497 var newsletter_name = ""; 4498 if( document.getElementById( 'ec_newsletter_name' ) ) 4499 newsletter_name = jQuery( document.getElementById( 'ec_newsletter_name' ) ).val( ); 4500 4501 var data = { 4502 action: 'ec_ajax_submit_newsletter_signup', 4503 email_address: email_address, 4504 newsletter_name: newsletter_name, 4505 nonce: nonce 4506 }; 4507 4508 jQuery.ajax( { 4509 url: wpeasycart_ajax_object.ajax_url, 4510 type: 'post', 4511 data: data, 4512 cache: false 4513 } ); 4514} 4515 4516function ec_submit_newsletter_signup_widget( nonce ) { 4517 jQuery( '.ec_newsletter_pre_submit' ).hide( ); 4518 jQuery( '.ec_newsletter_post_submit' ).show( ); 4519 4520 var email_address = jQuery( '#ec_newsletter_email_widget' ).val( ); 4521 var newsletter_name = ""; 4522 if( document.getElementById( 'ec_newsletter_name_widget' ) ) 4523 newsletter_name = jQuery( document.getElementById( 'ec_newsletter_name_widget' ) ).val( ); 4524 4525 var data = { 4526 action: 'ec_ajax_submit_newsletter_signup', 4527 email_address: email_address, 4528 newsletter_name: newsletter_name, 4529 nonce: nonce 4530 }; 4531 4532 jQuery.ajax( { 4533 url: wpeasycart_ajax_object.ajax_url, 4534 type: 'post', 4535 data: data, 4536 cache: false 4537 } ); 4538} 4539 4540function update_download_count( orderdetail_id ){ 4541 4542 if( jQuery( document.getElementById( 'ec_download_count_' + orderdetail_id ) ).length ){ 4543 var count = Number( jQuery( document.getElementById( 'ec_download_count_' + orderdetail_id ) ).html( ) ); 4544 var max_count = Number( jQuery( document.getElementById( 'ec_download_count_max_' + orderdetail_id ) ).html( ) ); 4545 if( count < max_count ){ 4546 count++; 4547 jQuery( document.getElementById( 'ec_download_count_' + orderdetail_id ) ).html( count ); 4548 } 4549 } 4550 4551} 4552 4553function ec_show_update_subscription_payment() { 4554 jQuery( '.ec_account_subscription_details_payment_form' ).show(); 4555 jQuery( '.ec_account_subscription_details_card_change' ).hide(); 4556 jQuery( '.ec_account_subscription_upgrade_row' ).hide(); 4557 jQuery( '.ec_account_subscription_details_plan_change' ).show(); 4558 return false; 4559} 4560 4561function ec_show_update_subscription_details() { 4562 jQuery( '.ec_account_subscription_details_payment_form' ).hide(); 4563 jQuery( '.ec_account_subscription_details_card_change' ).show(); 4564 jQuery( '.ec_account_subscription_upgrade_row' ).show(); 4565 jQuery( '.ec_account_subscription_details_plan_change' ).hide(); 4566 return false; 4567} 4568 4569function show_billing_info( ){ 4570 jQuery( document.getElementById( 'ec_account_subscription_billing_information' ) ).slideToggle(600); 4571 return false; 4572} 4573 4574function ec_update_subscription_info( subscription_id, nonce ){ 4575 jQuery( document.getElementById( 'stripe-success-cover' ) ).show( ); 4576 var data = { 4577 action: 'ec_ajax_stripe_update_customer_subscription_plan', 4578 language: wpeasycart_ajax_object.current_language, 4579 subscription_id: subscription_id, 4580 quantity: jQuery( document.getElementById( 'ec_quantity_' + subscription_id ) ).val(), 4581 ec_selected_plan: jQuery( document.getElementById( 'ec_selected_plan' ) ).val( ), 4582 nonce: nonce 4583 }; 4584 jQuery.ajax( { 4585 url: wpeasycart_ajax_object.ajax_url, 4586 type: 'post', 4587 data: data, 4588 cache: false, 4589 success: function( result ){ 4590 var json = JSON.parse( result ); 4591 jQuery( location ).attr( 'href', json.url ); 4592 } 4593 } ); 4594 return false; 4595} 4596 4597function ec_check_update_subscription_info( ){
4598 4599 if( jQuery( document.getElementById( 'ec_account_subscription_billing_information' ) ).is(":visible") ){ 4600 4601 var address_validated = ec_validate_address_block( 'ec_account_billing_information' ); 4602 var payment_method_complete = ec_validate_payment_method( ); 4603 var terms_complete = ec_validate_terms( ); 4604 4605 if( address_validated && payment_method_complete && terms_complete ) 4606 return true; 4607 else 4608 return false; 4609 4610 }else{ 4611 return true; 4612 } 4613} 4614 4615function ec_cancel_subscription_check( confirm_text ){ 4616 return confirm( confirm_text ); 4617} 4618 4619function ec_details_show_inquiry_form( product_id ){ 4620 jQuery( '.ec_details_inquiry_popup_' + product_id ).fadeIn( 'fast' ); 4621 return false; 4622} 4623 4624function ec_details_hide_inquiry_popup( product_id ){ 4625 jQuery( '.ec_details_inquiry_popup_' + product_id ).fadeOut( 'fast' ); 4626} 4627 4628function ec_details_show_image_popup( model_number ){ 4629 jQuery( document.getElementById( 'ec_details_large_popup_' + model_number ) ).show( ); 4630 jQuery( 'html' ).css( 'overflow', 'hidden' ); 4631} 4632 4633function ec_details_hide_large_popup( model_number ){ 4634 jQuery( document.getElementById( 'ec_details_large_popup_' + model_number ) ).hide( ); 4635 jQuery( 'html' ).css( 'overflow', 'scroll' ); 4636} 4637 4638function ec_create_ideal_order_redirect( source, nonce ){ 4639 var redirect = source.redirect.url; 4640 var data = { 4641 action: 'ec_ajax_create_stripe_ideal_order', 4642 source: source, 4643 nonce: nonce 4644 }; 4645 jQuery.ajax( { 4646 url: wpeasycart_ajax_object.ajax_url, 4647 type: 'post', 4648 data: data, 4649 cache: false, 4650 success: function( data ) { 4651 window.location.href = redirect; 4652 } 4653 } ); 4654} 4655 4656function ec_stripe_check_order_status( source, nonce, count = 1 ) { 4657 var data = { 4658 action: 'ec_ajax_stripe_check_order_status', 4659 source: source, 4660 nonce: nonce, 4661 count: count, 4662 }; 4663 jQuery.ajax( { 4664 url: wpeasycart_ajax_object.ajax_url, 4665 type: 'post', 4666 data: data, 4667 cache: false, 4668 success: function( data ){ 4669 var response_obj = JSON.parse( data ); 4670 if ( 'requires_confirmation' == response_obj.status ) { 4671 ec_stripe_check_order_status( source, nonce, count++ ); 4672 } else { 4673 window.location.href = response_obj.redirect; 4674 } 4675 } 4676 } ); 4677} 4678 4679function ec_notify_submit( product_id, rand_id, nonce ){ 4680 var errors = false; 4681 var email = jQuery( document.getElementById( 'ec_email_notify_' + product_id + '_' + rand_id ) ).val( ); 4682 if( !ec_validate_email( email ) ){ 4683 errors = true; 4684 jQuery( document.getElementById( 'ec_email_notify_' + product_id + '_' + rand_id + '_error' ) ).show( ); 4685 }else{ 4686 jQuery( document.getElementById( 'ec_email_notify_' + product_id + '_' + rand_id + '_error' ) ).hide( ); 4687 } 4688 4689 var recaptcha_response = false; 4690 if( jQuery( document.getElementById( 'ec_grecaptcha_response_product_details' ) ).length ){ 4691 recaptcha_response = jQuery( document.getElementById( 'ec_grecaptcha_response_product_details' ) ).val( ); 4692 if( !recaptcha_response.length ){ 4693 jQuery( '#ec_product_details_recaptcha > div' ).css( 'border', '1px solid red' ); 4694 errors = true; 4695 }else{ 4696 jQuery( '#ec_product_details_recaptcha > div' ).css( 'border', 'none' ); 4697 } 4698 } 4699 4700 if( !errors ){ 4701 jQuery( document.getElementById( 'ec_product_details_stock_notify_' + product_id + '_' + rand_id + '_loader_cover' ) ).show( ); 4702 jQuery( document.getElementById( 'ec_product_details_stock_notify_' + product_id + '_' + rand_id + '_loader' ) ).show( ); 4703 var data = { 4704 action: 'ec_ajax_subscribe_to_stock_notification', 4705 email: email, 4706 product_id: product_id, 4707 recaptcha_response: recaptcha_response, 4708 nonce: nonce 4709 }; 4710 jQuery.ajax( { 4711 url: wpeasycart_ajax_object.ajax_url, 4712 type: 'post', 4713 data: data, 4714 cache: false, 4715 success: function( data ){ 4716 jQuery( document.getElementById( 'ec_product_details_stock_notify_complete_' + product_id + '_' + rand_id ) ).show( ); 4717 jQuery( document.getElementById( 'ec_product_details_stock_notify_' + product_id + '_' + rand_id ) ).hide( ); 4718 jQuery( document.getElementById( 'ec_product_details_stock_notify_' + product_id + '_' + rand_id + '_loader_cover' ) ).hide( ); 4719 jQuery( document.getElementById( 'ec_product_details_stock_notify_' + product_id + '_' + rand_id + '_loader' ) ).hide( ); 4720 } 4721 } ); 4722 } 4723 4724} 4725 4726function wpeasycart_load_cart( cart_page, success_code, error_code, language = 'NONE', nonce ){ 4727 if( language == 'NONE' ){ 4728 language = wpeasycart_ajax_object.current_language; 4729 } 4730 var data = { 4731 action: 'ec_ajax_get_dynamic_cart_page', 4732 cart_page: cart_page, 4733 success_code: success_code, 4734 error_code: error_code, 4735 language: language, 4736 nonce: nonce 4737 }; 4738 jQuery.ajax( { 4739 url: wpeasycart_ajax_object.ajax_url, 4740 type: 'post', 4741 data: data, 4742 cache: false, 4743 success: function( data ){ 4744 jQuery( document.getElementById( 'wpeasycart_cart_holder' ) ).replaceWith( data ); 4745 wp_easycart_init_location_buttons(); 4746 } 4747 } ); 4748} 4749 4750function wpeasycart_load_account( account_page, page_id, success_code, error_code, language = 'NONE', nonce = '', form_only = false ){ 4751 if( language == 'NONE' ){ 4752 language = wpeasycart_ajax_object.current_language; 4753 } 4754 var data = { 4755 action: 'ec_ajax_get_dynamic_account_page', 4756 account_page: account_page, 4757 page_id: page_id, 4758 success_code: success_code, 4759 error_code: error_code, 4760 language: language, 4761 nonce: nonce, 4762 form_only: form_only 4763 }; 4764 jQuery.ajax( { 4765 url: wpeasycart_ajax_object.ajax_url, 4766 type: 'post', 4767 data: data, 4768 cache: false, 4769 success: function( data ){ 4770 jQuery( document.getElementById( 'wpeasycart_account_holder' ) ).replaceWith( data ); 4771 } 4772 } ); 4773} 4774 4775function wpeasycart_update_tip( tip_rate, nonce ){ 4776 jQuery( '.ec_cart_tip_item' ).removeClass( 'ec_tip_selected' ); 4777 var tip_amount = Number( jQuery( document.getElementById( 'ec_cart_tip_custom' ) ).val( ) ); 4778 jQuery( document.getElementById( 'ec_apply_tip_button' ) ).hide( ); 4779 jQuery( document.getElementById( 'ec_applying_tip' ) ).show( ); 4780 var data = { 4781 action: 'ec_ajax_update_tip_amount', 4782 tip_rate: tip_rate, 4783 tip_amount: tip_amount, 4784 language: wpeasycart_ajax_object.current_language, 4785 nonce: nonce 4786 }; 4787 jQuery.ajax( { 4788 url: wpeasycart_ajax_object.ajax_url, 4789 type: 'post', 4790 data: data, 4791 cache: false, 4792 success: function( data ){ 4793 var response_obj = JSON.parse( data ); 4794 ec_update_cart( response_obj ); 4795 jQuery( document.getElementById( 'ec_apply_tip_button' ) ).show( ); 4796 jQuery( document.getElementById( 'ec_applying_tip' ) ).hide( ); 4797 } 4798 } ); 4799} 4800 4801function wp_easycart_text_notification_subscribe( wpeasycart_text_iti ) { 4802 var isValid = wpeasycart_text_iti.isValidNumber(); 4803 if( ! isValid ) { 4804 jQuery( '#text_notification_error' ).show(); 4805 jQuery( document.getElementById( 'text_notification_success' ) ).hide(); 4806 return; 4807 } else { 4808 jQuery( '#text_notification_error' ).hide(); 4809 } 4810 jQuery( document.getElementById( 'text_notification_loader' ) ).show(); 4811 var text_number = wpeasycart_text_iti.getNumber(); 4812 var order_id = jQuery( document.getElementById( 'text_order_id' ) ).val( ); 4813 var data = { 4814 action: 'ec_ajax_subscribe_text_notification', 4815 text_number: text_number, 4816 order_id: order_id 4817 }; 4818 jQuery.ajax( { 4819 url: wpeasycart_ajax_object.ajax_url, 4820 type: 'post', 4821 data: data, 4822 cache: false, 4823 success: function( data ){
4824 jQuery( document.getElementById( 'text_notification_loader' ) ).hide(); 4825 jQuery( document.getElementById( 'text_notification_success' ) ).fadeIn( 'fast' ); 4826 jQuery( document.getElementById( 'text_phone_number' ) ).val( '' ) 4827 } 4828 } ); 4829} 4830function ec_details_advanced_adjust_price( product_id, rand_id ) { 4831 if( jQuery( document.getElementById( 'ec_base_price_' + product_id + '_' + rand_id ) ).length == 0 ) { 4832 return; 4833 } 4834 var base_price = Number( jQuery( document.getElementById( 'ec_base_option_price_' + product_id + '_' + rand_id ) ).val() ); 4835 if( jQuery( document.getElementById( 'ec_donation_amount_' + product_id + '_' + rand_id ) ).length ) { 4836 base_price = Number( jQuery( document.getElementById( 'ec_donation_amount_' + product_id + '_' + rand_id ) ).val() ); 4837 } 4838 4839 // Get a quantity in case we need to use in calculating price 4840 var current_quantity = 1; 4841 if( jQuery( document.getElementById( 'ec_quantity_' + product_id + '_' + rand_id ) ).length > 0 ){ 4842 current_quantity = jQuery( document.getElementById( 'ec_quantity_' + product_id + '_' + rand_id ) ).val( ); 4843 } 4844 if( jQuery( '.ec_details_grid_row > input' ).length > 0 ){ 4845 current_quantity = 0; 4846 jQuery( '.ec_details_grid_row > input' ).each( function( ){ 4847 current_quantity = current_quantity + Number( jQuery( this ).val( ) ); 4848 } ); 4849 } 4850 var tier_quantities = window['tier_quantities_' + product_id + '_' + rand_id]; 4851 var tier_prices = window['tier_prices_' + product_id + '_' + rand_id]; 4852 for( var i=0; i<tier_quantities.length; i++ ){ 4853 if( tier_quantities[i] <= current_quantity ) { 4854 base_price = Number( tier_prices[i] ); 4855 } 4856 } 4857 var vat_added = jQuery( document.getElementById( 'vat_added_' + product_id + '_' + rand_id ) ).val(); 4858 var vat_rate_multiplier = jQuery( document.getElementById( 'vat_rate_multiplier_' + product_id + '_' + rand_id ) ).val(); 4859 var override_price = -1; 4860 var price_multiplier = 1; 4861 // Checkbox Price Adjustments 4862 var checkbox_adj = 0; 4863 var checkbox_add = 0; 4864 // Combox Price Adjustments 4865 var combo_adj = 0; 4866 var combo_add = 0; 4867 // Date Price Adjustments 4868 var date_adj = 0; 4869 var date_add = 0; 4870 // File Price Adjustments 4871 var file_adj = 0; 4872 var file_add = 0; 4873 // Swatch Price Adjustments 4874 var swatch_adj = 0; 4875 var swatch_add = 0; 4876 // Grid Price Adjustments 4877 var grid_quantity = 0; 4878 var grid_adj = 0; 4879 var grid_add = 0; 4880 var grid_override = 0; 4881 // Radio Price Adjustments 4882 var radio_adj = 0; 4883 var radio_add = 0; 4884 // Text Price Adjustments 4885 var text_adj = 0; 4886 var text_add = 0; 4887 // Number Price Adjustments 4888 var number_adj = 0; 4889 var number_add = 0; 4890 // Textarea Price Adjustments 4891 var textarea_adj = 0; 4892 var textarea_add = 0; 4893 // Dimensions Price Adjustments 4894 var has_sq_footage = false; 4895 var sq_footage = 1; 4896 jQuery( '.ec_details_grid_row:visible > input' ).each( function() { 4897 if( jQuery( this ).val() > 0 ) { 4898 grid_quantity += Number( jQuery( this ).val( ) ); 4899 if( jQuery( this ).attr( 'data-product-id' ) == product_id && jQuery( this ).attr( 'data-optionitem-price' ) != 0 ){ 4900 grid_adj += ( ( Number( jQuery( this ).attr( 'data-optionitem-price' ) ) ) * ( Number( jQuery( this ).val( ) ) ) ); 4901 } 4902 if( jQuery( this ).attr( 'data-product-id' ) == product_id && jQuery( this ).attr( 'data-optionitem-price-onetime' ) != 0 ){ 4903 grid_add += Number( jQuery( this ).attr( 'data-optionitem-price-onetime' ) ); 4904 } 4905 if( jQuery( this ).attr( 'data-product-id' ) == product_id && jQuery( this ).attr( 'data-optionitem-price-override' ) >= 0 ){ 4906 grid_override += ( Number( jQuery( this ).attr( 'data-optionitem-price-override' ) ) - base_price ) * ( ( Number( jQuery( this ).val( ) ) ) ); 4907 } 4908 if( jQuery( this ).attr( 'data-product-id' ) == product_id && jQuery( this ).attr( 'data-optionitem-price-multiplier' ) > 0 ){ 4909 price_multiplier = price_multiplier * Number( jQuery( this ).attr( 'data-optionitem-price-multiplier' ) ); 4910 } 4911 } 4912 } ); 4913 jQuery( '.ec_details_checkbox_row:visible > input:checked, .ec_details_checkbox_row_ele:visible > label > input:checked' ).each( function( ){
4914 if( jQuery( this ).attr( 'data-product-id' ) == product_id && jQuery( this ).attr( 'data-optionitem-price' ) != 0 ){ 4915 if( grid_quantity ) 4916 checkbox_adj += Number( jQuery( this ).attr( 'data-optionitem-price' ) ) * grid_quantity; 4917 else 4918 checkbox_adj += Number( jQuery( this ).attr( 'data-optionitem-price' ) ); 4919 } 4920 if( jQuery( this ).attr( 'data-product-id' ) == product_id && jQuery( this ).attr( 'data-optionitem-price-onetime' ) != 0 ){ 4921 checkbox_add += Number( jQuery( this ).attr( 'data-optionitem-price-onetime' ) ); 4922 } 4923 if( jQuery( this ).attr( 'data-product-id' ) == product_id && jQuery( this ).attr( 'data-optionitem-price-override' ) >= 0 ){ 4924 override_price = Number( jQuery( this ).attr( 'data-optionitem-price-override' ) ); 4925 } 4926 if( jQuery( this ).attr( 'data-product-id' ) == product_id && jQuery( this ).attr( 'data-optionitem-price-multiplier' ) > 0 ){ 4927 price_multiplier = price_multiplier * Number( jQuery( this ).attr( 'data-optionitem-price-multiplier' ) ); 4928 } 4929 } ); 4930 jQuery( '.ec_details_option_row.ec_option_type_combo:visible > .ec_details_option_data > select option:selected' ).each( function( ){ 4931 if( jQuery( this ).attr( 'data-product-id' ) == product_id && jQuery( this ).attr( 'data-optionitem-price' ) != 0 ){ 4932 if( grid_quantity ) 4933 combo_adj += Number( jQuery( this ).attr( 'data-optionitem-price' ) ) * grid_quantity; 4934 else 4935 combo_adj += Number( jQuery( this ).attr( 'data-optionitem-price' ) ); 4936 } 4937 if( jQuery( this ).attr( 'data-product-id' ) == product_id && jQuery( this ).attr( 'data-optionitem-price-onetime' ) != 0 ){ 4938 combo_add += Number( jQuery( this ).attr( 'data-optionitem-price-onetime' ) ); 4939 } 4940 if( jQuery( this ).attr( 'data-product-id' ) == product_id && jQuery( this ).attr( 'data-optionitem-price-override' ) >= 0 ){ 4941 override_price = Number( jQuery( this ).attr( 'data-optionitem-price-override' ) ); 4942 } 4943 if( jQuery( this ).attr( 'data-product-id' ) == product_id && jQuery( this ).attr( 'data-optionitem-price-multiplier' ) > 0 ){ 4944 price_multiplier = price_multiplier * Number( jQuery( this ).attr( 'data-optionitem-price-multiplier' ) ); 4945 } 4946 } ); 4947 jQuery( '.ec_details_option_row.ec_option_type_date:visible > .ec_details_option_data > input' ).each( function( ){ 4948 if( jQuery( this ).val( ) != "" ){ 4949 if( jQuery( this ).attr( 'data-product-id' ) == product_id && jQuery( this ).attr( 'data-optionitem-price' ) != 0 ){ 4950 if( grid_quantity ) 4951 date_adj += Number( jQuery( this ).attr( 'data-optionitem-price' ) ) * grid_quantity; 4952 else 4953 date_adj += Number( jQuery( this ).attr( 'data-optionitem-price' ) ); 4954 } 4955 if( jQuery( this ).attr( 'data-product-id' ) == product_id && jQuery( this ).attr( 'data-optionitem-price-onetime' ) != 0 ){ 4956 date_add += Number( jQuery( this ).attr( 'data-optionitem-price-onetime' ) ); 4957 } 4958 if( jQuery( this ).attr( 'data-product-id' ) == product_id && jQuery( this ).attr( 'data-optionitem-price-override' ) >= 0 ){ 4959 override_price = Number( jQuery( this ).attr( 'data-optionitem-price-override' ) ); 4960 } 4961 if( jQuery( this ).attr( 'data-product-id' ) == product_id && jQuery( this ).attr( 'data-optionitem-price-multiplier' ) > 0 ){ 4962 price_multiplier = price_multiplier * Number( jQuery( this ).attr( 'data-optionitem-price-multiplier' ) ); 4963 } 4964 } 4965 } ); 4966 jQuery( '.ec_details_option_row.ec_option_type_file:visible > .ec_details_option_data > input' ).each( function( ){ 4967 if( jQuery( this ).val( ) != "" ){ 4968 if( jQuery( this ).attr( 'data-product-id' ) == product_id && jQuery( this ).attr( 'data-optionitem-price' ) != 0 ){ 4969 if( grid_quantity ) 4970 file_adj += Number( jQuery( this ).attr( 'data-optionitem-price' ) ) * grid_quantity; 4971 else 4972 file_adj += Number( jQuery( this ).attr( 'data-optionitem-price' ) ); 4973 } 4974 if( jQuery( this ).attr( 'data-product-id' ) == product_id && jQuery( this ).attr( 'data-optionitem-price-onetime' ) != 0 ){ 4975 file_add += Number( jQuery( this ).attr( 'data-optionitem-price-onetime' ) ); 4976 }
4977 if( jQuery( this ).attr( 'data-product-id' ) == product_id && jQuery( this ).attr( 'data-optionitem-price-override' ) >= 0 ){ 4978 override_price = Number( jQuery( this ).attr( 'data-optionitem-price-override' ) ); 4979 } 4980 if( jQuery( this ).attr( 'data-product-id' ) == product_id && jQuery( this ).attr( 'data-optionitem-price-multiplier' ) > 0 ){ 4981 price_multiplier = price_multiplier * Number( jQuery( this ).attr( 'data-optionitem-price-multiplier' ) ); 4982 } 4983 } 4984 } ); 4985 jQuery( '.ec_details_swatch.ec_advanced.ec_selected:visible, .ec_details_swatch_ele.ec_advanced.ec_selected:visible' ).each( function( ){ 4986 if( jQuery( this ).attr( 'data-product-id' ) == product_id && jQuery( this ).attr( 'data-optionitem-price' ) != 0 ){ 4987 if( grid_quantity ) 4988 swatch_adj += Number( jQuery( this ).attr( 'data-optionitem-price' ) ) * grid_quantity; 4989 else 4990 swatch_adj += Number( jQuery( this ).attr( 'data-optionitem-price' ) ); 4991 } 4992 if( jQuery( this ).attr( 'data-product-id' ) == product_id && jQuery( this ).attr( 'data-optionitem-price-onetime' ) != 0 ){ 4993 swatch_add += Number( jQuery( this ).attr( 'data-optionitem-price-onetime' ) ); 4994 } 4995 if( jQuery( this ).attr( 'data-product-id' ) == product_id && jQuery( this ).attr( 'data-optionitem-price-override' ) >= 0 ){ 4996 override_price = Number( jQuery( this ).attr( 'data-optionitem-price-override' ) ); 4997 } 4998 if( jQuery( this ).attr( 'data-product-id' ) == product_id && jQuery( this ).attr( 'data-optionitem-price-multiplier' ) > 0 ){ 4999 price_multiplier = price_multiplier * Number( jQuery( this ).attr( 'data-optionitem-price-multiplier' ) ); 5000 } 5001 } ); 5002 jQuery( '.ec_details_radio_row:visible > input:checked, .ec_details_radio_row_ele:visible > label > input:checked' ).each( function( ){ 5003 if( jQuery( this ).attr( 'data-product-id' ) == product_id && jQuery( this ).attr( 'data-optionitem-price' ) != 0 ){ 5004 if( grid_quantity ) 5005 radio_adj += Number( jQuery( this ).attr( 'data-optionitem-price' ) ) * grid_quantity; 5006 else 5007 radio_adj += Number( jQuery( this ).attr( 'data-optionitem-price' ) ); 5008 } 5009 if( jQuery( this ).attr( 'data-product-id' ) == product_id && jQuery( this ).attr( 'data-optionitem-price-onetime' ) != 0 ){ 5010 radio_add += Number( jQuery( this ).attr( 'data-optionitem-price-onetime' ) ); 5011 } 5012 if( jQuery( this ).attr( 'data-product-id' ) == product_id && jQuery( this ).attr( 'data-optionitem-price-override' ) >= 0 ){ 5013 override_price = Number( jQuery( this ).attr( 'data-optionitem-price-override' ) ); 5014 } 5015 if( jQuery( this ).attr( 'data-product-id' ) == product_id && jQuery( this ).attr( 'data-optionitem-price-multiplier' ) > 0 ){ 5016 price_multiplier = price_multiplier * Number( jQuery( this ).attr( 'data-optionitem-price-multiplier' ) ); 5017 } 5018 } ); 5019 jQuery( '.ec_details_option_row.ec_option_type_text:visible > .ec_details_option_data > input' ).each( function( ){ 5020 if( jQuery( this ).val( ) != "" ){ 5021 if( jQuery( this ).attr( 'data-product-id' ) == product_id && jQuery( this ).attr( 'data-optionitem-price' ) != 0 ){ 5022 if( grid_quantity ) 5023 text_adj += Number( jQuery( this ).attr( 'data-optionitem-price' ) ) * grid_quantity; 5024 else 5025 text_adj += Number( jQuery( this ).attr( 'data-optionitem-price' ) ); 5026 } 5027 if( jQuery( this ).attr( 'data-product-id' ) == product_id && jQuery( this ).attr( 'data-optionitem-price-onetime' ) != 0 ){ 5028 text_add += Number( jQuery( this ).attr( 'data-optionitem-price-onetime' ) ); 5029 } 5030 if( jQuery( this ).attr( 'data-product-id' ) == product_id && jQuery( this ).attr( 'data-optionitem-price-override' ) >= 0 ){ 5031 override_price = Number( jQuery( this ).attr( 'data-optionitem-price-override' ) ); 5032 } 5033 if( jQuery( this ).attr( 'data-product-id' ) == product_id && jQuery( this ).attr( 'data-optionitem-price-multiplier' ) > 0 ){ 5034 price_multiplier = price_multiplier * Number( jQuery( this ).attr( 'data-optionitem-price-multiplier' ) ); 5035 } 5036 if( jQuery( this ).attr( 'data-product-id' ) == product_id && jQuery( this ).attr( 'data-optionitem-price-per-character' ) > 0 ){ 5037 var num_characters = Number( jQuery( this ).val( ).replace( / /g, '' ).length ); 5038 var price_per_char = Number( jQuery( this ).attr( 'data-optionitem-price-per-character' ) ); 5039 text_adj = text_adj + ( num_characters * price_per_char ); 5040 } 5041 } 5042 } ); 5043 jQuery( '.ec_details_option_row.ec_option_type_number:visible > .ec_details_option_data > input' ).each( function( ){ 5044 if( jQuery( this ).val( ) != "" && jQuery( this ).val( ) != "0" ){
5045 if( jQuery( this ).attr( 'data-product-id' ) == product_id && jQuery( this ).attr( 'data-optionitem-price' ) != 0 ){ 5046 if( grid_quantity > 0 ) 5047 number_adj += Number( jQuery( this ).val( ) ) * Number( jQuery( this ).attr( 'data-optionitem-price' ) ) * grid_quantity; 5048 else 5049 number_adj += Number( jQuery( this ).val( ) ) * Number( jQuery( this ).attr( 'data-optionitem-price' ) ); 5050 } 5051 if( jQuery( this ).attr( 'data-product-id' ) == product_id && jQuery( this ).attr( 'data-optionitem-price-onetime' ) != 0 ){ 5052 number_add += Number( jQuery( this ).attr( 'data-optionitem-price-onetime' ) ); 5053 } 5054 if( jQuery( this ).attr( 'data-product-id' ) == product_id && jQuery( this ).attr( 'data-optionitem-price-override' ) >= 0 ){ 5055 override_price = Number( jQuery( this ).attr( 'data-optionitem-price-override' ) ); 5056 } 5057 if( jQuery( this ).attr( 'data-product-id' ) == product_id && jQuery( this ).attr( 'data-optionitem-price-multiplier' ) > 0 ){ 5058 price_multiplier = price_multiplier * Number( jQuery( this ).val( ) ) * Number( jQuery( this ).attr( 'data-optionitem-price-multiplier' ) ); 5059 } 5060 } 5061 } ); 5062 jQuery( '.ec_details_option_row.ec_option_type_textarea:visible > .ec_details_option_data > textarea' ).each( function( ){ 5063 if( jQuery( this ).val( ) != "" ){ 5064 if( jQuery( this ).attr( 'data-product-id' ) == product_id && jQuery( this ).attr( 'data-optionitem-price' ) != 0 ){ 5065 textarea_adj += Number( jQuery( this ).attr( 'data-optionitem-price' ) ); 5066 } 5067 if( jQuery( this ).attr( 'data-product-id' ) == product_id && jQuery( this ).attr( 'data-optionitem-price-onetime' ) != 0 ){ 5068 textarea_add += Number( jQuery( this ).attr( 'data-optionitem-price-onetime' ) ); 5069 } 5070 if( jQuery( this ).attr( 'data-product-id' ) == product_id && jQuery( this ).attr( 'data-optionitem-price-override' ) >= 0 ){ 5071 override_price = Number( jQuery( this ).attr( 'data-optionitem-price-override' ) ); 5072 } 5073 if( jQuery( this ).attr( 'data-product-id' ) == product_id && jQuery( this ).attr( 'data-optionitem-price-multiplier' ) > 0 ){ 5074 price_multiplier = price_multiplier * Number( jQuery( this ).attr( 'data-optionitem-price-multiplier' ) ); 5075 } 5076 if( jQuery( this ).attr( 'data-product-id' ) == product_id && jQuery( this ).attr( 'data-optionitem-price-per-character' ) > 0 ){ 5077 var num_characters = Number( jQuery( this ).val( ).replace( / /g, '' ).length ); 5078 var price_per_char = Number( jQuery( this ).attr( 'data-optionitem-price-per-character' ) ); 5079 textarea_adj = textarea_adj + ( num_characters * price_per_char ); 5080 } 5081 } 5082 } ); 5083 jQuery( '.ec_dimensions_width' ).each( function( ){ 5084 if( Number( jQuery( this ).attr( 'data-product-id' ) ) == Number( product_id ) && Number( jQuery( this ).attr( 'data-rand-id' ) == rand_id ) ){ 5085 has_sq_footage = true; 5086 var product_option_id = jQuery( this ).attr( 'data-product-option-id' ); 5087 var width = jQuery( document.getElementById( 'ec_option_adv_' + product_option_id + '_' + product_id + '_' + rand_id + '_width' ) ).val( ); 5088 var sub_width = 0; 5089 var is_metric = ( '1' == jQuery( this ).attr( 'data-is-metric' ) ) ? 1 : 0; 5090 if( jQuery( document.getElementById( 'ec_option_adv_' + product_option_id + '_' + product_id + '_' + rand_id + '_sub_width' ) ).length ) { 5091 var sub_width = jQuery( document.getElementById( 'ec_option_adv_' + product_option_id + '_' + product_id + '_' + rand_id + '_sub_width' ) ).val( ); 5092 } 5093 var height = jQuery( document.getElementById( 'ec_option_adv_' + product_option_id + '_' + product_id + '_' + rand_id + '_height' ) ).val( ); 5094 var sub_height = 0; 5095 if( jQuery( document.getElementById( 'ec_option_adv_' + product_option_id + '_' + product_id + '_' + rand_id + '_sub_height' ) ).length ) { 5096 var sub_height = jQuery( document.getElementById( 'ec_option_adv_' + product_option_id + '_' + product_id + '_' + rand_id + '_sub_height' ) ).val( ); 5097 } 5098 if( '' != width && '' != height ) { 5099 sq_footage = ec_details_get_sq_footage( is_metric, width, sub_width, height, sub_height ) * Number( jQuery( document.getElementById( 'ec_quantity_' + product_id + '_' + rand_id ) ).val( ) ); 5100 } 5101 } 5102 } ); 5103 if( grid_quantity > 0 ) { 5104 base_price = base_price * grid_quantity; 5105 } 5106 var new_price = ( base_price + Number( checkbox_adj ) + Number( combo_adj ) + Number( date_adj ) + Number( file_adj ) + Number( swatch_adj ) + Number( grid_adj ) + Number( grid_override ) + Number( radio_adj ) + Number( text_adj ) + Number( number_adj ) + Number( textarea_adj ) ); 5107 var new_price_sqft = new_price * sq_footage; 5108 var override_price_final = override_price + Number( checkbox_adj ) + Number( combo_adj ) + Number( date_adj ) + Number( file_adj ) + Number( swatch_adj ) + Number( grid_adj ) + Number( grid_override ) + Number( radio_adj ) + Number( text_adj ) + Number( number_adj ) + Number( textarea_adj ); 5109 var override_price_sqft = override_price_final * sq_footage; 5110 var order_price = Number( checkbox_add ) + Number( combo_add ) + Number( date_add ) + Number( file_add ) + Number( swatch_add ) + Number( grid_add ) + Number( radio_add ) + Number( text_add ) + Number( number_add ) + Number( textarea_add ); 5111 if( override_price > -1 ){ 5112 jQuery( document.getElementById( 'ec_final_price_' + product_id + '_' + rand_id ) ).html( e
5112c_details_format_money_v2( product_id, rand_id, override_price_sqft ) ); 5113 jQuery( '.ec_details_price.ec_details_single_price > .ec_product_sale_price_' + product_id + '_' + rand_id ).each( function( ){ jQuery( this ).html( ec_details_format_money_v2( product_id, rand_id, override_price_final ) ); } ); 5114 jQuery( '.ec_details_price.ec_details_single_price > .ec_product_price_' + product_id + '_' + rand_id ).each( function( ){ 5115 jQuery( this ).html( ec_details_format_money_v2( product_id, rand_id, override_price_final ) ); 5116 } ); 5117 if ( '1' == vat_added ) { 5118 jQuery( '.ec_details_price.ec_details_no_vat_price > .ec_product_sale_price_' + product_id + '_' + rand_id ).each( function() { 5119 jQuery( this ).html( ec_details_format_money_v2( product_id, rand_id, override_price_final ) ); 5120 } ); 5121 jQuery( '.ec_details_price.ec_details_vat_price > .ec_product_sale_price_' + product_id + '_' + rand_id ).each( function() { 5122 jQuery( this ).html( ec_details_format_money_v2( product_id, rand_id, override_price_final * vat_rate_multiplier ) ); 5123 } ); 5124 jQuery( '.ec_details_price.ec_details_no_vat_price > .ec_product_price_' + product_id + '_' + rand_id ).each( function() { 5125 jQuery( this ).html( ec_details_format_money_v2( product_id, rand_id, override_price_final ) ); 5126 } ); 5127 jQuery( '.ec_details_price.ec_details_vat_price > .ec_product_price_' + product_id + '_' + rand_id ).each( function() { 5128 jQuery( this ).html( ec_details_format_money_v2( product_id, rand_id, override_price_final * vat_rate_multiplier ) ); 5129 } ); 5130 } else { 5131 jQuery( '.ec_details_price.ec_details_no_vat_price > .ec_product_sale_price_' + product_id + '_' + rand_id ).each( function() { 5132 jQuery( this ).html( ec_details_format_money_v2( product_id, rand_id, override_price_final / vat_rate_multiplier ) ); 5133 } ); 5134 jQuery( '.ec_details_price.ec_details_vat_price > .ec_product_sale_price_' + product_id + '_' + rand_id ).each( function( ) { 5135 jQuery( this ).html( ec_details_format_money_v2( product_id, rand_id, override_price_final ) ); 5136 } ); 5137 jQuery( '.ec_details_price.ec_details_no_vat_price > .ec_product_price_' + product_id + '_' + rand_id ).each( function() { 5138 jQuery( this ).html( ec_details_format_money_v2( product_id, rand_id, override_price_final / vat_rate_multiplier ) ); 5139 } ); 5140 jQuery( '.ec_details_price.ec_details_vat_price > .ec_product_price_' + product_id + '_' + rand_id ).each( function() { 5141 jQuery( this ).html( ec_details_format_money_v2( product_id, rand_id, override_price_final ) ); 5142 } ); 5143 } 5144 } else { 5145 jQuery( document.getElementById( 'ec_final_price_' + product_id + '_' + rand_id ) ).html( ec_details_format_money_v2( product_id, rand_id, new_price_sqft ) ); 5146 jQuery( '.ec_details_price.ec_details_single_price > .ec_product_sale_price_' + product_id + '_' + rand_id ).each( function( ){ 5147 jQuery( this ).html( ec_details_format_money_v2( product_id, rand_id, new_price ) ); 5148 } ); 5149 jQuery( '.ec_details_price.ec_details_single_price > .ec_product_price_' + product_id + '_' + rand_id ).each( function( ){ 5150 jQuery( this ).html( ec_details_format_money_v2( product_id, rand_id, new_price ) ); 5151 } ); 5152 if ( '1' == vat_added ) { 5153 jQuery( '.ec_details_price.ec_details_no_vat_price > .ec_product_sale_price_' + product_id + '_' + rand_id ).each( function( ){ 5154 jQuery( this ).html( ec_details_format_money_v2( product_id, rand_id, new_price ) ); 5155 } ); 5156 jQuery( '.ec_details_price.ec_details_vat_price > .ec_product_sale_price_' + product_id + '_' + rand_id ).each( function( ){ 5157 jQuery( this ).html( ec_details_format_money_v2( product_id, rand_id, new_price * vat_rate_multiplier ) ); 5158 } ); 5159 jQuery( '.ec_details_price.ec_details_no_vat_price > .ec_product_price_' + product_id + '_' + rand_id ).each( function( ){ 5160 jQuery( this ).html( ec_details_format_money_v2( product_id, rand_id, new_price ) ); 5161 } ); 5162 jQuery( '.ec_details_price.ec_details_vat_price > .ec_product_price_' + product_id + '_' + rand_id ).each( function( ){ 5163 jQuery( this ).html( ec_details_format_money_v2( product_id, rand_id, new_price * vat_rate_multiplier ) ); 5164 } ); 5165 } else { 5166 jQuery( '.ec_details_price.ec_details_no_vat_price > .ec_product_sale_price_' + product_id + '_' + rand_id ).each( function( ){
5167 jQuery( this ).html( ec_details_format_money_v2( product_id, rand_id, new_price / vat_rate_multiplier ) ); 5168 } ); 5169 jQuery( '.ec_details_price.ec_details_vat_price > .ec_product_sale_price_' + product_id + '_' + rand_id ).each( function( ){ 5170 jQuery( this ).html( ec_details_format_money_v2( product_id, rand_id, new_price ) ); 5171 } ); 5172 jQuery( '.ec_details_price.ec_details_no_vat_price > .ec_product_price_' + product_id + '_' + rand_id ).each( function( ){ 5173 jQuery( this ).html( ec_details_format_money_v2( product_id, rand_id, new_price / vat_rate_multiplier ) ); 5174 } ); 5175 jQuery( '.ec_details_price.ec_details_vat_price > .ec_product_price_' + product_id + '_' + rand_id ).each( function( ){ 5176 jQuery( this ).html( ec_details_format_money_v2( product_id, rand_id, new_price ) ); 5177 } ); 5178 } 5179 } 5180 if ( price_multiplier != 1 && override_price > -1 ) { 5181 jQuery( document.getElementById( 'ec_final_price_' + product_id + '_' + rand_id ) ).html( ec_details_format_money_v2( product_id, rand_id, override_price_sqft * Number( price_multiplier ) ) ); 5182 jQuery( '.ec_details_price.ec_details_single_price > .ec_product_sale_price_' + product_id + '_' + rand_id ).each( function( ){ 5183 jQuery( this ).html( ec_details_format_money_v2( product_id, rand_id, override_price_final * Number( price_multiplier ) ) ); 5184 } ); 5185 jQuery( '.ec_details_price.ec_details_single_price > .ec_product_price_' + product_id + '_' + rand_id ).each( function( ){ 5186 jQuery( this ).html( ec_details_format_money_v2( product_id, rand_id, override_price_final * Number( price_multiplier ) ) ); 5187 } ); 5188 if ( '1' == vat_added ) { 5189 jQuery( '.ec_details_price.ec_details_no_vat_price > .ec_product_sale_price_' + product_id + '_' + rand_id ).each( function( ){ 5190 jQuery( this ).html( ec_details_format_money_v2( product_id, rand_id, override_price_final * Number( price_multiplier ) ) ); 5191 } ); 5192 jQuery( '.ec_details_price.ec_details_vat_price > .ec_product_sale_price_' + product_id + '_' + rand_id ).each( function( ){ 5193 jQuery( this ).html( ec_details_format_money_v2( product_id, rand_id, override_price_final * Number( price_multiplier ) * vat_rate_multiplier ) ); 5194 } ); 5195 jQuery( '.ec_details_price.ec_details_no_vat_price > .ec_product_price_' + product_id + '_' + rand_id ).each( function( ){ 5196 jQuery( this ).html( ec_details_format_money_v2( product_id, rand_id, override_price_final * Number( price_multiplier ) ) ); 5197 } ); 5198 jQuery( '.ec_details_price.ec_details_vat_price > .ec_product_price_' + product_id + '_' + rand_id ).each( function( ){ 5199 jQuery( this ).html( ec_details_format_money_v2( product_id, rand_id, override_price_final * Number( price_multiplier ) * vat_rate_multiplier ) ); 5200 } ); 5201 } else { 5202 jQuery( '.ec_details_price.ec_details_no_vat_price > .ec_product_sale_price_' + product_id + '_' + rand_id ).each( function( ){ 5203 jQuery( this ).html( ec_details_format_money_v2( product_id, rand_id, override_price_final * Number( price_multiplier ) / vat_rate_multiplier ) ); 5204 } ); 5205 jQuery( '.ec_details_price.ec_details_vat_price > .ec_product_sale_price_' + product_id + '_' + rand_id ).each( function( ){ 5206 jQuery( this ).html( ec_details_format_money_v2( product_id, rand_id, override_price_final * Number( price_multiplier ) ) ); 5207 } ); 5208 jQuery( '.ec_details_price.ec_details_no_vat_price > .ec_product_price_' + product_id + '_' + rand_id ).each( function( ){ 5209 jQuery( this ).html( ec_details_format_money_v2( product_id, rand_id, override_price_final * Number( price_multiplier ) / vat_rate_multiplier ) ); 5210 } ); 5211 jQuery( '.ec_details_price.ec_details_vat_price > .ec_product_price_' + product_id + '_' + rand_id ).each( function( ){ 5212 jQuery( this ).html( ec_details_format_money_v2( product_id, rand_id, override_price_final * Number( price_multiplier ) ) ); 5213 } ); 5214 } 5215 } else if( price_multiplier != 1 ){ 5216 jQuery( document.getElementById( 'ec_final_price_' + product_id + '_' + rand_id ) ).html( ec_details_format_money_v2( product_id, rand_id, new_price * Number( price_multiplier ) ) ); 5217 jQuery( '.ec_details_price.ec_details_single_price > .ec_product_sale_price_' + product_id + '_' + rand_id ).each( function( ){
5218 jQuery( this ).html( ec_details_format_money_v2( product_id, rand_id, new_price * Number( price_multiplier ) ) ); 5219 } ); 5220 jQuery( '.ec_details_price.ec_details_single_price > .ec_product_price_' + product_id + '_' + rand_id ).each( function( ){ 5221 jQuery( this ).html( ec_details_format_money_v2( product_id, rand_id, new_price * Number( price_multiplier ) ) ); 5222 } ); 5223 if( '1' == vat_added ){ 5224 jQuery( '.ec_details_price.ec_details_no_vat_price > .ec_product_sale_price_' + product_id + '_' + rand_id ).each( function( ){ 5225 jQuery( this ).html( ec_details_format_money_v2( product_id, rand_id, new_price * Number( price_multiplier ) ) ); 5226 } ); 5227 jQuery( '.ec_details_price.ec_details_vat_price > .ec_product_sale_price_' + product_id + '_' + rand_id ).each( function( ){ 5228 jQuery( this ).html( ec_details_format_money_v2( product_id, rand_id, new_price * Number( price_multiplier ) * vat_rate_multiplier ) ); 5229 } ); 5230 jQuery( '.ec_details_price.ec_details_no_vat_price > .ec_product_price_' + product_id + '_' + rand_id ).each( function( ){ 5231 jQuery( this ).html( ec_details_format_money_v2( product_id, rand_id, new_price * Number( price_multiplier ) ) ); 5232 } ); 5233 jQuery( '.ec_details_price.ec_details_vat_price > .ec_product_price_' + product_id + '_' + rand_id ).each( function( ){ 5234 jQuery( this ).html( ec_details_format_money_v2( product_id, rand_id, new_price * Number( price_multiplier ) * vat_rate_multiplier ) ); 5235 } ); 5236 } else { 5237 jQuery( '.ec_details_price.ec_details_no_vat_price > .ec_product_sale_price_' + product_id + '_' + rand_id ).each( function( ){ 5238 jQuery( this ).html( ec_details_format_money_v2( product_id, rand_id, new_price * Number( price_multiplier ) / vat_rate_multiplier ) ); 5239 } ); 5240 jQuery( '.ec_details_price.ec_details_vat_price > .ec_product_sale_price_' + product_id + '_' + rand_id ).each( function( ){ 5241 jQuery( this ).html( ec_details_format_money_v2( product_id, rand_id, new_price * Number( price_multiplier ) ) ); 5242 } ); 5243 jQuery( '.ec_details_price.ec_details_no_vat_price > .ec_product_price_' + product_id + '_' + rand_id ).each( function( ){ 5244 jQuery( this ).html( ec_details_format_money_v2( product_id, rand_id, new_price * Number( price_multiplier ) / vat_rate_multiplier ) ); 5245 } ); 5246 jQuery( '.ec_details_price.ec_details_vat_price > .ec_product_price_' + product_id + '_' + rand_id ).each( function( ){ 5247 jQuery( this ).html( ec_details_format_money_v2( product_id, rand_id, new_price * Number( price_multiplier ) ) ); 5248 } ); 5249 } 5250 } 5251 if( order_price != 0 ){ 5252 jQuery( '.ec_details_added_price_' + product_id + '_' + rand_id ).show( ); 5253 jQuery( document.getElementById( 'ec_added_price_' + product_id + '_' + rand_id ) ).html( ec_details_format_money_v2( product_id, rand_id, order_price ) ); 5254 }else{ 5255 jQuery( '.ec_details_added_price_' + product_id + '_' + rand_id ).hide( ); 5256 } 5257} 5258 5259function ec_details_base_adjust_price( product_id, rand_id ) { 5260 if( jQuery( document.getElementById( 'ec_default_price_' + product_id + '_' + rand_id ) ).length == 0 ) { 5261 return; 5262 } 5263 var base_price = Number( jQuery( document.getElementById( 'ec_default_price_' + product_id + '_' + rand_id ) ).val() ); 5264 if( jQuery( document.getElementById( 'ec_donation_amount_' + product_id + '_' + rand_id ) ).length ) { 5265 base_price = Number( jQuery( document.getElementById( 'ec_donation_amount_' + product_id + '_' + rand_id ) ).val() ); 5266 } 5267 var current_quantity = jQuery( document.getElementById( 'ec_quantity_' + product_id + '_' + rand_id ) ).val( ); 5268 var tier_quantities = window['tier_quantities_' + product_id + '_' + rand_id]; 5269 var tier_prices = window['tier_prices_' + product_id + '_' + rand_id]; 5270 if ( tier_quantities ) { 5271 for ( var i=0; i<tier_quantities.length; i++ ) { 5272 if ( tier_quantities[i] <= current_quantity ) { 5273 base_price = Number( tier_prices[i] ); 5274 } 5275 } 5276 } 5277 var vat_added = jQuery( document.getElementById( 'vat_added_' + product_id + '_' + rand_id ) ).val(); 5278 var vat_rate_multiplier = jQuery( document.getElementById( 'vat_rate_multiplier_' + product_id + '_' + rand_id ) ).val(); 5279 var option1_price_adj = 0; 5280 var option2_price_adj = 0; 5281 var option3_price_adj = 0; 5282 var option4_price_adj = 0; 5283 var option5_price_adj = 0; 5284 var option1_price_add = 0; 5285 var option2_price_add = 0; 5286 var option3_price_add = 0; 5287 var option4_price_add = 0; 5288 var option5_price_add = 0; 5289 var option1_price_override = -1; 5290 var option2_price_override = -1; 5291 var option3_price_override = -1; 5292 var option4_price_override = -1; 5293 var option5_price_override = -1; 5294 var total_basic_options = jQuery( '.ec_details_options_basic .ec_details_option_row' ).length; 5295 var basic_options_selected = 0; 5296 var basic_options_string = ''; 5297 if ( jQuery( '.ec_details_swatches > li.ec_option1_' + product_id + '_' + rand_id + '.ec_selected' ).length ) { 5298 basic_options_selected++; 5299 basic_options_string += jQuery( '#ec_option1_' + product_id + '_' + rand_id ).val(); 5300 } else if ( jQuery( '.ec_details_combo.ec_option1_' + product_id + '_' + rand_id ).length && jQuery( '.ec_details_combo.ec_option1_' + product_id + '_' + rand_id ).val() != '0') { 5301 basic_options_selected++; 5302 basic_options_string += jQuery( '.ec_details_combo.ec_option1_' + product_id + '_' + rand_id ).val(); 5303 } else { 5304 basic_options_string += '0'; 5305 } 5306 if ( jQuery( '.ec_details_swatches > li.ec_option2_' + product_id + '_' + rand_id + '.ec_selected' ).length ) { 5307 basic_options_selected++; 5308 basic_options_string += jQuery( '#ec_option2_' + product_id + '_' + rand_id ).val(); 5309 } else if ( jQuery( '.ec_details_combo.ec_option2_' + product_id + '_' + rand_id ).length && jQuery( '.ec_details_combo.ec_option2_' + product_id + '_' + rand_id ).val() != '0') { 5310 basic_options_selected++; 5311 basic_options_string += jQuery( '.ec_details_combo.ec_option2_' + product_id + '_' + rand_id ).val(); 5312 } else { 5313 basic_options_string += '0'; 5314 } 5315 if ( jQuery( '.ec_details_swatches > li.ec_option3_' + product_id + '_' + rand_id + '.ec_selected' ).length ) { 5316 basic_options_selected++; 5317 basic_options_string += jQuery( '#ec_option3_' + product_id + '_' + rand_id ).val(); 5318 } else if ( jQuery( '.ec_details_combo.ec_option3_' + product_id + '_' + rand_id ).length && jQuery( '.ec_details_combo.ec_option3_' + product_id + '_' + rand_id ).val() != '0') { 5319 basic_options_selected++; 5320 basic_options_string += jQuery( '.ec_details_combo.ec_option3_' + product_id + '_' + rand_id ).val(); 5321 } else { 5322 basic_options_string += '0'; 5323 } 5324 if ( jQuery( '.ec_details_swatches > li.ec_option4_' + product_id + '_' + rand_id + '.ec_selected' ).length ) { 5325 basic_options_selected++; 5326 basic_options_string += jQuery( '#ec_option4_' + product_id + '_' + rand_id ).val(); 5327 } else if ( jQuery( '.ec_details_combo.ec_option4_' + product_id + '_' + rand_id ).length && jQuery( '.ec_details_combo.ec_option4_' + product_id + '_' + rand_id ).val() != '0') { 5328 basic_options_selected++; 5329 basic_options_string += jQuery( '.ec_details_combo.ec_option4_' + product_id + '_' + rand_id ).val(); 5330 } else { 5331 basic_options_string += '0'; 5332 } 5333 if ( jQuery( '.ec_details_swatches > li.ec_option5_' + product_id + '_' + rand_id + '.ec_selected' ).length ) { 5334 basic_options_selected++; 5335 basic_options_string += jQuery( '#ec_option5_' + product_id + '_' + rand_id ).val(); 5336 } else if ( jQuery( '.ec_details_combo.ec_option5_' + product_id + '_' + rand_id ).length && jQuery( '.ec_details_combo.ec_option5_' + product_id + '_' + rand_id ).val() != '0') { 5337 basic_options_selected++; 5338 basic_options_string += jQuery( '.ec_details_combo.ec_option5_' + product_id + '_' + rand_id ).val(); 5339 } else { 5340 basic_options_string += '0'; 5341 } 5342 if ( total_basic_options == basic_options_selected && window['varitation_data_' + product_id + '_' + rand_id][basic_options_string] && window['varitation_data_' + product_id + '_' + rand_id][basic_options_string].sku != '' ) { 5343 jQuery( '.ec_details_model_number_sku_' + product_id + '_' + rand_id ).html( window['varitation_data_' + product_id + '_' + rand_id][basic_options_string].sku ); 5344 } else { 5345 jQuery( '.ec_details_model_number_sku_' + product_id + '_' + rand_id ).html( jQuery( document.getElementById( 'ec_default_sku_' + product_id + '_' + rand_id ) ).val() ); 5346 } 5347 if ( total_basic_options == basic_options_selected && window['varitation_data_' + product_id + '_' + rand_id][basic_options_string] && window['varitation_data_' + product_id + '_' + rand_id][basic_options_string].price != -1 ) { 5348 base_price = window['varitation_data_' + product_id + '_' + rand_id][basic_options_string].price; 5349 Number( jQuery( document.getElementById( 'ec_base_price_' + product_id + '_' + rand_id ) ).html( base_price ) ); 5350 } else { 5351 // Option 1 Price Adjustment 5352 if( jQuery( '.ec_details_swatches > li.ec_option1_' + product_id + '_' + rand_id + '.ec_selected, .ec_details_swatches_ele > li.ec_option1_' + product_id + '_' + rand_id + '.ec_selected' ).length ){ 5353 option1_price_adj = jQuery( '.ec_details_swatches > li.ec_option1_' + product_id + '_' + rand_id + '.ec_selected, .ec_details_swatches_ele > li.ec_option1_' + product_id + '_' + rand_id + '.ec_selected' ).attr( 'data-optionitem-price' ); 5354 option1_price_add = jQuery( '.ec_details_swatches > li.ec_option1_' + product_id + '_' + rand_id + '.ec_selected, .ec_details_swatches_ele > li.ec_option1_' + product_id + '_' + rand_id + '.ec_selected' ).attr( 'data-optionitem-price-onetime' ); 5355 option1_price_override = Number( jQuery( '.ec_details_swatches > li.ec_option1_' + product_id + '_' + rand_id + '.ec_selected, .ec_details_swatches_ele > li.ec_option1_' + product_id + '_' + rand_id + '.ec_selected' ).attr( 'data-optionitem-price-override' ) ); 5356 option1_price_multiplier = Number( jQuery( '.ec_details_swatches > li.ec_option1_' + product_id + '_' + rand_id + '.ec_selected, .ec_details_swatches_ele > li.ec_option1_' + product_id + '_' + rand_id + '.ec_selected' ).attr( 'data-optionitem-price-multiplier' ) ); 5357 }else if( jQuery( '.ec_details_combo.ec_option1_' + product_id + '_' + rand_id ).length ){ 5358 option1_price_adj = jQuery( '.ec_details_combo.ec_option1_' + product_id + '_' + rand_id + ' option:selected' ).attr( 'data-optionitem-price' ); 5359 option1_price_add = jQuery( '.ec_details_combo.ec_option1_' + product_id + '_' + rand_id + ' option:selected' ).attr( 'data-optionitem-price-onetime' ); 5360 option1_price_override = Number( jQuery( '.ec_details_combo.ec_option1_' + product_id + '_' + rand_id + ' option:selected' ).attr( 'data-optionitem-price-override' ) ); 5361 option1_price_multiplier = Number( jQuery( '.ec_details_combo.ec_option1_' + product_id + '_' + rand_id + ' option:selected' ).attr( 'data-optionitem-price-multiplier' ) ); 5362 } 5363 // Option 2 Price Adjustment 5364 if( jQuery( '.ec_details_swatches > li.ec_option2_' + product_id + '_' + rand_id + '.ec_selected, .ec_details_swatches_ele > li.ec_option2_' + product_id + '_' + rand_id + '.ec_selected' ).length ){ 5365 option2_price_adj = jQuery( '.ec_details_swatches > li.ec_option2_' + product_id + '_' + rand_id + '.ec_selected, .ec_details_swatches_ele > li.ec_option2_' + product_id + '_' + rand_id + '.ec_selected' ).attr( 'data-optionitem-price' ); 5366 option2_price_add = jQuery( '.ec_details_swatches > li.ec_option2_' + product_id + '_' + rand_id + '.ec_selected, .ec_details_swatches_ele > li.ec_option2_' + product_id + '_' + rand_id + '.ec_selected' ).attr( 'data-optionitem-price-onetime' ); 5367 option2_price_override = Number( jQuery( '.ec_details_swatches > li.ec_option2_' + product_id + '_' + rand_id + '.ec_selected, .ec_details_swatches_ele > li.ec_option2_' + product_id + '_' + rand_id + '.ec_selected' ).attr( 'data-optionitem-price-override' ) ); 5368 option2_price_multiplier = Number( jQuery( '.ec_details_swatches > li.ec_option2_' + product_id + '_' + rand_id + '.ec_selected, .ec_details_swatches_ele > li.ec_option2_' + product_id + '_' + rand_id + '.ec_selected' ).attr( 'data-optionitem-price-multiplier' ) ); 5369 }else if( jQuery( '.ec_details_combo.ec_option2_' + product_id + '_' + rand_id ).length ){ 5370 option2_price_adj = jQuery( '.ec_details_combo.ec_option2_' + product_id + '_' + rand_id + ' option:selected' ).attr( 'data-optionitem-price' ); 5371 option2_price_add = jQuery( '.ec_details_combo.ec_option2_' + product_id + '_' + rand_id + ' option:selected' ).attr( 'data-optionitem-price-onetime' ); 5372 option2_price_override = Number( jQuery( '.ec_details_combo.ec_option2_' + product_id + '_' + rand_id + ' option:selected' ).attr( 'data-optionitem-price-override' ) ); 5373 option2_price_multiplier = Number( jQuery( '.ec_details_combo.ec_option2_' + product_id + '_' + rand_id + ' option:selected' ).attr( 'data-optionitem-price-multiplier' ) ); 5374 } 5375 // Option 3 Price Adjustment 5376 if( jQuery( '.ec_details_swatches > li.ec_option3_' + product_id + '_' + rand_id + '.ec_selected, .ec_details_swatches_ele > li.ec_option3_' + product_id + '_' + rand_id + '.ec_selected' ).length ){ 5377 option3_price_adj = jQuery( '.ec_details_swatches > li.ec_option3_' + product_id + '_' + rand_id + '.ec_selected, .ec_details_swatches_ele > li.ec_option3_' + product_id + '_' + rand_id + '.ec_selected' ).attr( 'data-optionitem-price' ); 5378 option3_price_add = jQuery( '.ec_details_swatches > li.ec_option3_' + product_id + '_' + rand_id + '.ec_selected, .ec_details_swatches_ele > li.ec_option3_' + product_id + '_' + rand_id + '.ec_selected' ).attr( 'data-optionitem-price-onetime' ); 5379 option3_price_override = Number( jQuery( '.ec_details_swatches > li.ec_option3_' + product_id + '_' + rand_id + '.ec_selected, .ec_details_swatches_ele > li.ec_option3_' + product_id + '_' + rand_id + '.ec_selected' ).attr( 'data-optionitem-price-override' ) ); 5380 option3_price_multiplier = Number( jQuery( '.ec_details_swatches > li.ec_option3_' + product_id + '_' + rand_id + '.ec_selected, .ec_details_swatches_ele > li.ec_option3_' + product_id + '_' + rand_id + '.ec_selected' ).attr( 'data-optionitem-price-multiplier' ) ); 5381 }else if( jQuery( '.ec_details_combo.ec_option3_' + product_id + '_' + rand_id ).length ){ 5382 option3_price_adj = jQuery( '.ec_details_combo.ec_option3_' + product_id + '_' + rand_id + ' option:selected' ).attr( 'data-optionitem-price' ); 5383 option3_price_add = jQuery( '.ec_details_combo.ec_option3_' + product_id + '_' + rand_id + ' option:selected' ).attr( 'data-optionitem-price-onetime' ); 5384 option3_price_override = Number( jQuery( '.ec_details_combo.ec_option3_' + product_id + '_' + rand_id + ' option:selected' ).attr( 'data-optionitem-price-override' ) ); 5385 option3_price_multiplier = Number( jQuery( '.ec_details_combo.ec_option3_' + product_id + '_' + rand_id + ' option:selected' ).attr( 'data-optionitem-price-multiplier' ) ); 5386 } 5387 // Option 4 Price Adjustment 5388 if( jQuery( '.ec_details_swatches > li.ec_option4_' + product_id + '_' + rand_id + '.ec_selected, .ec_details_swatches_ele > li.ec_option4_' + product_id + '_' + rand_id + '.ec_selected' ).length ){ 5389 option4_price_adj = jQuery( '.ec_details_swatches > li.ec_option4_' + product_id + '_' + rand_id + '.ec_selected, .ec_details_swatches_ele > li.ec_option4_' + product_id + '_' + rand_id + '.ec_selected' ).attr( 'data-optionitem-price' ); 5390 option4_price_add = jQuery( '.ec_details_swatches > li.ec_option4_' + product_id + '_' + rand_id + '.ec_selected, .ec_details_swatches_ele > li.ec_option4_' + product_id + '_' + rand_id + '.ec_selected' ).attr( 'data-optionitem-price-onetime' ); 5391 option4_price_override = Number( jQuery( '.ec_details_swatches > li.ec_option4_' + product_id + '_' + rand_id + '.ec_selected, .ec_details_swatches_ele > li.ec_option4_' + product_id + '_' + rand_id + '.ec_selected' ).attr( 'data-optionitem-price-override' ) ); 5392 option4_price_multiplier = Number( jQuery( '.ec_details_swatches > li.ec_option4_' + product_id + '_' + rand_id + '.ec_selected, .ec_details_swatches_ele > li.ec_option4_' + product_id + '_' + rand_id + '.ec_selected' ).attr( 'data-optionitem-price-multiplier' ) ); 5393 }else if( jQuery( '.ec_details_combo.ec_option4_' + product_id + '_' + rand_id ).length ){ 5394 option4_price_adj = jQuery( '.ec_details_combo.ec_option4_' + product_id + '_' + rand_id + ' option:selected' ).attr( 'data-optionitem-price' ); 5395 option4_price_add = jQuery( '.ec_d
5395etails_combo.ec_option4_' + product_id + '_' + rand_id + ' option:selected' ).attr( 'data-optionitem-price-onetime' ); 5396 option4_price_override = Number( jQuery( '.ec_details_combo.ec_option4_' + product_id + '_' + rand_id + ' option:selected' ).attr( 'data-optionitem-price-override' ) ); 5397 option4_price_multiplier = Number( jQuery( '.ec_details_combo.ec_option4_' + product_id + '_' + rand_id + ' option:selected' ).attr( 'data-optionitem-price-multiplier' ) ); 5398 } 5399 // Option 5 Price Adjustment 5400 if( jQuery( '.ec_details_swatches > li.ec_option5_' + product_id + '_' + rand_id + '.ec_selected, .ec_details_swatches_ele > li.ec_option5_' + product_id + '_' + rand_id + '.ec_selected' ).length ){ 5401 option5_price_adj = jQuery( '.ec_details_swatches > li.ec_option5_' + product_id + '_' + rand_id + '.ec_selected, .ec_details_swatches_ele > li.ec_option5_' + product_id + '_' + rand_id + '.ec_selected' ).attr( 'data-optionitem-price' ); 5402 option5_price_add = jQuery( '.ec_details_swatches > li.ec_option5_' + product_id + '_' + rand_id + '.ec_selected, .ec_details_swatches_ele > li.ec_option5_' + product_id + '_' + rand_id + '.ec_selected' ).attr( 'data-optionitem-price-onetime' ); 5403 option5_price_override = Number( jQuery( '.ec_details_swatches > li.ec_option5_' + product_id + '_' + rand_id + '.ec_selected, .ec_details_swatches_ele > li.ec_option5_' + product_id + '_' + rand_id + '.ec_selected' ).attr( 'data-optionitem-price-override' ) ); 5404 option5_price_multiplier = Number( jQuery( '.ec_details_swatches > li.ec_option5_' + product_id + '_' + rand_id + '.ec_selected, .ec_details_swatches_ele > li.ec_option5_' + product_id + '_' + rand_id + '.ec_selected' ).attr( 'data-optionitem-price-multiplier' ) ); 5405 }else if( jQuery( '.ec_details_combo.ec_option5_' + product_id + '_' + rand_id ).length ){ 5406 option5_price_adj = jQuery( '.ec_details_combo.ec_option5_' + product_id + '_' + rand_id + ' option:selected' ).attr( 'data-optionitem-price' ); 5407 option5_price_add = jQuery( '.ec_details_combo.ec_option5_' + product_id + '_' + rand_id + ' option:selected' ).attr( 'data-optionitem-price-onetime' ); 5408 option5_price_override = Number( jQuery( '.ec_details_combo.ec_option5_' + product_id + '_' + rand_id + ' option:selected' ).attr( 'data-optionitem-price-override' ) ); 5409 option5_price_multiplier = Number( jQuery( '.ec_details_combo.ec_option5_' + product_id + '_' + rand_id + ' option:selected' ).attr( 'data-optionitem-price-multiplier' ) ); 5410 } 5411 } 5412 var num_decimals = jQuery( document.getElementById( 'num_decimals_' + product_id + '_' + rand_id ) ).val(); 5413 var decimal_symbol = jQuery( document.getElementById( 'decimal_symbol_' + product_id + '_' + rand_id ) ).val(); 5414 var grouping_symbol = jQuery( document.getElementById( 'grouping_symbol_' + product_id + '_' + rand_id ) ).val(); 5415 var new_price = base_price + Number( option1_price_adj ) + Number( option2_price_adj ) + Number( option3_price_adj ) + Number( option4_price_adj ) + Number( option5_price_adj ); 5416 var order_price = Number( option1_price_add ) + Number( option2_price_add ) + Number( option3_price_add ) + Number( option4_price_add ) + Number( option5_price_add ); 5417 var override_price = -1; 5418 if( option1_price_override > -1 ) { 5419 override_price = option1_price_override; 5420 } else if( option2_price_override > -1 ) { 5421 override_price = option2_price_override; 5422 } else if( option3_price_override > -1 ) { 5423 override_price = option3_price_override; 5424 } else if( option4_price_override > -1 ) { 5425 override_price = option4_price_override; 5426 } else if( option5_price_override > -1 ) { 5427 override_price = option5_price_override; 5428 } 5429 if( override_price > -1 ){ 5430 jQuery( document.getElementById( 'ec_final_price_' + product_id + '_' + rand_id ) ).html( ec_details_format_money_v2( product_id, rand_id, override_price ) ); 5431 jQuery( document.getElementById( 'ec_base_option_price_' + product_id + '_' + rand_id ) ).val( override_price ); 5432 jQuery( '.ec_details_price.ec_details_single_price > .ec_product_sale_price_' + product_id + '_' + rand_id ).each( function( ){ jQuery( this ).html( e
5432c_details_format_money_v2( product_id, rand_id, override_price ) ); } ); 5433 jQuery( '.ec_details_price.ec_details_single_price > .ec_product_price_' + product_id + '_' + rand_id ).each( function( ){ jQuery( this ).html( ec_details_format_money_v2( product_id, rand_id, override_price ) ); } ); 5434 if ( '1' == vat_added ) { 5435 jQuery( '.ec_details_price.ec_details_no_vat_price > .ec_product_sale_price_' + product_id + '_' + rand_id ).each( function( ){ 5436 jQuery( this ).html( ec_details_format_money_v2( product_id, rand_id, override_price ) ); 5437 } ); 5438 jQuery( '.ec_details_price.ec_details_vat_price > .ec_product_sale_price_' + product_id + '_' + rand_id ).each( function( ){ 5439 jQuery( this ).html( ec_details_format_money_v2( product_id, rand_id, override_price * vat_rate_multiplier ) ); 5440 } ); 5441 jQuery( '.ec_details_price.ec_details_no_vat_price > .ec_product_price_' + product_id + '_' + rand_id ).each( function( ){ 5442 jQuery( this ).html( ec_details_format_money_v2( product_id, rand_id, override_price ) ); 5443 } ); 5444 jQuery( '.ec_details_price.ec_details_vat_price > .ec_product_price_' + product_id + '_' + rand_id ).each( function( ){ 5445 jQuery( this ).html( ec_details_format_money_v2( product_id, rand_id, override_price * vat_rate_multiplier ) ); 5446 } ); 5447 } else { 5448 jQuery( '.ec_details_price.ec_details_no_vat_price > .ec_product_sale_price_' + product_id + '_' + rand_id ).each( function( ){ 5449 jQuery( this ).html( ec_details_format_money_v2( product_id, rand_id, override_price / vat_rate_multiplier ) ); 5450 } ); 5451 jQuery( '.ec_details_price.ec_details_vat_price > .ec_product_sale_price_' + product_id + '_' + rand_id ).each( function( ){ 5452 jQuery( this ).html( ec_details_format_money_v2( product_id, rand_id, override_price ) ); 5453 } ); 5454 jQuery( '.ec_details_price.ec_details_no_vat_price > .ec_product_price_' + product_id + '_' + rand_id ).each( function( ){ 5455 jQuery( this ).html( ec_details_format_money_v2( product_id, rand_id, override_price / vat_rate_multiplier ) ); 5456 } ); 5457 jQuery( '.ec_details_price.ec_details_vat_price > .ec_product_price_' + product_id + '_' + rand_id ).each( function( ){ 5458 jQuery( this ).html( ec_details_format_money_v2( product_id, rand_id, override_price ) ); 5459 } ); 5460 } 5461 }else{ 5462 jQuery( document.getElementById( 'ec_final_price_' + product_id + '_' + rand_id ) ).html( ec_details_format_money_v2( product_id, rand_id, new_price ) ); 5463 jQuery( document.getElementById( 'ec_base_option_price_' + product_id + '_' + rand_id ) ).val( new_price ); 5464 jQuery( '.ec_details_price.ec_details_single_price > .ec_product_sale_price_' + product_id + '_' + rand_id ).each( function( ){ 5465 jQuery( this ).html( ec_details_format_money_v2( product_id, rand_id, new_price ) ); 5466 } ); 5467 jQuery( '.ec_details_price.ec_details_single_price > .ec_product_price_' + product_id + '_' + rand_id ).each( function( ){ 5468 jQuery( this ).html( ec_details_format_money_v2( product_id, rand_id, new_price ) ); 5469 } ); 5470 if ( '1' == vat_added ) { 5471 jQuery( '.ec_details_price.ec_details_no_vat_price > .ec_product_sale_price_' + product_id + '_' + rand_id ).each( function( ){ 5472 jQuery( this ).html( ec_details_format_money_v2( product_id, rand_id, new_price ) ); 5473 } ); 5474 jQuery( '.ec_details_price.ec_details_vat_price > .ec_product_sale_price_' + product_id + '_' + rand_id ).each( function( ){ 5475 jQuery( this ).html( ec_details_format_money_v2( product_id, rand_id, new_price * vat_rate_multiplier ) ); 5476 } ); 5477 jQuery( '.ec_details_price.ec_details_no_vat_price > .ec_product_price_' + product_id + '_' + rand_id ).each( function( ){ 5478 jQuery( this ).html( ec_details_format_money_v2( product_id, rand_id, new_price ) ); 5479 } ); 5480 jQuery( '.ec_details_price.ec_details_vat_price > .ec_product_price_' + product_id + '_' + rand_id ).each( function( ){ 5481 jQuery( this ).html( ec_details_format_money_v2( product_id, rand_id, new_price * vat_rate_multiplier ) ); 5482 } ); 5483 } else { 5484 jQuery( '.ec_details_price.ec_details_no_vat_price > .ec_product_sale_price_' + product_id + '_' + rand_id ).each( function( ){
5485 jQuery( this ).html( ec_details_format_money_v2( product_id, rand_id, new_price / vat_rate_multiplier ) ); 5486 } ); 5487 jQuery( '.ec_details_price.ec_details_vat_price > .ec_product_sale_price_' + product_id + '_' + rand_id ).each( function( ){ 5488 jQuery( this ).html( ec_details_format_money_v2( product_id, rand_id, new_price ) ); 5489 } ); 5490 jQuery( '.ec_details_price.ec_details_no_vat_price > .ec_product_price_' + product_id + '_' + rand_id ).each( function( ){ 5491 jQuery( this ).html( ec_details_format_money_v2( product_id, rand_id, new_price / vat_rate_multiplier ) ); 5492 } ); 5493 jQuery( '.ec_details_price.ec_details_vat_price > .ec_product_price_' + product_id + '_' + rand_id ).each( function( ){ 5494 jQuery( this ).html( ec_details_format_money_v2( product_id, rand_id, new_price ) ); 5495 } ); 5496 } 5497 } 5498 if( order_price != 0 ){ 5499 jQuery( '.ec_details_added_price_' + product_id + '_' + rand_id ).show( ); 5500 jQuery( document.getElementById( 'ec_added_price_' + product_id + '_' + rand_id ) ).html( ec_details_format_money_v2( product_id, rand_id, order_price ) ); 5501 }else{ 5502 jQuery( '.ec_details_added_price_' + product_id + '_' + rand_id ).hide( ); 5503 } 5504 ec_details_advanced_adjust_price( product_id, rand_id ); 5505} 5506function ec_details_advanced_conditional_logic( product_id, rand_id ) { 5507 var ec_advanced_logic_rules = window['ec_advanced_logic_rules_' + product_id + '_' + rand_id]; 5508 for( var i=0; i<ec_advanced_logic_rules.length; i++ ){ 5509 if( ec_advanced_logic_rules[i].rules.length > 0 ){ 5510 if( ec_advanced_logic_rules[i].show_field ){ 5511 jQuery( '.ec_details_option_row[data-product-option-id="' + ec_advanced_logic_rules[i].id + '"]' ).hide( ); 5512 }else{ 5513 jQuery( '.ec_details_option_row[data-product-option-id="' + ec_advanced_logic_rules[i].id + '"]' ).show( ); 5514 } 5515 if( ec_advanced_logic_rules[i].and_rules == 'AND' ){ 5516 var rules_match = true; 5517 for( var j=0; j<ec_advanced_logic_rules[i].rules.length; j++ ){ 5518 jQuery( '.ec_details_option_row' ).each( function( ){ 5519 if( jQuery( this ).attr( 'data-product-option-id' ) == ec_advanced_logic_rules[i].rules[j].option_id ){ 5520 var val = 0; 5521 var selected_val = ec_advanced_logic_rules[i].rules[j].optionitem_id; 5522 if ( jQuery( this ).hasClass( 'ec_option_type_checkbox' ) ) { 5523 if ( jQuery( this ).attr( 'data-product-option-id' ) == ec_advanced_logic_rules[i].rules[j].option_id ) { 5524 jQuery( this ).find( 'input' ).each( function( ){ 5525 if ( jQuery( this ).attr( 'data-optionitem-id' ) == ec_advanced_logic_rules[i].rules[j].optionitem_id && jQuery( this ).is( ':checked' ) ) { 5526 val = ec_advanced_logic_rules[i].rules[j].optionitem_id; 5527 } 5528 } ); 5529 } 5530 5531 }else if( jQuery( this ).hasClass( 'ec_option_type_radio' ) ){ 5532 jQuery( this ).find( 'input' ).each( function( ){ 5533 if( jQuery( this ).val( ) == ec_advanced_logic_rules[i].rules[j].optionitem_id ){ 5534 if( jQuery( this ).is( ':checked' ) ){ 5535 val = ec_advanced_logic_rules[i].rules[j].optionitem_id; 5536 } 5537 } 5538 } ); 5539 5540 }else if( jQuery( this ).hasClass( 'ec_option_type_swatch' ) ){ 5541 jQuery( this ).find( '.ec_details_swatch.ec_selected' ).each( function( ){ 5542 if( jQuery( this ).attr( 'data-optionitem-id' ) == ec_advanced_logic_rules[i].rules[j].optionitem_id ){ 5543 val = ec_advanced_logic_rules[i].rules[j].optionitem_id; 5544 } 5545 } ); 5546 jQuery( this ).find( '.ec_details_swatch_ele.ec_selected' ).each( function( ){ 5547 if( jQuery( this ).attr( 'data-optionitem-id' ) == ec_advanced_logic_rules[i].rules[j].optionitem_id ){ 5548 val = ec_advanced_logic_rules[i].rules[j].optionitem_id; 5549 } 5550 } ); 5551 5552 }else if( jQuery( this ).hasClass( 'ec_option_type_combo' ) ){ 5553 var val = jQuery( this ).find( 'select' ).val( ); 5554 5555 }else if( jQuery( this ).hasClass( 'ec_option_type_textarea' ) ){ 5556 var val = jQuery( this ).find( 'textarea' ).val( ); 5557 selected_val = ec_advanced_logic_rules[i].rules[j].optionitem_value; 5558 5559 }else{ 5560 var val = jQuery( this ).find( 'input' ).val( ); 5561 selected_val = ec_advanced_logic_rules[i].rules[j].optionitem_value; 5562 } 5563 if( ec_advanced_logic_rules[i].rules[j].operator == '=' ){ 5564 if( val != selected_val ){ 5565 rules_match = false; 5566 } 5567 }else if( ec_advanced_logic_rules[i].rules[j].operator == '!=' ){ 5568 if( val == selected_val ){ 5569 rules_match = false; 5570 } 5571 } 5572 } 5573 } ); 5574 } 5575 }else{ 5576 var rules_match = false; 5577 for( var j=0; j<ec_advanced_logic_rules[i].rules.length; j++ ){ 5578 jQuery( '.ec_details_option_row' ).each( function( ){
5579 if( jQuery( this ).attr( 'data-product-option-id' ) == ec_advanced_logic_rules[i].rules[j].option_id ){ 5580 var val = 0; 5581 var selected_val = ec_advanced_logic_rules[i].rules[j].optionitem_id; 5582 if ( jQuery( this ).hasClass( 'ec_option_type_checkbox' ) ) { 5583 if ( jQuery( this ).attr( 'data-product-option-id' ) == ec_advanced_logic_rules[i].rules[j].option_id ) { 5584 jQuery( this ).find( 'input' ).each( function( ){ 5585 if ( jQuery( this ).attr( 'data-optionitem-id' ) == ec_advanced_logic_rules[i].rules[j].optionitem_id && jQuery( this ).is( ':checked' ) ) { 5586 val = ec_advanced_logic_rules[i].rules[j].optionitem_id; 5587 } 5588 } ); 5589 } 5590 5591 }else if( jQuery( this ).hasClass( 'ec_option_type_radio' ) ){ 5592 jQuery( this ).find( 'input' ).each( function( ){ 5593 if( jQuery( this ).val( ) == ec_advanced_logic_rules[i].rules[j].optionitem_id ){ 5594 if( jQuery( this ).is( ':checked' ) ){ 5595 val = ec_advanced_logic_rules[i].rules[j].optionitem_id; 5596 } 5597 } 5598 } ); 5599 5600 }else if( jQuery( this ).hasClass( 'ec_option_type_swatch' ) ){ 5601 jQuery( this ).find( '.ec_details_swatch.ec_selected' ).each( function( ){ 5602 if( jQuery( this ).attr( 'data-optionitem-id' ) == ec_advanced_logic_rules[i].rules[j].optionitem_id ){ 5603 val = ec_advanced_logic_rules[i].rules[j].optionitem_id; 5604 } 5605 } ); 5606 jQuery( this ).find( '.ec_details_swatch_ele.ec_selected' ).each( function( ){ 5607 if( jQuery( this ).attr( 'data-optionitem-id' ) == ec_advanced_logic_rules[i].rules[j].optionitem_id ){ 5608 val = ec_advanced_logic_rules[i].rules[j].optionitem_id; 5609 } 5610 } ); 5611 5612 }else if( jQuery( this ).hasClass( 'ec_option_type_combo' ) ){ 5613 var val = jQuery( this ).find( 'select' ).val( ); 5614 5615 }else if( jQuery( this ).hasClass( 'ec_option_type_textarea' ) ){ 5616 var val = jQuery( this ).find( 'textarea' ).val( ); 5617 selected_val = ec_advanced_logic_rules[i].rules[j].optionitem_value; 5618 5619 }else{ 5620 var val = jQuery( this ).find( 'input' ).val( ); 5621 selected_val = ec_advanced_logic_rules[i].rules[j].optionitem_value; 5622 } 5623 if( ec_advanced_logic_rules[i].rules[j].operator == '=' ){ 5624 if( val == selected_val ){ 5625 rules_match = true; 5626 } 5627 }else if( ec_advanced_logic_rules[i].rules[j].operator == '!=' ){ 5628 if( val != selected_val ){ 5629 rules_match = true; 5630 } 5631 } 5632 } 5633 } ); 5634 } 5635 } 5636 if( rules_match ){ 5637 if( ec_advanced_logic_rules[i].show_field ){ 5638 jQuery( '.ec_details_option_row[data-product-option-id="' + ec_advanced_logic_rules[i].id + '"]' ).show( ); 5639 }else{ 5640 jQuery( '.ec_details_option_row[data-product-option-id="' + ec_advanced_logic_rules[i].id + '"]' ).hide( ); 5641 if( jQuery( '.ec_details_option_row[data-product-option-id="' + ec_advanced_logic_rules[i].id + '"]' ).hasClass( 'ec_option_type_checkbox' ) ){ 5642 jQuery( '.ec_details_option_row[data-product-option-id="' + ec_advanced_logic_rules[i].id + '"]' ).find( 'input' ).each( function( ){ jQuery( this ).attr( 'checked', false ); } ); 5643 }else if( jQuery( '.ec_details_option_row[data-product-option-id="' + ec_advanced_logic_rules[i].id + '"]' ).hasClass( 'ec_option_type_radio' ) ){ 5644 jQuery( '.ec_details_option_row[data-product-option-id="' + ec_advanced_logic_rules[i].id + '"]' ).find( 'input' ).each( function( ){ jQuery( this ).prop( 'checked', false ); } ); 5645 }else if( jQuery( '.ec_details_option_row[data-product-option-id="' + ec_advanced_logic_rules[i].id + '"]' ).hasClass( 'ec_option_type_swatch' ) ){ 5646 jQuery( '.ec_details_option_row[data-product-option-id="' + ec_advanced_logic_rules[i].id + '"]' ).find( '.ec_details_swatch' ).each( function( ){ jQuery( this ).removeClass( 'ec_selected' ); } ); 5647 jQuery( '.ec_details_option_row[data-product-option-id="' + ec_advanced_logic_rules[i].id + '"]' ).find( '.ec_details_swatch_ele' ).each( function( ){ jQuery( this ).removeClass( 'ec_selected' ); } ); 5648 jQuery( document.getElementById( 'ec_option_adv_' + ec_advanced_logic_rules[i].id + '_' + product_id + '_' + rand_id ) ).val( '0' ); 5649 }else{ 5650 jQuery( '.ec_details_option_row[data-product-option-id="' + ec_advanced_logic_rules[i].id + '"]' ).find( 'input' ).each( function( ){ jQuery( this ).val( '' ); } ); 5651 jQuery( '.ec_details_option_row[data-product-option-id="' + ec_advanced_logic_rules[i].id + '"]' ).find( 'textarea' ).each( function( ){ jQuery( this ).val( '' ); } ); 5652 jQuery( '.ec_details_option_row[data-product-option-id="' + ec_advanced_logic_rules[i].id + '"]' ).find( 'select' ).each( function( ){ jQuery( this ).val( 0 ); } ); 5653 } 5654 } 5655 }else{ 5656 if( ec_advanced_logic_rules[i].show_field ){
5657 if( jQuery( '.ec_details_option_row[data-product-option-id="' + ec_advanced_logic_rules[i].id + '"]' ).hasClass( 'ec_option_type_checkbox' ) ){ 5658 jQuery( '.ec_details_option_row[data-product-option-id="' + ec_advanced_logic_rules[i].id + '"]' ).find( 'input' ).each( function( ){ jQuery( this ).attr( 'checked', false ); } ); 5659 }else if( jQuery( '.ec_details_option_row[data-product-option-id="' + ec_advanced_logic_rules[i].id + '"]' ).hasClass( 'ec_option_type_radio' ) ){ 5660 jQuery( '.ec_details_option_row[data-product-option-id="' + ec_advanced_logic_rules[i].id + '"]' ).find( 'input' ).each( function( ){ jQuery( this ).prop( 'checked', false ); } ); 5661 }else if( jQuery( '.ec_details_option_row[data-product-option-id="' + ec_advanced_logic_rules[i].id + '"]' ).hasClass( 'ec_option_type_swatch' ) ){ 5662 jQuery( '.ec_details_option_row[data-product-option-id="' + ec_advanced_logic_rules[i].id + '"]' ).find( '.ec_details_swatch' ).each( function( ){ jQuery( this ).removeClass( 'ec_selected' ); } ); 5663 jQuery( '.ec_details_option_row[data-product-option-id="' + ec_advanced_logic_rules[i].id + '"]' ).find( '.ec_details_swatch_ele' ).each( function( ){ jQuery( this ).removeClass( 'ec_selected' ); } ); 5664 jQuery( document.getElementById( 'ec_option_adv_' + ec_advanced_logic_rules[i].id + '_' + product_id + '_' + rand_id ) ).val( '0' ); 5665 }else{ 5666 jQuery( '.ec_details_option_row[data-product-option-id="' + ec_advanced_logic_rules[i].id + '"]' ).find( 'input' ).each( function( ){ jQuery( this ).val( '' ); } ); 5667 jQuery( '.ec_details_option_row[data-product-option-id="' + ec_advanced_logic_rules[i].id + '"]' ).find( 'textarea' ).each( function( ){ jQuery( this ).val( '' ); } ); 5668 jQuery( '.ec_details_option_row[data-product-option-id="' + ec_advanced_logic_rules[i].id + '"]' ).find( 'select' ).each( function( ){ jQuery( this ).val( 0 ); } ); 5669 } 5670 } 5671 } 5672 } 5673 } 5674} 5675 5676function ec_option1_image_change( product_id, rand_id, optionitem_id_1, quantity ){ 5677 var use_optionitem_images = jQuery( document.getElementById( 'use_optionitem_images_' + product_id + '_' + rand_id ) ).val(); 5678 if( '1' == use_optionitem_images ){ 5679 if ( ! jQuery( '.ec_details_main_image_' + product_id + '_' + rand_id ).length ) { 5680 if ( jQuery( '.ec_details_main_image[data-product-id="' + product_id + '"]' ).length ) { 5681 rand_id = jQuery( '.ec_details_main_image[data-product-id="' + product_id + '"]' ).attr( 'data-rand-id' ); 5682 } 5683 } 5684 if( jQuery( document.getElementById( 'ec_details_thumbnails_' + optionitem_id_1 + '_' + product_id + '_' + rand_id ) ).length ){ 5685 jQuery( '.ec_details_thumbnails_' + product_id + '_' + rand_id ).addClass( 'ec_inactive' ); 5686 jQuery( '.ec_details_large_popup_thumbnails_' + product_id + '_' + rand_id ).addClass( 'ec_inactive' ); 5687 jQuery( document.getElementById( 'ec_details_thumbnails_' + optionitem_id_1 + '_' + product_id + '_' + rand_id ) ).find( '.ec_details_thumbnail' ).first( ).trigger( 'click' ); 5688 if( !jQuery( document.getElementById( 'ec_details_thumbnails_' + optionitem_id_1 + '_' + product_id + '_' + rand_id ) ).hasClass( 'ec_no_thumbnails' ) ){ 5689 jQuery( document.getElementById( 'ec_details_thumbnails_' + optionitem_id_1 + '_' + product_id + '_' + rand_id ) ).removeClass( 'ec_inactive' ); 5690 if( jQuery( document.getElementById( 'ec_details_large_popup_thumbnails_' + optionitem_id_1 + '_' + product_id + '_' + rand_id ) ) ){ 5691 jQuery( document.getElementById( 'ec_details_large_popup_thumbnails_' + optionitem_id_1 + '_' + product_id + '_' + rand_id ) ).removeClass( 'ec_inactive' ); 5692 } 5693 } 5694 } else if( jQuery( '.ec_details_thumbnails_' + product_id + '_' + rand_id ).length ){ 5695 jQuery( '.ec_details_thumbnails_' + product_id + '_' + rand_id ).addClass( 'ec_inactive' ); 5696 jQuery( '.ec_details_large_popup_thumbnails_' + product_id + '_' + rand_id ).addClass( 'ec_inactive' ); 5697 jQuery( '.ec_details_thumbnails_' + product_id + '_' + rand_id ).first().find( '.ec_details_thumbnail' ).first( ).trigger( 'click' ); 5698 if ( ! jQuery( '.ec_details_thumbnails_' + product_id + '_' + rand_id ).first().hasClass( 'ec_no_thumbnails' ) ){ 5699 jQuery( '.ec_details_thumbnails_' + product_id + '_' + rand_id ).first().removeClass( 'ec_inactive' ); 5700 if ( jQuery( '.ec_details_large_popup_thumbnails_' + product_id + '_' + rand_id ).length ) { 5701 jQuery( '.ec_details_large_popup_thumbnails_' + product_id + '_' + rand_id ).first().removeClass( 'ec_inactive' ); 5702 } 5703 } 5704 } 5705 } 5706} 5707function ec_option1_init_combo( product_id, rand_id ){ 5708 if ( 5709 ! jQuery( 'select.ec_option2_' + product_id + '_' + rand_id ).length && 5710 ! jQuery( 'li.ec_option2_' + product_id + '_' + rand_id ).length 5711 ) { 5712 jQuery( 'select.ec_option1_' + product_id + '_' + rand_id + ' > option' ).each( function() { 5713 var optionitem_id_1 = jQuery( this ).attr( 'value' ); 5714 if ( 5715 window['varitation_data_' + product_id + '_' + rand_id ] && 5716 window['varitation_data_' + product_id + '_' + rand_id][optionitem_id_1 + '0000'] 5717 ) { 5718 var use_optionitem_quantity_tracking = jQuery( document.getElementById( 'use_optionitem_quantity_tracking_' + product_id + '_' + rand_id ) ).val(); 5719 if ( jQuery( document.getElementById( 'ec_allow_backorders_' + product_id + '_' + rand_id ) ).length && '1' == jQuery( document.getElementById( 'ec_allow_backorders_' + product_id + '_' + rand_id ) ).val() ) { 5720 use_optionitem_quantity_tracking = '0'; 5721 } 5722 if ( 5723 window['varitation_data_' + product_id + '_' + rand_id][optionitem_id_1 + '0000'].enabled && 5724 ( 5725 '0' == use_optionitem_quantity_tracking || 5726 ! window['varitation_data_' + product_id + '_' + rand_id][optionitem_id_1 + '0000'].tracking || 5727 window['varitation_data_' + product_id + '_' + rand_id][optionitem_id_1 + '0000'].quantity > 0 5728 ) 5729 ) { 5730 jQuery( this ).show().attr( 'disabled', false ); 5731 } else { 5732 jQuery( this ).hide().attr( 'disabled', true ); 5733 } 5734 } else { 5735 jQuery( this ).show().attr( 'disabled', false ); 5736 } 5737 } ); 5738 } 5739} 5740function ec_option1_init_swatches( product_id, rand_id, swatch, optionitem_id_1 ){ 5741 if ( 5742 ! jQuery( 'select.ec_option2_' + product_id + '_' + rand_id ).length && 5743 ! jQuery( 'li.ec_option2_' + product_id + '_' + rand_id ).length 5744 ) { 5745 if ( 5746 window['varitation_data_' + product_id + '_' + rand_id ] && 5747 window['varitation_data_' + product_id + '_' + rand_id][optionitem_id_1 + '0000'] 5748 ) { 5749 var use_optionitem_quantity_tracking = jQuery( document.getElementById( 'use_optionitem_quantity_tracking_' + product_id + '_' + rand_id ) ).val(); 5750 if ( jQuery( document.getElementById( 'allow_backorders' ) ).length && '1' == jQuery( document.getElementById( 'allow_backorders' ) ) ) { 5751 use_optionitem_quantity_tracking = '0'; 5752 } 5753 if ( 5754 window['varitation_data_' + product_id + '_' + rand_id][optionitem_id_1 + '0000'].enabled && 5755 ( 5756 '0' == use_optionitem_quantity_tracking || 5757 ! window['varitation_data_' + product_id + '_' + rand_id][optionitem_id_1 + '0000'].tracking || 5758 window['varitation_data_' + product_id + '_' + rand_id][optionitem_id_1 + '0000'].quantity > 0 5759 ) 5760 ) { 5761 swatch.addClass( 'ec_active' ).removeClass( 'ec_selected' ); 5762 } else if ( 5763 ! window['varitation_data_' + product_id + '_' + rand_id][optionitem_id_1 + '0000'].enabled 5764 ) { 5765 swatch.hide().removeClass( 'ec_active' ).removeClass( 'ec_selected' ); 5766 } else { 5767 swatch.removeClass( 'ec_active' ).removeClass( 'ec_selected' ); 5768 } 5769 } else { 5770 swatch.addClass( 'ec_active' ).removeClass( 'ec_selected' ); 5771 } 5772 } 5773} 5774function ec_option1_updated( product_id, rand_id, optionitem_id_1 ) { 5775 if ( jQuery( 'select.ec_option2_' + product_id + '_' + rand_id ).length ) { 5776 if ( ! jQuery( 'select.ec_option2_' + product_id + '_' + rand_id + '_backup' ).length ) { 5777 jQuery( '<select style="display:none" class="ec_option2_' + product_id + '_' + rand_id + '_backup"></select>' ).insertBefore( 'select.ec_option2_' + product_id + '_' + rand_id ); 5778 var options_copy = jQuery( 'select.ec_option2_' + product_id + '_' + rand_id + ' > option' ).clone(); 5779 jQuery( 'select.ec_option2_' + product_id + '_' + rand_id + '_backup' ).append( options_copy ); 5780 } else { 5781 jQuery ( 'select.ec_option2_' + product_id + '_' + rand_id + ' > option' ).remove(); 5782 var options_backup_copy = jQuery ( 'select.ec_option2_' + product_id + '_' + rand_id + '_backup > option' ).clone(); 5783 jQuery ( 'select.ec_option2_' + product_id + '_' + rand_id ).append( options_backup_copy ); 5784 } 5785 5786 jQuery ( 'select.ec_option2_' + product_id + '_' + rand_id + ' > option' ).each( function() { 5787 if ( window['varitation_data_' + product_id + '_' + rand_id ] && window['varitation_data_' + product_id + '_' + rand_id][optionitem_id_1 + jQuery( this ).attr( 'value' ) + '000'] ) { 5788 if ( window['varitation_data_' + product_id + '_' + rand_id ] && window['varitation_data_' + product_id + '_' + rand_id][optionitem_id_1 + jQuery( this ).attr( 'value' ) + '000'].enabled ) { 5789 jQuery( this ).show().attr( 'disabled', false ); 5790 } else { 5791 jQuery( this ).remove(); 5792 } 5793 } else { 5794 jQuery( this ).show().attr( 'disabled', false ); 5795 } 5796 } ); 5797 } else if ( jQuery( 'li.ec_option2_' + product_id + '_' + rand_id ).length ) { 5798 jQuery ( 'li.ec_option2_' + product_id + '_' + rand_id ).each( function() { 5799 if ( window['varitation_data_' + product_id + '_' + rand_id ] && window['varitation_data_' + product_id + '_' + rand_id][optionitem_id_1 + jQuery( this ).attr( 'data-optionitem-id' ) + '000'] ) { 5800 if ( window['varitation_data_' + product_id + '_' + rand_id ] && window['varitation_data_' + product_id + '_' + rand_id][optionitem_id_1 + jQuery( this ).attr( 'data-optionitem-id' ) + '000'].enabled ) { 5801 jQuery( this ).addClass( 'ec_active' ); 5802 } else { 5803 if ( jQuery( this ).hasClass( 'ec_selected' ) ) { 5804 jQuery( '.ec_details_option_label_selected_2' ).html( '' ); 5805 } 5806 jQuery( this ).removeClass( 'ec_active' ).removeClass( 'ec_selected' ); 5807 } 5808 } else { 5809 jQuery( this ).addClass( 'ec_active' ); 5810 } 5811 } ); 5812 } 5813} 5814function ec_option1_selected( product_id, rand_id, optionitem_id_1, quantity ){ 5815 var variation = false; 5816 if ( window['varitation_data_' + product_id + '_' + rand_id ] && window['varitation_data_' + product_id + '_' + rand_id][optionitem_id_1 + '0000'] ) { 5817 variation = window['varitation_data_' + product_id + '_' + rand_id][optionitem_id_1 + '0000']; 5818 } 5819 if( variation ) { 5820 quantity = ( variation.tracking ) ? variation.quantity : 'inf'; 5821 quantity = ( variation.enabled ) ? quantity : 0; 5822 } 5823 5824 var use_optionitem_images = jQuery( document.getElementById( 'use_optionitem_images_' + product_id + '_' + rand_id ) ).val(); 5825 if( '1' == use_optionitem_images ){ 5826 jQuery( '.ec_details_thumbnails_' + product_id + '_' + rand_id ).addClass( 'ec_inactive' ); 5827 jQuery( '.ec_details_large_popup_thumbnails_' + product_id + '_' + rand_id ).addClass( 'ec_inactive' ); 5828 jQuery( document.getElementById( 'ec_details_thumbnails_' + optionitem_id_1 + '_' + product_id + '_' + rand_id ) ).find( '.ec_details_thumbnail' ).first( ).trigger( 'click' ); 5829 if( !jQuery( document.getElementById( 'ec_details_thumbnails_' + optionitem_id_1 + '_' + product_id + '_' + rand_id ) ).hasClass( 'ec_no_thumbnails' ) ){ 5830 jQuery( document.getElementById( 'ec_details_thumbnails_' + optionitem_id_1 + '_' + product_id + '_' + rand_id ) ).removeClass( 'ec_inactive' ); 5831 jQuery( document.getElementById( 'ec_details_large_popup_thumbnails_' + optionitem_id_1 + '_' + product_id + '_' + rand_id ) ).removeClass( 'ec_inactive' ); 5832 } 5833 } 5834 jQuery( '.ec_details_swatches > li.ec_option2_' + product_id + '_' + rand_id + ', .ec_details_swatches_ele > li.ec_option2_' + product_id + '_' + rand_id ).removeClass( 'ec_selected' ).removeClass( 'ec_active' ); 5835 jQuery( '.ec_details_swatches > li.ec_option3_' + product_id + '_' + rand_id + ', .ec_details_swatches_ele > li.ec_option3_' + product_id + '_' + rand_id ).removeClass( 'ec_selected' ).removeClass( 'ec_active' ); 5836 jQuery( '.ec_details_swatches > li.ec_option4_' + product_id + '_' + rand_id + ', .ec_details_swatches_ele > li.ec_option4_' + product_id + '_' + rand_id ).removeClass( 'ec_selected' ).removeClass( 'ec_active' ); 5837 jQuery( '.ec_details_swatches > li.ec_option5_' + product_id + '_' + rand_id + ', .ec_details_swatches_ele > li.ec_option5_' + product_id + '_' + rand_id ).removeClass( 'ec_selected' ).removeClass( 'ec_active' ); 5838 jQuery( '.ec_details_combo.ec_option2_' + product_id + '_' + rand_id ).val( '0' ).prop( 'disabled', true ).addClass( 'ec_inactive' ); 5839 jQuery( '.ec_details_combo.ec_option3_' + product_id + '_' + rand_id ).val( '0' ).prop( 'disabled', true ).addClass( 'ec_inactive' ); 5840 jQuery( '.ec_details_combo.ec_option4_' + product_id + '_' + rand_id ).val( '0' ).prop( 'disabled', true ).addClass( 'ec_inactive' ); 5841 jQuery( '.ec_details_combo.ec_option5_' + product_id + '_' + rand_id ).val( '0' ).prop( 'disabled', true ).addClass( 'ec_inactive' ); 5842 jQuery( '.ec_details_option_label_selected_2, .ec_details_option_label_selected_3, .ec_details_option_label_selected_4, .ec_details_option_label_selected_5' ).html( '' ); 5843 jQuery( document.getElementById( 'ec_details_stock_quantity_' + product_id + '_' + rand_id ) ).html( quantity ); 5844 if ( 'inf' != quantity ) { 5845 jQuery( '.ec_details_stock_total' ).show(); 5846 } else { 5847 jQuery( '.ec_details_stock_total' ).hide(); 5848 } 5849 jQuery( document.getElementById('ec_quantity_' + product_id + '_' + rand_id ) ).attr( 'max', quantity ); 5850 if( Number( jQuery( document.getElementById('ec_quantity_' + product_id + '_' + rand_id ) ).val( ) ) > Number( quantity ) ){ 5851 jQuery( document.getElementById('ec_quantity_' + product_id + '_' + rand_id ) ).val( quantity ); 5852 } 5853 jQuery( document.getElementById( 'ec_option_loading_2_' + product_id + '_' + rand_id ) ).show( ); 5854 var next_options = jQuery( '.ec_details_swatches > li.ec_option2_' + product_id + '_' + rand_id + ', .ec_details_swatches_ele > li.ec_option2_' + product_id + '_' + rand_id ); 5855 if( next_options.length ){ 5856 next_options.each( function( ){ 5857 jQuery( this ).show().removeClass( 'ec_active' ).removeClass( 'ec_disabled_variant' ).addClass( 'ec_no_data_variant' ); 5858 } ); 5859 var data = { 5860 action: 'ec_ajax_get_optionitem_quantities', 5861 optionitem_id_1: optionitem_id_1, 5862 product_id: product_id, 5863 nonce: jQuery( document.getElementById( 'product_details_nonce_' + product_id + '_' + rand_id ) ).val() 5864 }; 5865 jQuery.ajax( { 5866 url: wpeasycart_ajax_object.ajax_url, 5867 type: 'post', 5868 data: data, 5869 cache: false, 5870 success: function( data ){ 5871 var json_data = JSON.parse( data ); 5872 jQuery( document.getElementById( 'ec_option_loading_2_' + product_id + '_' + rand_id ) ).hide( ); 5873 var found_i = -1; 5874 next_options.each( function( ){ 5875 for ( var i = 0; i < json_data.length && -1 == found_i; i++ ) { 5876 if ( jQuery( this ).attr( 'data-optionitem-id' ) == json_data[i].optionitem_id ) { 5877 found_i = i; 5878 } 5879 } 5880 if ( -1 != found_i && found_i < json_data.length ) { 5881 jQuery( this ).attr( 'data-optionitem-quantity', json_data[ found_i ].quantity ); 5882 if ( ! json_data[ found_i ].is_enabled ) { 5883 jQuery( this ).show().addClass( 'ec_disabled_variant' ).removeClass( 'ec_no_data_variant' ); 5884 } else if( json_data[ found_i ].quantity > 0 || '0' == json_data[ found_i ].tracking ){ 5885 jQuery( this ).show().addClass( 'ec_active' ).removeClass( 'ec_no_data_variant' ); 5886 } 5887 var subitem_variation = false; 5888 if ( window['varitation_data_' + product_id + '_' + rand_id ] && window['varitation_data_' + product_id + '_' + rand_id][optionitem_id_1 + jQuery( this ).attr( 'data-optionitem-id' ) + '000'] ) { 5889 subitem_variation = window['varitation_data_' + product_id + '_' + rand_id][optionitem_id_1 + jQuery( this ).attr( 'data-optionitem-id' ) + '000']; 5890 } 5891 if( subitem_variation ) { 5892 if ( ! subitem_variation.enabled ) { 5893 jQuery( this ).hide(); 5894 } 5895 } 5896 } 5897 found_i = -1; 5898 } ); 5899 } 5900 } ); 5901 }else{ 5902 next_options = jQuery( '.ec_details_combo.ec_option2_' + product_id + '_' + rand_id + ' option' );
5903 next_options.each( function( ){ 5904 jQuery( this ).removeClass( 'ec_active' ); 5905 } ); 5906 var data = { 5907 action: 'ec_ajax_get_optionitem_quantities', 5908 optionitem_id_1: optionitem_id_1, 5909 product_id: product_id, 5910 nonce: jQuery( document.getElementById( 'product_details_nonce_' + product_id + '_' + rand_id ) ).val() 5911 }; 5912 jQuery.ajax( { 5913 url: wpeasycart_ajax_object.ajax_url, 5914 type: 'post', 5915 data: data, 5916 cache: false, 5917 success: function( data ){ 5918 jQuery( '.ec_details_combo.ec_option2_' + product_id + '_' + rand_id ).prop( 'disabled', false ).removeClass( 'ec_inactive' ); 5919 var json_data = JSON.parse( data ); 5920 jQuery( document.getElementById( 'ec_option_loading_2_' + product_id + '_' + rand_id ) ).hide( ); 5921 var found_i = -1; 5922 next_options.each( function( ){ 5923 for ( var i = 0; i < json_data.length && -1 == found_i; i++ ) { 5924 if ( jQuery( this ).val( ) == json_data[i].optionitem_id ) { 5925 found_i = i; 5926 } 5927 } 5928 if ( -1 != found_i && found_i < json_data.length ) { 5929 jQuery( this ).attr( 'data-optionitem-quantity', ( ( '1' == json_data[ found_i ].tracking ) ? json_data[ found_i ].quantity : 'inf' ) ); 5930 if( json_data[ found_i ].quantity > 0 || '0' == json_data[ found_i ].tracking ){ 5931 jQuery( this ).show().attr( 'disabled', false ); 5932 } else { 5933 jQuery( this ).hide().attr( 'disabled', true ); 5934 } 5935 var subitem_variation = false; 5936 if ( window['varitation_data_' + product_id + '_' + rand_id ] && window['varitation_data_' + product_id + '_' + rand_id][optionitem_id_1 + jQuery( this ).val() + '000'] ) { 5937 subitem_variation = window['varitation_data_' + product_id + '_' + rand_id][optionitem_id_1 + jQuery( this ).val() + '000']; 5938 } 5939 if( subitem_variation ) { 5940 if ( ! subitem_variation.enabled ) { 5941 jQuery( this ).hide().prop( 'disabled', true ); 5942 } 5943 } 5944 } else { 5945 jQuery( this ).attr( 'data-optionitem-quantity', 0 ).hide().attr( 'disabled', true ); 5946 } 5947 found_i = -1; 5948 } ); 5949 } 5950 } ); 5951 } 5952} 5953function ec_option2_updated( product_id, rand_id, optionitem_id_1, optionitem_id_2 ) { 5954 if ( jQuery( 'select.ec_option3_' + product_id + '_' + rand_id ).length ) { 5955 if ( ! jQuery( 'select.ec_option3_' + product_id + '_' + rand_id + '_backup' ).length ) { 5956 jQuery( '<select style="display:none" class="ec_option3_' + product_id + '_' + rand_id + '_backup"></select>' ).insertBefore( 'select.ec_option3_' + product_id + '_' + rand_id ); 5957 var options_copy = jQuery( 'select.ec_option3_' + product_id + '_' + rand_id + ' > option' ).clone(); 5958 jQuery( 'select.ec_option3_' + product_id + '_' + rand_id + '_backup' ).append( options_copy ); 5959 } else { 5960 jQuery ( 'select.ec_option3_' + product_id + '_' + rand_id + ' > option' ).remove(); 5961 var options_backup_copy = jQuery ( 'select.ec_option3_' + product_id + '_' + rand_id + '_backup > option' ).clone(); 5962 jQuery ( 'select.ec_option3_' + product_id + '_' + rand_id ).append( options_backup_copy ); 5963 } 5964 5965 jQuery ( 'select.ec_option3_' + product_id + '_' + rand_id + ' > option' ).each( function() { 5966 if ( window['varitation_data_' + product_id + '_' + rand_id ] && window['varitation_data_' + product_id + '_' + rand_id][optionitem_id_1 + optionitem_id_2 + jQuery( this ).attr( 'value' ) + '00'] ) { 5967 if ( window['varitation_data_' + product_id + '_' + rand_id ] && window['varitation_data_' + product_id + '_' + rand_id][optionitem_id_1 + optionitem_id_2 + jQuery( this ).attr( 'value' ) + '00'].enabled ) { 5968 jQuery( this ).show().attr( 'disabled', false ); 5969 } else { 5970 jQuery( this ).remove(); 5971 } 5972 } else { 5973 jQuery( this ).show().attr( 'disabled', false ); 5974 } 5975 } ); 5976 } else if ( jQuery( 'li.ec_option3_' + product_id + '_' + rand_id ).length ) { 5977 jQuery ( 'li.ec_option3_' + product_id + '_' + rand_id ).each( function() { 5978 if ( window['varitation_data_' + product_id + '_' + rand_id ] && window['varitation_data_' + product_id + '_' + rand_id][optionitem_id_1 + optionitem_id_2 + jQuery( this ).attr( 'data-optionitem-id' ) + '00'] ) { 5979 if ( window['varitation_data_' + product_id + '_' + rand_id ] && window['varitation_data_' + product_id + '_' + rand_id][optionitem_id_1 + optionitem_id_2 + jQuery( this ).attr( 'data-optionitem-id' ) + '00'].enabled ) { 5980 jQuery( this ).addClass( 'ec_active' ); 5981 } else { 5982 if ( jQuery( this ).hasClass( 'ec_selected' ) ) { 5983 jQuery( '.ec_details_option_label_selected_3' ).html( '' ); 5984 } 5985 jQuery( this ).removeClass( 'ec_active' ).removeClass( 'ec_selected' ); 5986 } 5987 } else { 5988 jQuery( this ).addClass( 'ec_active' ); 5989 } 5990 } ); 5991 } 5992} 5993function option2_selected( product_id, rand_id, optionitem_id_1, optionitem_id_2, quantity ){ 5994 var variation = false; 5995 if ( window['varitation_data_' + product_id + '_' + rand_id ] && window['varitation_data_' + product_id + '_' + rand_id][optionitem_id_1 + optionitem_id_2 + '000'] ) { 5996 variation = window['varitation_data_' + product_id + '_' + rand_id][optionitem_id_1 + optionitem_id_2 + '000']; 5997 } 5998 if( variation ) { 5999 quantity = ( variation.tracking ) ? variation.quantity : 'inf'; 6000 quantity = ( variation.enabled ) ? quantity : 0; 6001 } 6002 6003 jQuery( '.ec_details_swatches > li.ec_option3_' + product_id + '_' + rand_id + ', .ec_details_swatches_ele > li.ec_option3_' + product_id + '_' + rand_id ).removeClass( 'ec_selected' ).removeClass( 'ec_active' ); 6004 jQuery( '.ec_details_swatches > li.ec_option4_' + product_id + '_' + rand_id + ', .ec_details_swatches_ele > li.ec_option4_' + product_id + '_' + rand_id ).removeClass( 'ec_selected' ).removeClass( 'ec_active' ); 6005 jQuery( '.ec_details_swatches > li.ec_option5_' + product_id + '_' + rand_id + ', .ec_details_swatches_ele > li.ec_option5_' + product_id + '_' + rand_id ).removeClass( 'ec_selected' ).removeClass( 'ec_active' ); 6006 jQuery( '.ec_details_combo.ec_option3_' + product_id + '_' + rand_id ).val( '0' ).prop( 'disabled', true ).addClass( 'ec_inactive' ); 6007 jQuery( '.ec_details_combo.ec_option4_' + product_id + '_' + rand_id ).val( '0' ).prop( 'disabled', true ).addClass( 'ec_inactive' ); 6008 jQuery( '.ec_details_combo.ec_option5_' + product_id + '_' + rand_id ).val( '0' ).prop( 'disabled', true ).addClass( 'ec_inactive' ); 6009 jQuery( '.ec_details_option_label_selected_3, .ec_details_option_label_selected_4, .ec_details_option_label_selected_5' ).html( '' ); 6010 jQuery( '.ec_option2_' + product_id + '_' + rand_id + '.ec_details_option_row_error' ).hide( ); 6011 jQuery( document.getElementById( 'ec_details_stock_quantity_' + product_id + '_' + rand_id ) ).html( quantity ); 6012 if ( 'inf' != quantity ) { 6013 jQuery( '.ec_details_stock_total' ).show(); 6014 } else { 6015 jQuery( '.ec_details_stock_total' ).hide(); 6016 } 6017 jQuery( document.getElementById('ec_quantity_' + product_id + '_' + rand_id ) ).attr( 'max', quantity ); 6018 if( Number( jQuery( document.getElementById('ec_quantity_' + product_id + '_' + rand_id ) ).val( ) ) > Number( quantity ) ){ 6019 jQuery( document.getElementById('ec_quantity_' + product_id + '_' + rand_id ) ).val( quantity ); 6020 } 6021 var next_options = jQuery( '.ec_details_swatches > li.ec_option3_' + product_id + '_' + rand_id + ', .ec_details_swatches_ele > li.ec_option3_' + product_id + '_' + rand_id ); 6022 jQuery( document.getElementById( 'ec_option_loading_3_' + product_id + '_' + rand_id ) ).show( ); 6023 if( next_options.length ){ 6024 next_options.each( function( ){ 6025 jQuery( this ).show().removeClass( 'ec_active' ).removeClass( 'ec_disabled_variant' ).addClass( 'ec_no_data_variant' ); 6026 } ); 6027 var data = { 6028 action: 'ec_ajax_get_optionitem_quantities', 6029 optionitem_id_1: optionitem_id_1, 6030 optionitem_id_2: optionitem_id_2, 6031 product_id: product_id, 6032 nonce: jQuery( document.getElementById( 'product_details_nonce_' + product_id + '_' + rand_id ) ).val() 6033 }; 6034 jQuery.ajax( { 6035 url: wpeasycart_ajax_object.ajax_url, 6036 type: 'post', 6037 data: data, 6038 cache: false, 6039 success: function( data ){ 6040 var json_data = JSON.parse( data ); 6041 jQuery( document.getElementById( 'ec_option_loading_3_' + product_id + '_' + rand_id ) ).hide( ); 6042 var found_i = -1; 6043 next_options.each( function( ){ 6044 for ( var i = 0; i < json_data.length && -1 == found_i; i++ ) { 6045 if ( jQuery( this ).attr( 'data-optionitem-id' ) == json_data[i].optionitem_id ) { 6046 found_i = i; 6047 } 6048 } 6049 if ( -1 != found_i && found_i < json_data.length ){ 6050 jQuery( this ).attr( 'data-optionitem-quantity', json_data[ found_i ].quantity ); 6051 if ( ! json_data[ found_i ].is_enabled ) { 6052 jQuery( this ).show().addClass( 'ec_disabled_variant' ).removeClass( 'ec_no_data_variant' ); 6053 } else if( json_data[ found_i ].quantity > 0 || '0' == json_data[ found_i ].tracking ){ 6054 jQuery( this ).show().addClass( 'ec_active' ).removeClass( 'ec_no_data_variant' ); 6055 } 6056 var subitem_variation = false; 6057 if ( window['varitation_data_' + product_id + '_' + rand_id ] && window['varitation_data_' + product_id + '_' + rand_id][optionitem_id_1 + optionitem_id_2 + jQuery( this ).attr( 'data-optionitem-id' ) + '00'] ) { 6058 subitem_variation = window['varitation_data_' + product_id + '_' + rand_id][optionitem_id_1 + optionitem_id_2 + jQuery( this ).attr( 'data-optionitem-id' ) + '00']; 6059 } 6060 if( subitem_variation ) { 6061 if ( ! subitem_variation.enabled ) { 6062 jQuery( this ).hide(); 6063 } 6064 } 6065 } 6066 found_i = -1; 6067 } ); 6068 } 6069 } ); 6070 }else{ 6071 next_options = jQuery( '.ec_details_combo.ec_option3_' + product_id + '_' + rand_id + ' option' ); 6072 next_options.each( function( ){ 6073 jQuery( this ).removeClass( 'ec_active' ); 6074 } ); 6075 var data = { 6076 action: 'ec_ajax_get_optionitem_quantities', 6077 optionitem_id_1: optionitem_id_1, 6078 optionitem_id_2: optionitem_id_2, 6079 product_id: product_id, 6080 nonce: jQuery( document.getElementById( 'product_details_nonce_' + product_id + '_' + rand_id ) ).val() 6081 }; 6082 jQuery.ajax( { 6083 url: wpeasycart_ajax_object.ajax_url, 6084 type: 'post', 6085 data: data, 6086 cache: false, 6087 success: function( data ){ 6088 jQuery( '.ec_details_combo.ec_option3_' + product_id + '_' + rand_id ).prop( 'disabled', false ).removeClass( 'ec_inactive' ); 6089 var json_data = JSON.parse( data ); 6090 jQuery( document.getElementById( 'ec_option_loading_3_' + product_id + '_' + rand_id ) ).hide( ); 6091 var found_i = -1; 6092 next_options.each( function( ){ 6093 for ( var i = 0; i < json_data.length && -1 == found_i; i++ ) { 6094 if ( jQuery( this ).val() == json_data[i].optionitem_id ) { 6095 found_i = i; 6096 } 6097 } 6098 if ( -1 != found_i && found_i < json_data.length ) { 6099 jQuery( this ).attr( 'data-optionitem-quantity', ( ( '1' == json_data[ found_i ].tracking ) ? json_data[ found_i ].quantity : 'inf' ) ); 6100 if( json_data[ found_i ].quantity > 0 || '0' == json_data[ found_i ].tracking ){ 6101 jQuery( this ).show().attr( 'disabled', false ); 6102 } else { 6103 jQuery( this ).hide().attr( 'disabled', true ); 6104 } 6105 var subitem_variation = false; 6106 if ( window['varitation_data_' + product_id + '_' + rand_id ] && window['varitation_data_' + product_id + '_' + rand_id][optionitem_id_1 + optionitem_id_2 + jQuery( this ).val() + '00'] ) { 6107 subitem_variation = window['varitation_data_' + product_id + '_' + rand_id][optionitem_id_1 + optionitem_id_2 + jQuery( this ).val() + '00']; 6108 } 6109 if( subitem_variation ) { 6110 if ( ! subitem_variation.enabled ) { 6111 jQuery( this ).hide().prop( 'disabled', true ); 6112 } 6113 } 6114 } else { 6115 jQuery( this ).attr( 'data-optionitem-quantity', 0 ).hide().attr( 'disabled', true ); 6116 } 6117 found_i = -1; 6118 } ); 6119 } 6120 } ); 6121 } 6122} 6123function ec_option3_updated( product_id, rand_id, optionitem_id_1, optionitem_id_2, optionitem_id_3 ) { 6124 if ( jQuery( 'select.ec_option4_' + product_id + '_' + rand_id ).length ) { 6125 if ( ! jQuery( 'select.ec_option4_' + product_id + '_' + rand_id + '_backup' ).length ) { 6126 jQuery( '<select style="display:none" class="ec_option4_' + product_id + '_' + rand_id + '_backup"></select>' ).insertBefore( 'select.ec_option4_' + product_id + '_' + rand_id ); 6127 var options_copy = jQuery( 'select.ec_option4_' + product_id + '_' + rand_id + ' > option' ).clone(); 6128 jQuery( 'select.ec_option4_' + product_id + '_' + rand_id + '_backup' ).append( options_copy ); 6129 } else { 6130 jQuery ( 'select.ec_option4_' + product_id + '_' + rand_id + ' > option' ).remove(); 6131 var options_backup_copy = jQuery ( 'select.ec_option4_' + product_id + '_' + rand_id + '_backup > option' ).clone(); 6132 jQuery ( 'select.ec_option4_' + product_id + '_' + rand_id ).append( options_backup_copy ); 6133 } 6134 6135 jQuery ( 'select.ec_option4_' + product_id + '_' + rand_id + ' > option' ).each( function() { 6136 if ( window['varitation_data_' + product_id + '_' + rand_id ] && window['varitation_data_' + product_id + '_' + rand_id][optionitem_id_1 + optionitem_id_2 + optionitem_id_3 + jQuery( this ).attr( 'value' ) + '0'] ) { 6137 if ( window['varitation_data_' + product_id + '_' + rand_id ] && window['varitation_data_' + product_id + '_' + rand_id][optionitem_id_1 + optionitem_id_2 + optionitem_id_3 + jQuery( this ).attr( 'value' ) + '0'].enabled ) { 6138 jQuery( this ).show().attr( 'disabled', false ); 6139 } else { 6140 jQuery( this ).remove(); 6141 } 6142 } else { 6143 jQuery( this ).show().attr( 'disabled', false ); 6144 } 6145 } ); 6146 } else if ( jQuery( 'li.ec_option4_' + product_id + '_' + rand_id ).length ) { 6147 jQuery ( 'li.ec_option4_' + product_id + '_' + rand_id ).each( function() { 6148 if ( window['varitation_data_' + product_id + '_' + rand_id ] && window['varitation_data_' + product_id + '_' + rand_id][optionitem_id_1 + optionitem_id_2 + optionitem_id_3 + jQuery( this ).attr( 'data-optionitem-id' ) + '0'] ) { 6149 if ( window['varitation_data_' + product_id + '_' + rand_id ] && window['varitation_data_' + product_id + '_' + rand_id][optionitem_id_1 + optionitem_id_2 + optionitem_id_3 + jQuery( this ).attr( 'data-optionitem-id' ) + '0'].enabled ) { 6150 jQuery( this ).addClass( 'ec_active' ); 6151 } else { 6152 if ( jQuery( this ).hasClass( 'ec_selected' ) ) { 6153 jQuery( '.ec_details_option_label_selected_4' ).html( '' ); 6154 } 6155 jQuery( this ).removeClass( 'ec_active' ).removeClass( 'ec_selected' ); 6156 } 6157 } else { 6158 jQuery( this ).addClass( 'ec_active' ); 6159 } 6160 } ); 6161 } 6162} 6163function option3_selected( product_id, rand_id, optionitem_id_1, optionitem_id_2, optionitem_id_3, quantity ){ 6164 var variation = false; 6165 if ( window['varitation_data_' + product_id + '_' + rand_id ] && window['varitation_data_' + product_id + '_' + rand_id][optionitem_id_1 + optionitem_id_2 + optionitem_id_3 + '00'] ) { 6166 variation = window['varitation_data_' + product_id + '_' + rand_id][optionitem_id_1 + optionitem_id_2 + optionitem_id_3 + '00']; 6167 } 6168 if( variation ) { 6169 quantity = ( variation.tracking ) ? variation.quantity : 'inf'; 6170 quantity = ( variation.enabled ) ? quantity : 0; 6171 } 6172 6173 jQuery( '.ec_details_swatches > li.ec_option4_' + product_id + '_' + rand_id + ', .ec_details_swatches_ele > li.ec_option4_' + product_id + '_' + rand_id ).removeClass( 'ec_selected' ).removeClass( 'ec_active' ); 6174 jQuery( '.ec_details_swatches > li.ec_option5_' + product_id + '_' + rand_id + ', .ec_details_swatches_ele > li.ec_option5_' + product_id + '_' + rand_id ).removeClass( 'ec_selected' ).removeClass( 'ec_active' ); 6175 jQuery( '.ec_details_combo.ec_option4_' + product_id + '_' + rand_id ).val( '0' ).prop( 'disabled', true ).addClass( 'ec_inactive' ); 6176 jQuery( '.ec_details_combo.ec_option5_' + product_id + '_' + rand_id ).val( '0' ).prop( 'disabled', true ).addClass( 'ec_inactive' ); 6177 jQuery( '.ec_details_option_label_selected_4, .ec_details_option_label_selected_5' ).html( '' ); 6178 jQuery( '.ec_option3_' + product_id + '_' + rand_id + '.ec_details_option_row_error' ).hide( ); 6179 jQuery( document.getElementById( 'ec_details_stock_quantity_' + product_id + '_' + rand_id ) ).html( quantity ); 6180 if ( 'inf' != quantity ) { 6181 jQuery( '.ec_details_stock_total' ).show(); 6182 } else { 6183 jQuery( '.ec_details_stock_total' ).hide(); 6184 } 6185 jQuery( document.getElementById('ec_
6185quantity_' + product_id + '_' + rand_id ) ).attr( 'max', quantity ); 6186 if( Number( jQuery( document.getElementById('ec_quantity_' + product_id + '_' + rand_id ) ).val( ) ) > Number( quantity ) ){ 6187 jQuery( document.getElementById('ec_quantity_' + product_id + '_' + rand_id ) ).val( quantity ); 6188 } 6189 var next_options = jQuery( '.ec_details_swatches > li.ec_option4_' + product_id + '_' + rand_id + ', .ec_details_swatches_ele > li.ec_option4_' + product_id + '_' + rand_id ); 6190 jQuery( document.getElementById( 'ec_option_loading_4_' + product_id + '_' + rand_id ) ).show( ); 6191 if( next_options.length ){ 6192 next_options.each( function( ){ 6193 jQuery( this ).show().removeClass( 'ec_active' ).removeClass( 'ec_disabled_variant' ).addClass( 'ec_no_data_variant' ); 6194 } ); 6195 var data = { 6196 action: 'ec_ajax_get_optionitem_quantities', 6197 optionitem_id_1: optionitem_id_1, 6198 optionitem_id_2: optionitem_id_2, 6199 optionitem_id_3: optionitem_id_3, 6200 product_id: product_id, 6201 nonce: jQuery( document.getElementById( 'product_details_nonce_' + product_id + '_' + rand_id ) ).val() 6202 }; 6203 jQuery.ajax( { 6204 url: wpeasycart_ajax_object.ajax_url, 6205 type: 'post', 6206 data: data, 6207 cache: false, 6208 success: function( data ){ 6209 var json_data = JSON.parse( data ); 6210 jQuery( document.getElementById( 'ec_option_loading_4_' + product_id + '_' + rand_id ) ).hide( ); 6211 var found_i = -1; 6212 next_options.each( function( ){ 6213 for ( var i = 0; i < json_data.length && -1 == found_i; i++ ) { 6214 if ( jQuery( this ).attr( 'data-optionitem-id' ) == json_data[i].optionitem_id ) { 6215 found_i = i; 6216 } 6217 } 6218 if ( -1 != found_i && found_i < json_data.length > found_i ){ 6219 jQuery( this ).attr( 'data-optionitem-quantity', json_data[ found_i ].quantity ); 6220 if ( ! json_data[ found_i ].is_enabled ) { 6221 jQuery( this ).show().addClass( 'ec_disabled_variant' ).removeClass( 'ec_no_data_variant' ); 6222 } else if( json_data[ found_i ].quantity > 0 || '0' == json_data[ found_i ].tracking ){ 6223 jQuery( this ).show().addClass( 'ec_active' ).removeClass( 'ec_no_data_variant' ); 6224 } 6225 var subitem_variation = false; 6226 if ( window['varitation_data_' + product_id + '_' + rand_id ] && window['varitation_data_' + product_id + '_' + rand_id][optionitem_id_1 + optionitem_id_2 + optionitem_id_3 + jQuery( this ).attr( 'data-optionitem-id' ) + '0'] ) { 6227 subitem_variation = window['varitation_data_' + product_id + '_' + rand_id][optionitem_id_1 + optionitem_id_2 + optionitem_id_3 + jQuery( this ).attr( 'data-optionitem-id' ) + '0']; 6228 } 6229 if( subitem_variation ) { 6230 if ( ! subitem_variation.enabled ) { 6231 jQuery( this ).hide(); 6232 } 6233 } 6234 } 6235 found_i = -1; 6236 } ); 6237 } 6238 } ); 6239 } else { 6240 next_options = jQuery( '.ec_details_combo.ec_option4_' + product_id + '_' + rand_id + ' option' ); 6241 next_options.each( function( ){ 6242 jQuery( this ).removeClass( 'ec_active' ); 6243 } ); 6244 var data = { 6245 action: 'ec_ajax_get_optionitem_quantities', 6246 optionitem_id_1: optionitem_id_1, 6247 optionitem_id_2: optionitem_id_2, 6248 optionitem_id_3: optionitem_id_3, 6249 product_id: product_id, 6250 nonce: jQuery( document.getElementById( 'product_details_nonce_' + product_id + '_' + rand_id ) ).val() 6251 }; 6252 jQuery.ajax( { 6253 url: wpeasycart_ajax_object.ajax_url, 6254 type: 'post', 6255 data: data, 6256 cache: false, 6257 success: function( data ){ 6258 jQuery( '.ec_details_combo.ec_option4_' + product_id + '_' + rand_id ).prop( 'disabled', false ).removeClass( 'ec_inactive' ); 6259 var json_data = JSON.parse( data ); 6260 jQuery( document.getElementById( 'ec_option_loading_4_' + product_id + '_' + rand_id ) ).hide( ); 6261 var found_i = -1; 6262 next_options.each( function( ){ 6263 for ( var i = 0; i < json_data.length && -1 == found_i; i++ ) { 6264 if ( jQuery( this ).val() == json_data[i].optionitem_id ) { 6265 found_i = i; 6266 } 6267 } 6268 if ( -1 != found_i && found_i < json_data.length ) { 6269 jQuery( this ).attr( 'data-optionitem-quantity', ( ( '1' == json_data[ found_i ].tracking ) ? json_data[ found_i ].quantity : 'inf' ) ); 6270 if( json_data[ found_i ].quantity > 0 || '0' == json_data[ found_i ].tracking ){ 6271 jQuery( this ).show().attr( 'disabled', false ); 6272 } else { 6273 jQuery( this ).hide().attr( 'disabled', true ); 6274 } 6275 var subitem_variation = false; 6276 if ( window['varitation_data_' + product_id + '_' + rand_id ] && window['varitation_data_' + product_id + '_' + rand_id][optionitem_id_1 + optionitem_id_2 + optionitem_id_3 + jQuery( this ).val() + '0'] ) { 6277 subitem_variation = window['varitation_data_' + product_id + '_' + rand_id][optionitem_id_1 + optionitem_id_2 + optionitem_id_3 + jQuery( this ).val() + '0']; 6278 } 6279 if( subitem_variation ) { 6280 if ( ! subitem_variation.enabled ) { 6281 jQuery( this ).hide().prop( 'disabled', true ); 6282 } 6283 } 6284 }else{ 6285 jQuery( this ).attr( 'data-optionitem-quantity', 0 ).hide().attr( 'disabled', true ); 6286 } 6287 found_i = -1; 6288 } ); 6289 } 6290 } ); 6291 } 6292} 6293function ec_option4_updated( product_id, rand_id, optionitem_id_1, optionitem_id_2, optionitem_id_3, optionitem_id_4 ) { 6294 if ( jQuery( 'select.ec_option5_' + product_id + '_' + rand_id ).length ) { 6295 if ( ! jQuery( 'select.ec_option5_' + product_id + '_' + rand_id + '_backup' ).length ) { 6296 jQuery( '<select style="display:none" class="ec_option5_' + product_id + '_' + rand_id + '_backup"></select>' ).insertBefore( 'select.ec_option5_' + product_id + '_' + rand_id ); 6297 var options_copy = jQuery( 'select.ec_option5_' + product_id + '_' + rand_id + ' > option' ).clone(); 6298 jQuery( 'select.ec_option5_' + product_id + '_' + rand_id + '_backup' ).append( options_copy ); 6299 } else { 6300 jQuery ( 'select.ec_option5_' + product_id + '_' + rand_id + ' > option' ).remove(); 6301 var options_backup_copy = jQuery ( 'select.ec_option5_' + product_id + '_' + rand_id + '_backup > option' ).clone(); 6302 jQuery ( 'select.ec_option5_' + product_id + '_' + rand_id ).append( options_backup_copy ); 6303 } 6304 6305 jQuery ( 'select.ec_option5_' + product_id + '_' + rand_id + ' > option' ).each( function() { 6306 if ( window['varitation_data_' + product_id + '_' + rand_id ] && window['varitation_data_' + product_id + '_' + rand_id][optionitem_id_1 + optionitem_id_2 + optionitem_id_3 + optionitem_id_4 + jQuery( this ).attr( 'value' )] ) { 6307 if ( window['varitation_data_' + product_id + '_' + rand_id ] && window['varitation_data_' + product_id + '_' + rand_id][optionitem_id_1 + optionitem_id_2 + optionitem_id_3 + optionitem_id_4 + jQuery( this ).attr( 'value' )].enabled ) { 6308 jQuery( this ).show().attr( 'disabled', false ); 6309 } else { 6310 jQuery( this ).remove(); 6311 } 6312 } else { 6313 jQuery( this ).show().attr( 'disabled', false ); 6314 } 6315 } ); 6316 } else if ( jQuery( 'li.ec_option5_' + product_id + '_' + rand_id ).length ) { 6317 jQuery ( 'li.ec_option5_' + product_id + '_' + rand_id ).each( function() { 6318 if ( window['varitation_data_' + product_id + '_' + rand_id ] && window['varitation_data_' + product_id + '_' + rand_id][optionitem_id_1 + optionitem_id_2 + optionitem_id_3 + optionitem_id_4 + jQuery( this ).attr( 'data-optionitem-id' )] ) { 6319 if ( window['varitation_data_' + product_id + '_' + rand_id ] && window['varitation_data_' + product_id + '_' + rand_id][optionitem_id_1 + optionitem_id_2 + optionitem_id_3 + optionitem_id_4 + jQuery( this ).attr( 'data-optionitem-id' )].enabled ) { 6320 jQuery( this ).addClass( 'ec_active' ); 6321 } else { 6322 if ( jQuery( this ).hasClass( 'ec_selected' ) ) { 6323 jQuery( '.ec_details_option_label_selected_5' ).html( '' ); 6324 } 6325 jQuery( this ).removeClass( 'ec_active' ).removeClass( 'ec_selected' ); 6326 } 6327 } else { 6328 jQuery( this ).addClass( 'ec_active' ); 6329 } 6330 } ); 6331 } 6332} 6333function option4_selected( product_id, rand_id, optionitem_id_1, optionitem_id_2, optionitem_id_3, optionitem_id_4, quantity ){ 6334 var variation = false; 6335 if ( window['varitation_data_' + product_id + '_' + rand_id ] && window['varitation_data_' + product_id + '_' + rand_id][optionitem_id_1 + optionitem_id_2 + optionitem_id_3 + optionitem_id_4 + '0'] ) { 6336 variation = window['varitation_data_' + product_id + '_' + rand_id][optionitem_id_1 + optionitem_id_2 + optionitem_id_3 + optionitem_id_4 + '0']; 6337 } 6338 if( variation ) { 6339 quantity = ( variation.tracking ) ? variation.quantity : 'inf'; 6340 quantity = ( variation.enabled ) ? quantity : 0; 6341 } 6342 6343 jQuery( '.ec_details_swatches > li.ec_option5_' + product_id + '_' + rand_id + ', .ec_details_swatches_ele > li.ec_option5_' + product_id + '_' + rand_id ).removeClass( 'ec_selected' ).removeClass( 'ec_active' ); 6344 jQuery( '.ec_details_combo.ec_option5_' + product_id + '_' + rand_id ).val( '0' ).prop( 'disabled', true ).addClass( 'ec_inactive' ); 6345 jQuery( '.ec_details_option_label_selected_5' ).html( '' ); 6346 jQuery( '.ec_option4.ec_details_option_row_error' ).hide( ); 6347 jQuery( document.getElementById( 'ec_details_stock_quantity_' + product_id + '_' + rand_id ) ).html( quantity ); 6348 if ( 'inf' != quantity ) { 6349 jQuery( '.ec_details_stock_total' ).show(); 6350 } else { 6351 jQuery( '.ec_details_stock_total' ).hide(); 6352 } 6353 jQuery( document.getElementById('ec_quantity_' + product_id + '_' + rand_id ) ).attr( 'max', quantity ); 6354 if( Number( jQuery( document.getElementById('ec_quantity_' + product_id + '_' + rand_id ) ).val( ) ) > Number( quantity ) ){ 6355 jQuery( document.getElementById('ec_quantity_' + product_id + '_' + rand_id ) ).val( quantity ); 6356 } 6357 var next_options = jQuery( '.ec_details_swatches > li.ec_option5_' + product_id + '_' + rand_id + ', .ec_details_swatches_ele > li.ec_option5_' + product_id + '_' + rand_id ); 6358 jQuery( document.getElementById( 'ec_option_loading_5_' + product_id + '_' + rand_id ) ).show( ); 6359 if( next_options.length ){ 6360 next_options.each( function( ){ 6361 jQuery( this ).show().removeClass( 'ec_active' ).removeClass( 'ec_disabled_variant' ).addClass( 'ec_no_data_variant' ) 6362 } ); 6363 var data = { 6364 action: 'ec_ajax_get_optionitem_quantities', 6365 optionitem_id_1: optionitem_id_1, 6366 optionitem_id_2: optionitem_id_2, 6367 optionitem_id_3: optionitem_id_3, 6368 optionitem_id_4: optionitem_id_4, 6369 product_id: product_id, 6370 nonce: jQuery( document.getElementById( 'product_details_nonce_' + product_id + '_' + rand_id ) ).val() 6371 }; 6372 jQuery.ajax( { 6373 url: wpeasycart_ajax_object.ajax_url, 6374 type: 'post', 6375 data: data, 6376 cache: false, 6377 success: function( data ){ 6378 var json_data = JSON.parse( data ); 6379 jQuery( document.getElementById( 'ec_option_loading_5_' + product_id + '_' + rand_id ) ).hide( ); 6380 var found_i = -1; 6381 next_options.each( function( ){ 6382 for ( var i = 0; i < json_data.length && -1 == found_i; i++ ) { 6383 if ( jQuery( this ).attr( 'data-optionitem-id' ) == json_data[i].optionitem_id ) { 6384 found_i = i; 6385 } 6386 } 6387 if ( -1 != found_i && found_i < json_data.length > found_i ){ 6388 jQuery( this ).attr( 'data-optionitem-quantity', json_data[i].quantity ); 6389 if ( ! json_data[ found_i ].is_enabled ) { 6390 jQuery( this ).show().addClass( 'ec_disabled_variant' ).removeClass( 'ec_no_data_variant' ); 6391 } else if( json_data[i].quantity > 0 || '0' == json_data[i].tracking ){ 6392 jQuery( this ).show().addClass( 'ec_active' ).removeClass( 'ec_no_data_variant' ); 6393 } 6394 i++; 6395 var subitem_variation = false; 6396 if ( window['varitation_data_' + product_id + '_' + rand_id ] && window['varitation_data_' + product_id + '_' + rand_id][optionitem_id_1 + optionitem_id_2 + optionitem_id_3 + optionitem_id_4 + jQuery( this ).attr( 'data-optionitem-id' ) ] ) { 6397 subitem_variation = window['varitation_data_' + product_id + '_' + rand_id][optionitem_id_1 + optionitem_id_2 + optionitem_id_3 + optionitem_id_4 + jQuery( this ).attr( 'data-optionitem-id' ) ]; 6398 } 6399 if( subitem_variation ) { 6400 if ( ! subitem_variation.enabled ) { 6401 jQuery( this ).hide(); 6402 } 6403 } 6404 } 6405 found_i = -1; 6406 } ); 6407 } 6408 } ); 6409 } else { 6410 next_options = jQuery( '.ec_details_combo.ec_option5_' + product_id + '_' + rand_id + ' option' ); 6411 next_options.each( function( ){ 6412 jQuery( this ).removeClass( 'ec_active' ); 6413 } ); 6414 var data = { 6415 action: 'ec_ajax_get_optionitem_quantities', 6416 optionitem_id_1: optionitem_id_1, 6417 optionitem_id_2: optionitem_id_2, 6418 optionitem_id_3: optionitem_id_3, 6419 optionitem_id_4: optionitem_id_4, 6420 product_id: product_id, 6421 nonce: jQuery( document.getElementById( 'product_details_nonce_' + product_id + '_' + rand_id ) ).val() 6422 }; 6423 jQuery.ajax( { 6424 url: wpeasycart_ajax_object.ajax_url, 6425 type: 'post', 6426 data: data, 6427 cache: false, 6428 success: function( data ){ 6429 jQuery( '.ec_details_combo.ec_option5_' + product_id + '_' + rand_id ).prop( 'disabled', false ).removeClass( 'ec_inactive' ); 6430 var json_data = JSON.parse( data ); 6431 jQuery( document.getElementById( 'ec_option_loading_5_' + product_id + '_' + rand_id ) ).hide( ); 6432 var found_i = -1; 6433 next_options.each( function( ){ 6434 for ( var i = 0; i < json_data.length && -1 == found_i; i++ ) { 6435 if ( jQuery( this ).val() == json_data[i].optionitem_id ) { 6436 found_i = i; 6437 } 6438 } 6439 if ( -1 != found_i && found_i < json_data.length ) { 6440 jQuery( this ).attr( 'data-optionitem-quantity', ( ( '1' == json_data[ found_i ].tracking ) ? json_data[ found_i ].quantity : 'inf' ) ); 6441 if( json_data[ found_i ].quantity > 0 || '0' == json_data[ found_i ].tracking ){ 6442 jQuery( this ).show().attr( 'disabled', false ); 6443 } else { 6444 jQuery( this ).hide().attr( 'disabled', true ); 6445 } 6446 i++; 6447 var subitem_variation = false; 6448 if ( window['varitation_data_' + product_id + '_' + rand_id ] && window['varitation_data_' + product_id + '_' + rand_id][optionitem_id_1 + optionitem_id_2 + optionitem_id_3 + optionitem_id_4 + jQuery( this ).val() ] ) { 6449 subitem_variation = window['varitation_data_' + product_id + '_' + rand_id][optionitem_id_1 + optionitem_id_2 + optionitem_id_3 + optionitem_id_4 + jQuery( this ).val() ]; 6450 } 6451 if( subitem_variation ) { 6452 if ( ! subitem_variation.enabled ) { 6453 jQuery( this ).hide().prop( 'disabled', true ); 6454 } 6455 } 6456 } else { 6457 jQuery( this ).attr( 'data-optionitem-quantity', 0 ).hide().attr( 'disabled', true ); 6458 } 6459 found_i = -1; 6460 } ); 6461 } 6462 } ); 6463 } 6464} 6465 6466function ec_details_submit_inquiry( product_id, rand_id ){ 6467 var errors = 0; 6468 if( document.getElementById( 'ec_inquiry_name_' + product_id + '_' + rand_id ) ){ 6469 if( jQuery( document.getElementById( 'ec_inquiry_name_' + product_id + '_' + rand_id ) ).val( ) == "" || !ec_validate_email( jQuery( document.getElementById( 'ec_inquiry_email_' + product_id + '_' + rand_id ) ).val( ) ) || jQuery( document.getElementById( 'ec_inquiry_message_' + product_id + '_' + rand_id ) ).val( ) == "" ){ 6470 jQuery( document.getElementById( 'ec_details_inquiry_error_' + product_id + '_' + rand_id ) ).show( ); 6471 errors++; 6472 }else{ 6473 jQuery( document.getElementById( 'ec_details_inquiry_error_' + product_id + '_' + rand_id ) ).hide( ); 6474 } 6475 } 6476 if( jQuery( document.getElementById( 'ec_grecaptcha_response_inquiry' ) ).length ){ 6477 var recaptcha_response = jQuery( document.getElementById( 'ec_grecaptcha_response_inquiry' ) ).val( ); 6478 if( !recaptcha_response.length ){ 6479 jQuery( '#ec_product_details_inquiry_recaptcha > div' ).css( 'border', '1px solid red' ); 6480 errors++; 6481 }else{ 6482 jQuery( '#ec_product_details_inquiry_recaptcha > div' ).css( 'border', 'none' ); 6483 } 6484 } 6485 if( ! ec_details_add_to_cart( product_id, rand_id ) ){ 6486 errors++; 6487 } 6488 if( errors > 0 ) { 6489 return false; 6490 } else { 6491 jQuery( document.getElementById( 'ec_inquiry_loader_' + product_id + '_' + rand_id ) ).show( ); 6492 jQuery( document.getElementById( 'ec_inquiry_loader_bg_' + product_id + '_' + rand_id ) ).show( ); 6493 return true; 6494 } 6495} 6496 6497function ec_details_add_to_cart( product_id, rand_id ) { 6498 // In cases where sites only integrate with stand alone add to carts, caching c
6498an cause problems with initial adds, this should resolve that. 6499 var data = { 6500 action: 'ec_ajax_try_wpec_session', 6501 product_id: product_id, 6502 nonce: jQuery( '#ec_cart_form_nonce' ).val() 6503 }; 6504 jQuery.ajax( { 6505 url: wpeasycart_ajax_object.ajax_url, 6506 type: 'post', 6507 data: data, 6508 cache: false 6509 } ); 6510 var errors = 0; 6511 // Basic Option 1 Error Check 6512 if( jQuery( '.ec_details_swatch.ec_option1_' + product_id + '_' + rand_id + ', .ec_details_swatch_ele.ec_option1_' + product_id + '_' + rand_id ).length && !jQuery( '.ec_option1_' + product_id + '_' + rand_id + '.ec_selected' ).attr( 'data-optionitem-id' ) ){ 6513 jQuery( '.ec_option1_' + product_id + '_' + rand_id + '.ec_details_option_row_error' ).show( ); 6514 errors++; 6515 }else if( jQuery( '.ec_details_combo.ec_option1_' + product_id + '_' + rand_id ).length && ( jQuery( '.ec_details_combo.ec_option1.ec_option1_' + product_id + '_' + rand_id ).val( ) == null || jQuery( '.ec_details_combo.ec_option1.ec_option1_' + product_id + '_' + rand_id ).val( ) == '0' ) ){ 6516 jQuery( '.ec_option1_' + product_id + '_' + rand_id + '.ec_details_option_row_error' ).show( ); 6517 errors++; 6518 }else{ 6519 jQuery( '.ec_option1_' + product_id + '_' + rand_id + '.ec_details_option_row_error' ).hide( ); 6520 } 6521 // Basic Option 2 Error Check 6522 if( jQuery( '.ec_details_swatch.ec_option2_' + product_id + '_' + rand_id + ', .ec_details_swatch_ele.ec_option2_' + product_id + '_' + rand_id ).length && !jQuery( '.ec_option2_' + product_id + '_' + rand_id + '.ec_selected' ).attr( 'data-optionitem-id' ) ){ 6523 jQuery( '.ec_option2_' + product_id + '_' + rand_id + '.ec_details_option_row_error' ).show( ); 6524 errors++; 6525 }else if( jQuery( '.ec_details_combo.ec_option2_' + product_id + '_' + rand_id ).length && ( jQuery( '.ec_details_combo.ec_option2.ec_option2_' + product_id + '_' + rand_id ).val( ) == null || jQuery( '.ec_details_combo.ec_option2.ec_option2_' + product_id + '_' + rand_id ).val( ) == '0' ) ){ 6526 jQuery( '.ec_option2_' + product_id + '_' + rand_id + '.ec_details_option_row_error' ).show( ); 6527 errors++; 6528 }else{ 6529 jQuery( '.ec_option2_' + product_id + '_' + rand_id + '.ec_details_option_row_error' ).hide( ); 6530 } 6531 // Basic Option 3 Error Check 6532 if( jQuery( '.ec_details_swatch.ec_option3_' + product_id + '_' + rand_id + ', .ec_details_swatch_ele.ec_option3_' + product_id + '_' + rand_id ).length && !jQuery( '.ec_option3_' + product_id + '_' + rand_id + '.ec_selected' ).attr( 'data-optionitem-id' ) ){ 6533 jQuery( '.ec_option3_' + product_id + '_' + rand_id + '.ec_details_option_row_error' ).show( ); 6534 errors++; 6535 }else if( jQuery( '.ec_details_combo.ec_option3_' + product_id + '_' + rand_id ).length && ( jQuery( '.ec_details_combo.ec_option3.ec_option3_' + product_id + '_' + rand_id ).val( ) == null || jQuery( '.ec_details_combo.ec_option3.ec_option3_' + product_id + '_' + rand_id ).val( ) == '0' ) ){ 6536 jQuery( '.ec_option3_' + product_id + '_' + rand_id + '.ec_details_option_row_error' ).show( ); 6537 errors++; 6538 }else{ 6539 jQuery( '.ec_option3_' + product_id + '_' + rand_id + '.ec_details_option_row_error' ).hide( ); 6540 } 6541 // Basic Option 4 Error Check 6542 if( jQuery( '.ec_details_swatch.ec_option4_' + product_id + '_' + rand_id + ', .ec_details_swatch_ele.ec_option4_' + product_id + '_' + rand_id ).length && !jQuery( '.ec_option4_' + product_id + '_' + rand_id + '.ec_selected' ).attr( 'data-optionitem-id' ) ){ 6543 jQuery( '.ec_option4_' + product_id + '_' + rand_id + '.ec_details_option_row_error' ).show( ); 6544 errors++; 6545 }else if( jQuery( '.ec_details_combo.ec_option4_' + product_id + '_' + rand_id ).length && ( jQuery( '.ec_details_combo.ec_option4.ec_option4_' + product_id + '_' + rand_id ).val( ) == null || jQuery( '.ec_details_combo.ec_option4.ec_option4_' + product_id + '_' + rand_id ).val( ) == '0' ) ){ 6546 jQuery( '.ec_option4_' + product_id + '_' + rand_id + '.ec_details_option_row_error' ).show( ); 6547 errors++; 6548 }else{ 6549 jQuery( '.ec_option4_' + product_id + '_' + rand_id + '.ec_details_option_row_error' ).hide( ); 6550 } 6551 // Basic Option 5 Error Check 6552 if( jQuery( '.ec_details_swatch.ec_option5_' + product_id + '_' + rand_id + ', .ec_details_swatch_ele.ec_option5_' + product_id + '_' + rand_id ).length && !jQuery( '.ec_option5_' + product_id + '_' + rand_id + '.ec_selected' ).attr( 'data-optionitem-id' ) ){ 6553 jQuery( '.ec_option5_' + product_id + '_' + rand_id + '.ec_details_option_row_error' ).show( ); 6554 errors++; 6555 }else if( jQuery( '.ec_details_combo.ec_option5_' + product_id + '_' + rand_id ).length && ( jQuery( '.ec_details_combo.ec_option5.ec_option5_' + product_id + '_' + rand_id ).val( ) == null || jQuery( '.ec_details_combo.ec_option5.ec_option5_' + product_id + '_' + rand_id ).val( ) == '0' ) ){ 6556 jQuery( '.ec_option5_' + product_id + '_' + rand_id + '.ec_details_option_row_error' ).show( ); 6557 errors++; 6558 }else{ 6559 jQuery( '.ec_option5_' + product_id + '_' + rand_id + '.ec_details_option_row_error' ).hide( ); 6560 } 6561 // --------Advanced Option Checks---------- // 6562 // Select Box Check 6563 var advanced_select_rows = jQuery( '.ec_details_option_row.ec_option_type_combo:visible' ); 6564 advanced_select_rows.each( function( ){
6565 if( jQuery( this ).attr( 'data-product-id' ) == product_id && jQuery( this ).attr( 'data-option-required' ) == '1' ){ // Option is Required 6566 if( jQuery( document.getElementById( 'ec_option_adv_' + jQuery( this ).attr( 'data-product-option-id' ) + '_' + product_id + '_' + rand_id ) ).val( ) == '0' ){ 6567 jQuery( document.getElementById( 'ec_details_adv_option_row_error_' + jQuery( this ).attr( 'data-product-option-id' ) + '_' + product_id + '_' + rand_id ) ).show( ); 6568 errors++; 6569 }else{ 6570 jQuery( document.getElementById( 'ec_details_adv_option_row_error_' + jQuery( this ).attr( 'data-product-option-id' ) + '_' + product_id + '_' + rand_id ) ).hide( ); 6571 } 6572 } 6573 } ); 6574 // Check Box Check 6575 var advanced_checkbox_rows = jQuery( '.ec_details_option_row.ec_option_type_checkbox:visible' ); 6576 advanced_checkbox_rows.each( function( ){ 6577 if( jQuery( this ).attr( 'data-product-id' ) == product_id && jQuery( this ).attr( 'data-option-required' ) == '1' ){ // Option is Required 6578 var selected_checkboxes = jQuery( "input.ec_option_adv_" + jQuery( this ).attr( 'data-product-option-id' ) + ":checked" ); 6579 if( selected_checkboxes.length ){ 6580 jQuery( document.getElementById( 'ec_details_adv_option_row_error_' + jQuery( this ).attr( 'data-product-option-id' ) + '_' + product_id + '_' + rand_id ) ).hide( ); 6581 }else{ 6582 jQuery( document.getElementById( 'ec_details_adv_option_row_error_' + jQuery( this ).attr( 'data-product-option-id' ) + '_' + product_id + '_' + rand_id ) ).show( ); 6583 errors++; 6584 } 6585 } 6586 } ); 6587 // Date Box Check 6588 var advanced_date_rows = jQuery( '.ec_details_option_row.ec_option_type_date:visible' ); 6589 advanced_date_rows.each( function( ){ 6590 if( jQuery( this ).attr( 'data-product-id' ) == product_id && jQuery( this ).attr( 'data-option-required' ) == '1' ){ // Option is Required 6591 if( jQuery( document.getElementById( 'ec_option_adv_' + jQuery( this ).attr( 'data-product-option-id' ) + '_' + product_id + '_' + rand_id ) ).val( ) == "" ){ 6592 jQuery( document.getElementById( 'ec_details_adv_option_row_error_' + jQuery( this ).attr( 'data-product-option-id' ) + '_' + product_id + '_' + rand_id ) ).show( ); 6593 errors++; 6594 }else{ 6595 jQuery( document.getElementById( 'ec_details_adv_option_row_error_' + jQuery( this ).attr( 'data-product-option-id' ) + '_' + product_id + '_' + rand_id ) ).hide( ); 6596 } 6597 } 6598 } ); 6599 // File Upload Check ( required, and whether the chosen file's type and size can be accepted ) 6600 jQuery( '.ec_details_option_row.ec_option_type_file:visible' ).each( function( ){ 6601 if ( jQuery( this ).attr( 'data-product-id' ) != product_id ) { 6602 return; 6603 } 6604 var option_key = jQuery( this ).attr( 'data-product-option-id' ) + '_' + product_id + '_' + rand_id; 6605 var input = document.getElementById( 'ec_option_adv_' + option_key ); 6606 var error_row = document.getElementById( 'ec_details_adv_option_row_error_' + option_key ); 6607 if ( ! input ) { 6608 return; 6609 } 6610 if ( error_row && undefined === jQuery( error_row ).data( 'ec-default-error' ) ) { 6611 jQuery( error_row ).data( 'ec-default-error', jQuery( error_row ).html( ) ); 6612 } 6613 var problem = ''; 6614 var file = ( input.files && input.files.length ) ? input.files[0] : null; 6615 if ( ! jQuery( input ).val( ) ) { 6616 problem = ( jQuery( this ).attr( 'data-option-required' ) == '1' ) ? 'missing' : ''; 6617 } else if ( file ) { 6618 var extensions = ( input.getAttribute( 'data-ec-file-ext' ) || '' ).toLowerCase( ).split( ',' ); 6619 var dot = file.name.lastIndexOf( '.' ); 6620 var extension = ( dot > -1 ) ? file.name.slice( dot + 1 ).toLowerCase( ) : ''; 6621 var max_size = parseInt( input.getAttribute( 'data-ec-max-size' ), 10 ); 6622 if ( input.getAttribute( 'data-ec-file-ext' ) && ( '' === extension || -1 === jQuery.inArray( extension, extensions ) ) ) { 6623 problem = 'file-type'; 6624 } else if ( max_size > 0 && file.size > max_size ) { 6625 problem = 'file-size'; 6626 } 6627 } 6628 if ( problem ) { 6629 if ( error_row ) { 6630 if ( 'missing' !== problem && input.getAttribute( 'data-ec-error-' + problem ) ) { 6631 jQuery( error_row ).text( input.getAttribute( 'data-ec-error-' + problem ) ); 6632 } else { 6633 jQuery( error_row ).html( jQuery( error_row ).data( 'ec-default-error' ) ); 6634 } 6635 jQuery( error_row ).show( ); 6636 } 6637 errors++; 6638 } else if ( error_row ) { 6639 jQuery( error_row ).hide( ); 6640 } 6641 } ); 6642 // Swatch Check 6643 var advanced_swatch_rows = jQuery( '.ec_details_option_row.ec_option_type_swatch:visible' ); 6644 advanced_swatch_rows.each( function( ){
6645 if( jQuery( this ).attr( 'data-product-id' ) == product_id && jQuery( this ).attr( 'data-option-required' ) == '1' ){ // Option is Required 6646 var advanced_selected_swatches = jQuery( ".ec_details_swatch.ec_option_adv_" + jQuery( this ).attr( 'data-product-option-id' ) + '_' + product_id + '_' + rand_id + ".ec_selected, .ec_details_swatch_ele.ec_option_adv_" + jQuery( this ).attr( 'data-product-option-id' ) + '_' + product_id + '_' + rand_id + ".ec_selected" ); 6647 if( advanced_selected_swatches.length ){ 6648 jQuery( document.getElementById( 'ec_details_adv_option_row_error_' + jQuery( this ).attr( 'data-product-option-id' ) + '_' + product_id + '_' + rand_id ) ).hide( ); 6649 }else{ 6650 jQuery( document.getElementById( 'ec_details_adv_option_row_error_' + jQuery( this ).attr( 'data-product-option-id' ) + '_' + product_id + '_' + rand_id ) ).show( ); 6651 errors++; 6652 } 6653 } 6654 } ); 6655 // Radio Button Check 6656 var advanced_radio_rows = jQuery( '.ec_details_option_row.ec_option_type_radio:visible' ); 6657 advanced_radio_rows.each( function( ){ 6658 if( jQuery( this ).attr( 'data-product-id' ) == product_id && jQuery( this ).attr( 'data-option-required' ) == '1' ){ // Option is Required 6659 var selected_radios = jQuery( "input[name='ec_option_adv_" + jQuery( this ).attr( 'data-product-option-id' ) + "']:checked" ); 6660 if( selected_radios.length ){ 6661 jQuery( document.getElementById( 'ec_details_adv_option_row_error_' + jQuery( this ).attr( 'data-product-option-id' ) + '_' + product_id + '_' + rand_id ) ).hide( ); 6662 }else{ 6663 jQuery( document.getElementById( 'ec_details_adv_option_row_error_' + jQuery( this ).attr( 'data-product-option-id' ) + '_' + product_id + '_' + rand_id ) ).show( ); 6664 errors++; 6665 } 6666 } 6667 } ); 6668 // Text Box + Text Area Check ( required, and the minimum length whenever something was typed ) 6669 jQuery( '.ec_details_option_row.ec_option_type_text:visible, .ec_details_option_row.ec_option_type_textarea:visible' ).each( function( ){ 6670 if ( jQuery( this ).attr( 'data-product-id' ) != product_id ) { 6671 return; 6672 } 6673 var option_key = jQuery( this ).attr( 'data-product-option-id' ) + '_' + product_id + '_' + rand_id; 6674 var input = document.getElementById( 'ec_option_adv_' + option_key ); 6675 var error_row = document.getElementById( 'ec_details_adv_option_row_error_' + option_key ); 6676 if ( ! input ) { 6677 return; 6678 } 6679 if ( error_row && undefined === jQuery( error_row ).data( 'ec-default-error' ) ) { 6680 jQuery( error_row ).data( 'ec-default-error', jQuery( error_row ).html( ) ); 6681 } 6682 var value = jQuery( input ).val( ); 6683 var is_textarea = jQuery( this ).hasClass( 'ec_option_type_textarea' ); 6684 var missing = jQuery( this ).attr( 'data-option-required' ) == '1' && ( value == '' || ( is_textarea && value == 0 ) ); 6685 var short_by = ( ! missing && window.wpeasycart_text_input_rules && window.wpeasycart_text_input_rules.too_short ) ? window.wpeasycart_text_input_rules.too_short( input ) : 0; 6686 if ( missing || short_by ) { 6687 if ( error_row ) { 6688 if ( short_by && input.getAttribute( 'data-ec-min-length-error' ) ) { 6689 jQuery( error_row ).text( input.getAttribute( 'data-ec-min-length-error' ) ); 6690 } else { 6691 jQuery( error_row ).html( jQuery( error_row ).data( 'ec-default-error' ) ); 6692 } 6693 jQuery( error_row ).show( ); 6694 } 6695 errors++; 6696 } else if ( error_row ) { 6697 jQuery( error_row ).hide( ); 6698 } 6699 } ); 6700 // Number Box Check 6701 var advanced_text_rows = jQuery( '.ec_details_option_row.ec_option_type_number:visible' ); 6702 advanced_text_rows.each( function( ){ 6703 if( jQuery( this ).attr( 'data-product-id' ) == product_id && jQuery( this ).attr( 'data-option-required' ) == '1' ){ // Option is Required 6704 if( jQuery( document.getElementById( 'ec_option_adv_' + jQuery( this ).attr( 'data-product-option-id' ) + '_' + product_id + '_' + rand_id ) ).val( ) != "" ){ 6705 jQuery( document.getElementById( 'ec_details_adv_option_row_error_' + jQuery( this ).attr( 'data-product-option-id' ) + '_' + product_id + '_' + rand_id ) ).hide( ); 6706 }else{ 6707 jQuery( document.getElementById( 'ec_details_adv_option_row_error_' + jQuery( this ).attr( 'data-
6707product-option-id' ) + '_' + product_id + '_' + rand_id ) ).show( ); 6708 errors++; 6709 } 6710 } 6711 } ); 6712 // Quantity Grid Check 6713 var advanced_grid_rows = jQuery( '.ec_details_option_row.ec_option_type_grid:visible' ); 6714 advanced_grid_rows.each( function( ){ 6715 if( jQuery( this ).attr( 'data-product-id' ) == product_id && jQuery( this ).attr( 'data-option-required' ) == '1' ){ // Option is Required 6716 var grid_items = jQuery( this ).find( ".ec_details_option_data > .ec_details_grid_row > input" ); 6717 var total_grid_quantity = 0; 6718 grid_items.each( 6719 function( ){ 6720 total_grid_quantity += jQuery( this ).val( ); 6721 } 6722 ); 6723 if( total_grid_quantity > 0 ){ 6724 jQuery( document.getElementById( 'ec_details_adv_option_row_error_' + jQuery( this ).attr( 'data-product-option-id' ) + '_' + product_id + '_' + rand_id ) ).hide( ); 6725 }else{ 6726 jQuery( document.getElementById( 'ec_details_adv_option_row_error_' + jQuery( this ).attr( 'data-product-option-id' ) + '_' + product_id + '_' + rand_id ) ).show( ); 6727 errors++; 6728 } 6729 } 6730 } ); 6731 // Dimensions Type 1 Check 6732 var advanced_dimensions_rows = jQuery( '.ec_details_option_row.ec_option_type_dimensions1:visible' ); 6733 advanced_dimensions_rows.each( function( ){ 6734 if( jQuery( this ).attr( 'data-product-id' ) == product_id && jQuery( this ).attr( 'data-option-required' ) == '1' ){ // Option is Required 6735 // Test Width + Height 6736 if( jQuery( document.getElementById( 'ec_option_adv_' + jQuery( this ).attr( 'data-product-option-id' ) + '_' + product_id + '_' + rand_id + '_width' ) ).val( ) != "" && jQuery( document.getElementById( 'ec_option_adv_' + jQuery( this ).attr( 'data-product-option-id' ) + '_' + product_id + '_' + rand_id + '_height' ) ).val( ) != "" ){ 6737 jQuery( document.getElementById( 'ec_details_adv_option_row_error_' + jQuery( this ).attr( 'data-product-option-id' ) + '_' + product_id + '_' + rand_id ) ).hide( ); 6738 }else{ 6739 jQuery( document.getElementById( 'ec_details_adv_option_row_error_' + jQuery( this ).attr( 'data-product-option-id' ) + '_' + product_id + '_' + rand_id ) ).show( ); 6740 errors++; 6741 } 6742 6743 } 6744 } ); 6745 // Dimensions Type 2 Check 6746 var advanced_dimensions_rows = jQuery( '.ec_details_option_row.ec_option_type_dimensions2:visible' ); 6747 advanced_dimensions_rows.each( function( ){ 6748 if( jQuery( this ).attr( 'data-product-id' ) == product_id && jQuery( this ).attr( 'data-option-required' ) == '1' ){ // Option is Required 6749 // Test Width + Height 6750 if( jQuery( document.getElementById( 'ec_option_adv_' + jQuery( this ).attr( 'data-product-option-id' ) + '_' + product_id + '_' + rand_id + '_width' ) ).val( ) != "" && jQuery( document.getElementById( 'ec_option_adv_' + jQuery( this ).attr( 'data-product-option-id' ) + '_' + product_id + '_' + rand_id + '_height' ) ).val( ) != "" ){ 6751 jQuery( document.getElementById( 'ec_details_adv_option_row_error_' + jQuery( this ).attr( 'data-product-option-id' ) + '_' + product_id + '_' + rand_id ) ).hide( ); 6752 }else{ 6753 jQuery( document.getElementById( 'ec_details_adv_option_row_error_' + jQuery( this ).attr( 'data-product-option-id' ) + '_' + product_id + '_' + rand_id ) ).show( ); 6754 errors++; 6755 } 6756 6757 } 6758 } ); 6759 // -------END Advanced Option Checks------- // 6760 // -------START GIFT CARD CHECK ----------- // 6761 var gift_card_errors = 0; 6762 if( document.getElementById( 'ec_giftcard_to_name_' + product_id + '_' + rand_id ) && jQuery( document.getElementById( 'ec_giftcard_to_name_' + product_id + '_' + rand_id ) ).val( ) == "" ){ 6763 errors++; 6764 gift_card_errors++; 6765 } 6766 if( document.getElementById( 'ec_giftcard_to_email_' + product_id + '_' + rand_id ) && jQuery( document.getElementById( 'ec_giftcard_to_email_' + product_id + '_' + rand_id ) ).val( ) == "" ){ 6767 errors++; 6768 gift_card_errors++; 6769 } 6770 if( document.getElementById( 'ec_giftcard_from_name_' + product_id + '_' + rand_id ) && jQuery( document.getElementById( 'ec_giftcard_from_name_' + product_id + '_' + rand_id ) ).val( ) == "" ){ 6771 errors++; 6772 gift_card_errors++; 6773 } 6774 if( document.getElementById( 'ec_giftcard_message_' + product_id + '_' + rand_id ) && jQuery( document.getElementById( 'ec_giftcard_message_' + product_id + '_' + rand_id ) ).val( ) == "" ){ 6775 errors++; 6776 gift_card_errors++; 6777 } 6778 if( gift_card_errors ){ 6779 jQuery( document.getElementById( 'ec_details_giftcard_error_' + product_id + '_' + rand_id ) ).show( ); 6780 }else{ 6781 jQuery( document.getElementById( 'ec_details_giftcard_error_' + product_id + '_' + rand_id ) ).hide( ); 6782 } 6783 // -------END GIFT CARD CHECK ----------- // 6784 // -------START DONATION CHECK ----------- // 6785 if( document.getElementById( 'ec_donation_amount_' + product_id + '_' + rand_id ) ){ 6786 var price = jQuery( document.getElementById( 'price_' + product_id + '_' + rand_id ) ).val(); 6787 if( isNaN( jQuery( document.getElementById( 'ec_donation_amount_' + product_id + '_' + rand_id ) ).val( ) ) || Number( jQuery( document.getElementById( 'ec_donation_amount_' + product_id + '_' + rand_id ) ).val( ) ) < price ){ 6788 jQuery( document.getElementById( 'ec_details_donation_error_' + product_id + '_' + rand_id ) ).show( ); 6789 errors++; 6790 }else{ 6791 jQuery( document.getElementById( 'ec_details_donation_error_' + product_id + '_' + rand_id ) ).hide( ); 6792 } 6793 } 6794 // -------END DONATION CHECK ----------- // 6795 // -------START INQUIRY CHECK ----------- // 6796 if( document.getElementById( 'ec_inquiry_name' ) ){ 6797 if( jQuery( document.getElementById( 'ec_inquiry_name' ) ).val( ) == "" || jQuery( document.getElementById( 'ec_inquiry_email' ) ).val( ) == "" || jQuery( document.getElementById( 'ec_inquiry_message' ) ).val( ) == "" ){ 6798 jQuery( document.getElementById( 'ec_details_inquiry_error' ) ).show( ); 6799 errors++; 6800 }else{ 6801 jQuery( document.getElementById( 'ec_details_inquiry_error' ) ).hide( ); 6802 } 6803 } 6804 // -------END INQUIRY CHECK ----------- // 6805 // Stock Quantity Check ( 6.0.1: this product's own stock, never a quick view's elsewhere on the page ) 6806 var entered_quantity = Number( jQuery( document.getElementById( 'ec_quantity_' + product_id + '_' + rand_id ) ).val( ) ); 6807 var allowed_quantity = 9999999999999; 6808 var stock_element = jQuery( document.getElementById( 'ec_details_stock_quantity_' + product_id + '_' + rand_id ) ); 6809 if( stock_element.length && '1' != jQuery( document.getElementById( 'ec_allow_backorders_' + product_id + '_' + rand_id ) ).val( ) ){ 6810 var stock_text = String( stock_element.html( ) ).replace( /^\s+|\s+$/g, '' ); 6811 if( '' != stock_text && isFinite( Number( stock_text ) ) ){ // 'inf' ( an option without stock tracking ) sets no limit 6812 allowed_quantity = Number( stock_text ); 6813 } 6814 } 6815 // Backorder Check 6816 if( allowed_quantity <= 0 && jQuery( document.getElementById( 'ec_back_order_info_' + product_id + '_' + rand_id ) ).length ){ 6817 allowed_quantity = 1000000; 6818 } 6819 // Check Stock Quantity 6820 if( entered_quantity > allowed_quantity ){ 6821 jQuery( document.getElementById( 'ec_addtocart_quantity_exceeded_error_' + product_id + '_' + rand_id ) ).show( ); 6822 errors++; 6823 }else{ 6824 jQuery( document.getElementById( 'ec_addtocart_quantity_exceeded_error_' + product_id + '_' + rand_id ) ).hide( ); 6825 } 6826 // Minimum Quantity Check 6827 var min_quantity = jQuery( document.getElementById( 'min_quantity_' + product_id + '_' + rand_id ) ).val(); 6828 if( entered_quantity < min_quantity ){ 6829 jQuery( document.getElementById( 'ec_addtocart_quantity_minimum_error_' + product_id + '_' + rand_id ) ).show( ); 6830 errors++; 6831 }else{ 6832 jQuery( document.getElementById( 'ec_addtocart_quantity_minimum_error_' + product_id + '_' + rand_id ) ).hide( ); 6833 } 6834 // Maximum Quantity Check 6835 var max_quantity = jQuery( document.getElementById( 'max_quantity_' + product_id + '_' + rand_id ) ).val(); 6836 if( max_quantity > 0 && entered_quantity > max_quantity ){ 6837 jQuery( document.getElementById( 'ec_addtocart_quantity_maximum_error_' + product_id + '_' + rand_id ) ).show( ); 6838 errors++; 6839 }else{ 6840 jQuery( document.getElementById( 'ec_addtocart_quantity_maximum_error_' + product_id + '_' + rand_id ) ).hide( ); 6841 } 6842 errors = window['wp_easycart_add_to_cart_js_validation_end_' + product_id + '_' + rand_id]( errors ); 6843 if( errors > 0 ) { 6844 return false; 6845 } else { 6846 if ( typeof gtag !== "undefined" ) { 6847 var final_price = ''; 6848 if ( jQuery( '.ec_details_title_' + product_id + '_' + rand_id ).length ) { 6849 if ( jQuery( document.getElementById( 'ec_final_price_' + product_id + '_' + rand_id ) ).length ) { 6850 final_price = jQuery( document.getElementById( 'ec_final_price_' + product_id + '_' + rand_id ) ).html().replace( /[^\d\.\,]/g, '' ); 6851 } 6852 ec_ga4_add_to_cart( jQuery( '.ec_details_model_number_sku_' + product_id + '_' + rand_id ).html(), jQuery( '.ec_details_title_' + product_id + '_' + rand_id ).html(), entered_quantity, final_price, jQuery( document.getElementById( 'currency_code_' + product_id + '_' + rand_id ) ).val() ); 6853 } else if ( jQuery( document.getElementById( 'ec_product_title_' + product_id + '_' + rand_id ) ).length ) { 6854 if ( jQuery( document.getElementById( 'ec_base_price_' + product_id + '_' + rand_id ) ).length ) { 6855 final_price = jQuery( document.getElementById( 'ec_base_price_' + product_id + '_' + rand_id ) ).html().replace( /[^\d\.\,]/g, '' ); 6856 } 6857 ec_ga4_add_to_cart( jQuery( document.getElementById( 'ec_default_sku_' + product_id + '_' + rand_id ) ).val(), jQuery( document.getElementById( 'ec_product_title_' + product_id + '_' + rand_id ) ).val(), entered_quantity, final_price, jQuery( document.getElementById( 'currency_code_' + product_id + '_' + rand_id ) ).val() ); 6858 } 6859 } 6860 return true; 6861 } 6862} 6863 6864function ec_submit_product_review( product_id, rand_id, nonce ){ 6865 var review_title = jQuery( document.getElementById( 'ec_review_title_' + product_id + '_' + rand_id ) ).val( ); 6866 var review_score = 0; 6867 for( var i=1; i<=5; i++ ){ 6868 if( jQuery( document.getElementById( 'ec_details_review_star' + i + '_' + product_id + '_' + rand_id ) ).hasClass( 'ec_product_details_star_on' ) || jQuery( document.getElementById( 'ec_details_review_star' + i + '_' + product_id + '_' + rand_id ) ).hasClass( 'ec_product_details_star_on_ele' ) ){ 6869 review_score++; 6870 } 6871 } 6872 var review_message = jQuery( document.getElementById( 'ec_review_message_' + product_id + '_' + rand_id ) ).val( ); 6873 if( review_title != "" && review_score != 0 && review_message != "" ){ 6874 // Submit a filled out review 6875 jQuery( document.getElementById( 'ec_details_customer_review_loader_' + product_id + '_' + rand_id ) ).show( ); 6876 jQuery( document.getElementById( 'ec_details_review_error_' + product_id + '_' + rand_id ) ).hide( ); 6877 var data = { 6878 action: 'ec_ajax_insert_customer_review', 6879 review_title: review_title, 6880 review_score: review_score, 6881 review_message: review_message, 6882 product_id: product_id, 6883 nonce: nonce 6884 }; 6885 jQuery.ajax( { 6886 url: wpeasycart_ajax_object.ajax_url, 6887 type: 'post', 6888 data: data, 6889 cache: false, 6890 success: function( data ){ 6891 jQuery( document.getElementById( 'ec_details_customer_review_loader_' + product_id + '_' + rand_id ) ).hide( ); 6892 jQuery( document.getElementById( 'ec_details_submit_review_button_row_' + product_id + '_' + rand_id ) ).hide( ); 6893 jQuery( document.getElementById( 'ec_details_review_submitted_button_row_' + product_id + '_' + rand_id ) ).show( ); 6894 jQuery( document.getElementById( 'ec_details_customer_review_success_' + product_id + '_' + rand_id ) ).show( ).delay( 1500 ).fadeOut( 'slow' ); 6895 } 6896 } ); 6897 } else { 6898 jQuery( document.getElementById( 'ec_details_review_error_' + product_id + '_' + rand_id ) ).show( ); 6899 } 6900} 6901 6902function ec_details_get_sq_footage( is_metric, width, sub_width, height, sub_height ){ 6903 var sub_width_decimal = ec_details_get_sub_dimension_decimal( sub_width ); 6904 var sub_height_decimal = ec_details_get_sub_dimension_decimal( sub_height ); 6905 if( '1' == is_metric ) { 6906 width = Number( Number( width ) + sub_width_decimal ) / 1000; 6907 height = Number( Number( height ) + sub_height_decimal ) / 1000; 6908 } else { 6909 width = Number( Number( width ) + sub_width_decimal ) / 12; 6910 height = Number( Number( height ) + sub_height_decimal ) / 12; 6911 } 6912 return width * height; 6913} 6914 6915function ec_details_get_sub_dimension_decimal( sub_dimension ) { 6916 if( sub_dimension == "0" ){ 6917 return 0; 6918 }else if( sub_dimension == "1/16" ){ 6919 return .0625; 6920 }else if( sub_dimension == "1/8" ){ 6921 return .1250; 6922 }else if( sub_dimension == "3/16" ){ 6923 return .1875; 6924 }else if( sub_dimension == "1/4" ){ 6925 return .2500; 6926 }else if( sub_dimension == "5/16" ){ 6927 return .3125; 6928 }else if( sub_dimension == "3/8" ){ 6929 return .3750; 6930 }else if( sub_dimension == "7/16" ){ 6931 return .4375; 6932 }else if( sub_dimension == "1/2" ){ 6933 return .5000; 6934 }else if( sub_dimension == "9/16" ){ 6935 return .5625; 6936 }else if( sub_dimension == "5/8" ){ 6937 return .6250; 6938 }else if( sub_dimension == "11/16" ){ 6939 return .6875; 6940 }else if( sub_dimension == "3/4" ){ 6941 return .7500; 6942 }else if( sub_dimension == "13/16" ){ 6943 return .8125; 6944 }else if( sub_dimension == "7/8" ){ 6945 return .8750; 6946 }else if( sub_dimension == "15/16" ){ 6947 return .9375; 6948 }else{ 6949 return 0; 6950 } 6951} 6952 6953function ec_details_format_money_v2( product_id, rand_id, price ) { 6954 var currency_symbol = jQuery( document.getElementById( 'currency_symbol_' + product_id + '_' + rand_id ) ).val(); 6955 var num_decimals = Number( jQuery( document.getElementById( 'num_decimals_' + product_id + '_' + rand_id ) ).val() ); 6956 var decimal_symbol = jQuery( document.getElementById( 'decimal_symbol_' + product_id + '_' + rand_id ) ).val(); 6957 var grouping_symbol = jQuery( document.getElementById( 'grouping_symbol_' + product_id + '_' + rand_id ) ).val(); 6958 var conversion_rate = Number( jQuery( document.getElementById( 'conversion_rate_' + product_id + '_' + rand_id ) ).val() ); 6959 var symbol_location = Number( jQuery( document.getElementById( 'symbol_location_' + product_id + '_' + rand_id ) ).val() ); 6960 var currency_code = jQuery( document.getElementById( 'currency_code_' + product_id + '_' + rand_id ) ).val(); 6961 var show_currency_code = Number( jQuery( document.getElementById( 'show_currency_code_' + product_id + '_' + rand_id ) ).val() ); 6962 price = ec_pricing_round( price * Number( conversion_rate ), num_decimals ); 6963 var n = price, 6964 num_decimals = isNaN(num_decimals = Math.abs(num_decimals)) ? 2 : num_decimals, 6965 decimal_symbol = decimal_symbol == undefined ? "." : decimal_symbol, 6966 grouping_symbol = grouping_symbol == undefined ? "," : grouping_symbol, 6967 i = parseInt(n = price.toFixed( num_decimals ) ) + "", 6968 j = (j = i.length) > 3 ? j % 3 : 0; 6969 var formatted = (j ? i.substr(0, j) + grouping_symbol : "") + i.substr(j).replace(/(\d{3})(?=\d)/g, "$1" + grouping_symbol) + (num_decimals ? decimal_symbol + Math.abs(n - i).toFixed(num_decimals).slice(2) : ""); 6970 if( symbol_location ){
6971 formatted = currency_symbol + formatted; 6972 }else{ 6973 formatted = formatted + currency_symbol; 6974 } 6975 if( show_currency_code == '1' ){ 6976 formatted = currency_code + ' ' + formatted; 6977 } 6978 return formatted; 6979} 6980function ec_pricing_round( number, places ) { 6981 var multiplier = Math.pow(10, places+2); // get two extra digits 6982 var fixed = Math.floor(number*multiplier); // convert to integer 6983 fixed += 50; // round down on anything less than x.xxx50 6984 fixed = Math.floor(fixed/100); // chop off last 2 digits 6985 return fixed/Math.pow(10, places); 6986} 6987function ec_admin_save_product_details_options( ){ 6988 jQuery( "#ec_admin_page_updated_loader" ).show( ); 6989 jQuery( "#ec_admin_loader_bg" ).show( ); 6990 var data = { 6991 action: 'ec_ajax_save_product_details_options', 6992 ec_option_details_main_color: jQuery( document.getElementById( 'ec_option_details_main_color' ) ).val( ), 6993 ec_option_details_second_color: jQuery( document.getElementById( 'ec_option_details_second_color' ) ).val( ), 6994 ec_option_details_columns_desktop: jQuery( document.getElementById( 'ec_option_details_columns_desktop' ) ).val( ), 6995 ec_option_details_columns_laptop: jQuery( document.getElementById( 'ec_option_details_columns_laptop' ) ).val( ), 6996 ec_option_details_columns_tablet_wide: jQuery( document.getElementById( 'ec_option_details_columns_tablet_wide' ) ).val( ), 6997 ec_option_details_columns_tablet: jQuery( document.getElementById( 'ec_option_details_columns_tablet' ) ).val( ), 6998 ec_option_details_columns_smartphone: jQuery( document.getElementById( 'ec_option_details_columns_smartphone' ) ).val( ), 6999 ec_option_use_dark_bg: jQuery( document.getElementById( 'ec_option_use_dark_bg' ) ).val( ), 7000 nonce: jQuery( '#product_details_save_options_nonce' ).val() 7001 } 7002 jQuery.ajax( { 7003 url: wpeasycart_ajax_object.ajax_url, 7004 type: 'post', 7005 data: data, 7006 cache: false, 7007 success: function(data){ 7008 jQuery( document.getElementById( 'ec_admin_page_updated_loader' ) ).hide( ); 7009 jQuery( document.getElementById( 'ec_admin_page_updated' ) ).show( ); 7010 jQuery( document.getElementById( 'ec_admin_loader_bg' ) ).fadeOut( 'slow' ); 7011 location.reload( ); 7012 } 7013 } ); 7014 jQuery( document.getElementById( 'ec_page_editor' ) ).animate( { left:'-290px' }, {queue:false, duration:220} ).removeClass( 'ec_display_editor_true' ).addClass( 'ec_display_editor_false' ); 7015} 7016function ec_admin_show_description_editor( product_id, rand_id ) { 7017 jQuery( '.ec_details_description_content_' + product_id + '_' + rand_id ).hide( ); 7018 jQuery( '.ec_details_description_editor_' + product_id + '_' + rand_id ).show( ); 7019} 7020function ec_admin_save_description_editor( model_number, product_id, rand_id ) { 7021 var new_html = ( jQuery( document.getElementById( 'desc_' + model_number ) ).is( ':visible' ) ) ? jQuery( document.getElementById( 'desc_' + model_number ) ).val() : tinymce.get( 'desc_' + model_number ).getContent(); 7022 jQuery( '.ec_details_description_editor_' + product_id + '_' + rand_id ).hide( ); 7023 jQuery( '.ec_details_description_content_' + product_id + '_' + rand_id ).html( new_html ).show( ); 7024 var data = { 7025 action: 'ec_ajax_ec_update_product_description', 7026 description: new_html, 7027 product_id: product_id, 7028 nonce: jQuery( document.getElementById( 'product_details_update_product_description_nonce_' + product_id + '_' + rand_id ) ).val() 7029 }; 7030 jQuery.ajax( { 7031 url: wpeasycart_ajax_object.ajax_url, 7032 type: 'post', 7033 data: data, 7034 cache: false 7035 } ); 7036} 7037function ec_admin_show_specifications_editor( product_id, rand_id ) { 7038 jQuery( '.ec_details_specifications_content_' + product_id + '_' + rand_id ).hide( ); 7039 jQuery( '.ec_details_specifications_editor_' + product_id + '_' + rand_id ).show( ); 7040} 7041function ec_admin_save_specifications_editor( model_number, product_id, rand_id ){ 7042 var new_html = ( jQuery( document.getElementById( 'specs_' + model_number ) ).is( ':visible' ) ) ? jQuery( document.getElementById( 'specs_' + model_number ) ).val() : tinymce.get( 'specs_' + model_number ).getContent(); 7043 jQuery( '.ec_details_specifications_editor_' + product_id + '_' + rand_id ).hide( ); 7044 jQuery( '.ec_details_specifications_content_' + product_id + '_' + rand_id ).html( new_html ).show( ); 7045 var data = { 7046 action: 'ec_ajax_ec_update_product_specifications', 7047 specifications: new_html, 7048 product_id: product_id, 7049 nonce: jQuery( document.getElementById( 'product_details_update_product_specs_nonce_' + product_id + '_' + rand_id ) ).val() 7050 }; 7051 jQuery.ajax( { 7052 url: wpeasycart_ajax_object.ajax_url, 7053 type: 'post', 7054 data: data, 7055 cache: false 7056 } ); 7057} 7058 7059if ( '' != wpeasycart_ajax_object.ga4_id || '' != wpeasycart_ajax_object.ga4_conv_id ) { 7060 var newScript = document.createElement( 'script' ); 7061 newScript.type = 'text/javascript'; 7062 newScript.setAttribute( 'async', 'true' );
7063 if ( '' != wpeasycart_ajax_object.ga4_id ) { 7064 newScript.setAttribute( 'src', 'https://www.googletagmanager.com/gtag/js?id=' + wpeasycart_ajax_object.ga4_id ); 7065 } else { 7066 newScript.setAttribute( 'src', 'https://www.googletagmanager.com/gtag/js?id=' + wpeasycart_ajax_object.ga4_conv_id ); 7067 } 7068 jQuery( 'head' ).append( newScript ); 7069 window.dataLayer = window.dataLayer || []; 7070 function gtag(){ dataLayer.push( arguments ); } 7071 gtag( 'js', new Date() ); 7072 if ( '' != wpeasycart_ajax_object.ga4_id ) { 7073 gtag( 'config', wpeasycart_ajax_object.ga4_id ); // , {'debug_mode': false} ); 7074 } 7075 if ( '' != wpeasycart_ajax_object.ga4_conv_id ) { 7076 gtag( 'config', wpeasycart_ajax_object.ga4_conv_id ); // , {'debug_mode': false} ); 7077 } 7078} 7079 7080function ec_ga4_remove_from_cart( model_number, title, quantity, price, currency, manufacturer_name, is_tag_manager = false ) { 7081 if ( is_tag_manager ) { 7082 dataLayer.push( { ecommerce: null } ); // Clear the previous ecommerce object. 7083 dataLayer.push( { 7084 event: 'remove_from_cart', 7085 ecommerce: { 7086 currency: currency, 7087 value: Number( price ) * Number( quantity ), 7088 items: [ { 7089 item_id: model_number, 7090 item_name: title, 7091 index: 0, 7092 price: parseFloat( price ), 7093 item_brand: manufacturer_name, 7094 quantity: quantity 7095 } ] 7096 } 7097 } ); 7098 } else { 7099 gtag( 'event', 'remove_from_cart', { 7100 currency: currency, 7101 value: Number( price ) * Number( quantity ), 7102 items: [ { 7103 item_id: model_number, 7104 item_name: title, 7105 index: 0, 7106 price: parseFloat( price ), 7107 item_brand: manufacturer_name, 7108 quantity: quantity 7109 } ] 7110 } ); 7111 } 7112} 7113 7114function ec_ga4_add_to_cart( model_number, title, quantity, price, currency, manufacturer_name, is_tag_manager = false ) { 7115 if ( is_tag_manager ) { 7116 dataLayer.push( { ecommerce: null } ); // Clear the previous ecommerce object. 7117 dataLayer.push( { 7118 event: 'add_to_cart', 7119 ecommerce: { 7120 currency: currency, 7121 value: Number( price ) * Number( quantity ), 7122 items: [ { 7123 item_id: model_number, 7124 item_name: title, 7125 index: 0, 7126 price: parseFloat( price ), 7127 item_brand: manufacturer_name, 7128 quantity: quantity 7129 } ] 7130 } 7131 } ); 7132 } else { 7133 gtag( 'event', 'add_to_cart', { 7134 currency: currency, 7135 value: Number( price ) * Number( quantity ), 7136 items: [ { 7137 item_id: model_number, 7138 item_name: title, 7139 index: 0, 7140 price: parseFloat( price ), 7141 item_brand: manufacturer_name, 7142 quantity: quantity 7143 } ] 7144 } ); 7145 } 7146} 7147 7148function wp_easycart_cart_checkout_click() { 7149 jQuery( '.ec_cart_button_checkout' ).addClass( 'wp-easycart-running' ); 7150} 7151 7152function wp_easycart_cart_shipping_next() { 7153 jQuery( '.ec_cart_button_shipping_next' ).parent().addClass( 'wp-easycart-running' ); 7154} 7155 7156function wpeasycart_mobile_summary() { 7157 if ( jQuery( '.ec_cart_mobile_summary_content' ).is( ':visible' ) ) { 7158 jQuery( '.ec_cart_mobile_summary_content' ).hide(); 7159 jQuery( '.dashicons-arrow-down-alt2' ).show(); 7160 jQuery( '.dashicons-arrow-up-alt2' ).hide(); 7161 } else { 7162 jQuery( '.ec_cart_mobile_summary_content' ).show(); 7163 jQuery( '.dashicons-arrow-down-alt2' ).hide(); 7164 jQuery( '.dashicons-arrow-up-alt2' ).show(); 7165 } 7166} 7167 7168function wpeasycart_load_locations( locations ) { 7169 for ( var i = 0; i < locations.length; i++ ) { 7170 jQuery( '.wpeasycart-location-list' ).append( locations[ i ].location_html ); 7171 } 7172} 7173function wpeasycart_trigger_location_geo( product_id = false, type = false ) { 7174 jQuery( '.wp-easycart-location-popup-error' ).hide(); 7175 if (navigator.geolocation) { 7176 navigator.geolocation.getCurrentPosition( 7177 ( position ) => { 7178 jQuery( '.wpeasycart-location-list-loader' ).show(); 7179 jQuery( '.wpeasycart-location-list' ).html( '' ); 7180 var lat = position.coords.latitude; 7181 var long = position.coords.longitude; 7182 var data = { 7183 action: 'ec_ajax_location_find_by_geo', 7184 lat: lat, 7185 long: long, 7186 product_id: product_id, 7187 type: type, 7188 nonce: jQuery( '#wpeasycart_location_nonce' ).val() 7189 }; 7190 jQuery.ajax( { 7191 url: wpeasycart_ajax_object.ajax_url, 7192 type: 'post', 7193 data: data, 7194 cache: false, 7195 success: function( response ) { 7196 jQuery( '.wpeasycart-location-list-loader' ).hide(); 7197 if ( response.data.locations ) { 7198 wpeasycart_load_locations( response.data.locations ); 7199 } 7200 } 7201 } ); 7202 }, 7203 ( error ) => { 7204 switch( error.code ) { 7205 case error.PERMISSION_DENIED: 7206 jQuery( '.wp-easycart-location-popup-error.error1' ).show(); 7207 break; 7208 case error.POSITION_UNAVAILABLE: 7209 jQuery( '.wp-easycart-location-popup-error.error2' ).show(); 7210 break; 7211 case error.TIMEOUT: 7212 jQuery( '.wp-easycart-location-popup-error.error3' ).show(); 7213 break; 7214 case error.UNKNOWN_ERROR: 7215 jQuery( '.wp-easycart-location-popup-error.error4' ).show(); 7216 break; 7217 } 7218 jQuery( '.wpeasycart-location-list-loader' ).show(); 7219 jQuery( '.wpeasycart-location-list' ).html( '' ); 7220 var data = { 7221 action: 'ec_ajax_location_find_by_geo', 7222 lat: 0, 7223 long: 0, 7224 nonce: jQuery( '#wpeasycart_location_nonce' ).val() 7225 }; 7226 jQuery.ajax( { 7227 url: wpeasycart_ajax_object.ajax_url, 7228 type: 'post', 7229 data: data, 7230 cache: false, 7231 success: function( response ) { 7232 jQuery( '.wpeasycart-location-list-loader' ).hide(); 7233 if ( response.data.locations ) { 7234 wpeasycart_load_locations( response.data.locations ); 7235 } 7236 } 7237 } ); 7238 } 7239 ); 7240 } else { 7241 jQuery( '.wp-easycart-location-popup-error.error5' ).show(); 7242 } 7243}
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.