// JavaScript Document jQuery( document ).ready( function( ){ if ( jQuery( '#wpeasycart_cart_holder' ).length ) { 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' ) ) } if ( jQuery( '#wpeasycart_account_holder' ).length ) { 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' ) ) } if ( jQuery( '.ec_product_quickview_container' ).length ) { jQuery( '.ec_product_quickview_container' ).each( function() { jQuery( this ).appendTo( document.body ); } ); } if ( jQuery( '.ec_add_to_cart_form, input[type="number"].ec_quantity' ).length ) { jQuery( '.ec_add_to_cart_form, input[type="number"].ec_quantity' ).on( 'keypress', function( e ) { if ( ! jQuery( e.target ).is( 'textarea' ) && e.which == 13 ) { return false; } } ); } jQuery( '.ec_flipbook_left' ).click( function( event ){ var current_image = jQuery( event.target ).parent( ).find( 'img.ec_flipbook_image' ).attr( 'src' ); var image_list_string = jQuery( event.target ).parent( ).data( 'image-list' ); var image_list = image_list_string.split( ',' ).filter( item => item !== '' ); var prev = image_list[image_list.length - 1]; for( var i=0; i item !== '' ); var prev = image_list[0]; for( var i=image_list.length-1; i>-1; i-- ){ if( image_list[i] == current_image ){ break; }else{ prev = image_list[i]; } } jQuery( event.target ).parent( ).find( 'img.ec_flipbook_image' ).attr( 'src', prev ); } ); jQuery( '.ec_product_shortcode .owl-carousel' ).each( function( ){ jQuery( this ).on({ 'initialized.owl.carousel': function( ){ jQuery( this ).find( '.wp-easycart-carousel-item' ).show( ); jQuery( this ).parent( ).find( '.wpec-product-slider-loader' ).hide( ); } }).owlCarousel( JSON.parse( jQuery( this ).attr( 'data-owl-options' ) ) ); } ); wpeasycart_cart_billing_country_update( ); wpeasycart_cart_shipping_country_update( ); wpeasycart_account_billing_country_update( ); wpeasycart_account_shipping_country_update( ); jQuery( document.getElementById( 'ec_cart_billing_country' ) ).change( function( ){ wpeasycart_cart_billing_country_update( ); } ); jQuery( document.getElementById( 'ec_cart_shipping_country' ) ).change( function( ){ wpeasycart_cart_shipping_country_update( ); } ); jQuery( document.getElementById( 'ec_account_billing_information_country' ) ).change( function( ){ wpeasycart_account_billing_country_update( ); } ); jQuery( document.getElementById( 'ec_account_shipping_information_country' ) ).change( function( ){ wpeasycart_account_shipping_country_update( ); } ); if( jQuery( '.ec_menu_mini_cart' ).length ){ jQuery( document.getElementById( 'ec_card_number' ) ).keydown( function( ){ ec_show_cc_type( ec_get_card_type( jQuery( document.getElementById( 'ec_card_number' ) ).val( ) ) ) } ); // Load cart menu, updates over possible cached value var data = { action: 'ec_ajax_get_dynamic_cart_menu', language: wpeasycart_ajax_object.current_language, nonce: jQuery( '.ec_menu_mini_cart' ).attr( 'data-nonce' ) }; jQuery.ajax({url: wpeasycart_ajax_object.ajax_url, type: 'post', data: data, success: function( data ){ jQuery( '.ec_menu_mini_cart' ).html( data ); } } ); } if( wpeasycart_isTouchDevice( ) ){ jQuery( '.ec_product_quickview' ).hide( ); } if( jQuery( document.getElementById( 'ec_card_number' ) ).length ){ jQuery( document.getElementById( 'ec_card_number' ) ).payment( 'formatCardNumber' ); } if( jQuery( document.getElementById( 'ec_cc_expiration' ) ).length ){ jQuery( document.getElementById( 'ec_cc_expiration' ) ).payment( 'formatCardExpiry' ); } if( jQuery( document.getElementById( 'ec_security_code' ) ).length ){ jQuery( document.getElementById( 'ec_security_code' ) ).payment( 'formatCardCVC' ); } if( jQuery( '.ec_is_datepicker' ).length ){ jQuery( '.ec_is_datepicker' ).datepicker( ); } if( jQuery( '.ec_details_customer_review_list' ).length ){ jQuery( '.ec_details_customer_review_list' ).each( function( ){ var reviews = jQuery( this ).find( 'li' ); var product_id = jQuery( this ).attr( 'data-product-id' ); var reviews_per_page = jQuery( document.getElementById( 'ec_details_reviews_per_page_' + product_id ) ).val( ); if( reviews.length > reviews_per_page ){ var paging = '
'; for( var i=0; i' + ( i + 1 ) + ''; } paging += '
'; jQuery( this ).after( paging ); ec_customer_review_paging(1, product_id); } } ); } if( jQuery( '.ec_product_sidebar_filter_item' ).length ){ jQuery( '.ec_product_sidebar_filter_item' ).on( 'click', function( ){ if( jQuery( this ).hasClass( 'selected' ) ){ jQuery( this ).removeClass( 'selected' ); }else{ jQuery( this ).addClass( 'selected' ); } var filter_ids = []; jQuery( '.ec_product_sidebar_filter_item.selected' ).each( function( ){ filter_ids.push( jQuery( this ).attr( 'data-optionitemid' ) ); } ); var category_ids = []; jQuery( '.ec_product_sidebar_filter_item.selected' ).each( function( ){ filter_ids.push( jQuery( this ).attr( 'data-categoryid' ) ); } ); jQuery( this ).parent( ).parent( ).parent( ).parent( ).find( '.ec_product_page_content' ).html( '
' ); var data = { action: 'ec_ajax_update_product_page_content', filter_ids: filter_ids, category_ids: category_ids, nonce: jQuery( '.ec_product_sidebar_filter_item' ).attr( 'data-nonce' ) }; } ); } if( jQuery( '.ec_product_page_with_sidebar.ec_product_page_sidebar_left, .ec_product_page_with_sidebar.ec_product_page_sidebar_right' ).length ){ 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' ); jQuery( '.ec_product_sidebar_filter_item_mobile' ).on( 'click', function() { if ( jQuery( this ).hasClass( 'selected' ) ) { jQuery( this ).removeClass( 'selected' ); } else { jQuery( this ).addClass( 'selected' ); } jQuery( '.ec_product_page_content' ).html( '
' ); jQuery( '.ec_product_page_sidebar_slide_bg' ).fadeOut( 'fast' ); jQuery( '.ec_product_page_sidebar_mobile_only' ).css( 'left', '-500px' ); return true; } ); jQuery( '.ec_product_page_sidebar_slide_bg' ).appendTo( document.body ); jQuery( '.ec_product_page_filters_toggle' ).on( 'click', function( ){ if( jQuery( '.ec_product_page_sidebar_mobile_only' ).css( 'left' ) == '0px' ){ jQuery( '.ec_product_page_sidebar_mobile_only' ).css( 'left', '-500px' ).fadeOut(); jQuery( '.ec_product_page_sidebar_slide_bg' ).fadeOut( 'fast' ); }else{ jQuery( '.ec_product_page_sidebar_mobile_only' ).css( 'left', '0px' ).fadeIn( 'fast' ); jQuery( '.ec_product_page_sidebar_slide_bg' ).fadeIn( 'fast' ); } } ); jQuery( '.ec_product_page_sidebar_slide_bg, .ec_product_sidebar_close, .ec_product_sidebar_close_mobile_only' ).on( 'click', function( ){ jQuery( '.ec_product_page_sidebar_slide_bg' ).fadeOut( 'fast' ); jQuery( '.ec_product_page_sidebar_mobile_only' ).css( 'left', '-500px' ); return false; } ); } 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 ){ 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( ); jQuery( '.ec_product_page_sidebar_slide_bg' ).appendTo( document.body ); jQuery( '.ec_product_page_sidebar_slide-left .ec_product_page_filters_toggle' ).on( 'click', function( ){ if( jQuery( '.ec_product_page_sidebar' ).css( 'left' ) == '0px' ){ jQuery( '.ec_product_page_sidebar' ).css( 'left', '-500px' ); jQuery( '.ec_product_page_sidebar_slide_bg' ).fadeOut( 'fast' ); }else{ jQuery( '.ec_product_page_sidebar' ).css( 'left', '0px' ); jQuery( '.ec_product_page_sidebar_slide_bg' ).fadeIn( 'fast' ); } } ); jQuery( '.ec_product_page_sidebar_slide-right .ec_product_page_filters_toggle' ).on( 'click', function( ){ if( jQuery( '.ec_product_page_sidebar' ).css( 'right' ) == '0px' ){ jQuery( '.ec_product_page_sidebar' ).css( 'right', '-500px' ); jQuery( '.ec_product_page_sidebar_slide_bg' ).fadeOut( 'fast' ); }else{ jQuery( '.ec_product_page_sidebar' ).css( 'right', '0px' ); jQuery( '.ec_product_page_sidebar_slide_bg' ).fadeIn( 'fast' ); } } ); jQuery( '.ec_product_page_sidebar_slide_bg, .ec_product_sidebar_close, .ec_product_sidebar_close_mobile_only' ).on( 'click', function() { jQuery( '.ec_product_page_sidebar_slide_bg' ).fadeOut( 'fast' ); jQuery( '.ec_product_page_sidebar_slide-left' ).css( 'left', '-500px' ); jQuery( '.ec_product_page_sidebar_slide-right' ).css( 'right', '-500px' ); return false; } ); 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( ){ jQuery( '.ec_product_page_content' ).html( '
' ); jQuery( '.ec_product_page_sidebar_slide_bg' ).fadeOut( 'fast' ); jQuery( '.ec_product_page_sidebar_mobile_only' ).css( 'left', '-500px' ); } ); } if ( jQuery( '.ec_product_sidebar_group_title' ).length ) { jQuery( '.ec_product_sidebar_group_title' ).on( 'click', function() { jQuery( this ).parent( ).find( '.ec_product_sidebar_group_link_list, .ec_product_sidebar_group_filter_list' ).toggle( ); } ); } jQuery( '.ec_add_to_cart_form_ajax' ).submit( function( e ) { e.preventDefault(); var input_eles = jQuery( this ).find( 'input, select' ); var input_submit = jQuery( this ).find( 'input[type="submit"]' ); jQuery( input_submit ).addClass( 'loading' ).parent().append( '' ); var data = { action: 'ec_ajax_add_to_cart_complete', noredirect: 1, nonce: jQuery( '.ec_add_to_cart_form_ajax' ).attr( 'data-nonce' ) }; for ( var i=0; i' + json_data[0].title + ' x 1 @ ' + json_data[0].price + '' ); } jQuery( input_submit ).parent().find( '.dashicons-update-alt' ).remove(); jQuery( input_submit ).parent().append( '' ); jQuery( input_submit ).removeClass( 'loading' ).addClass( 'added' ); setTimeout(function() { jQuery( input_submit ).removeClass( 'added' ).parent().find( '.dashicons-saved' ).remove(); }, 2000 ); } } ); } ); if( jQuery( '.ec_details_thumbnail' ).length ) { jQuery( '.ec_details_thumbnail' ).on( 'click', function() { var product_id = jQuery( this ).attr( 'data-product-id' ); var rand_id = jQuery( this ).attr( 'data-rand-id' ); var src = ''; if ( jQuery( this ).find( 'img' ).attr( 'data-large-src' ) ) { src = jQuery( this ).find( 'img' ).attr( 'data-large-src' ); } else if ( jQuery( this ).find( 'img' ).parent().attr( 'data-large-src' ) ) { src = jQuery( this ).find( 'img' ).parent().attr( 'data-large-src' ); } else if ( jQuery( this ).find( 'img' ).parent().parent().attr( 'data-large-src' ) ) { src = jQuery( this ).find( 'img' ).parent().parent().attr( 'data-large-src' ); } else if ( jQuery( this ).find( 'img' ).attr( 'data-src' ) ) { src = jQuery( this ).find( 'img' ).attr( 'data-src' ); } else { src = jQuery( this ).find( 'img' ).attr( 'src' ); } jQuery( '.ec_details_thumbnails_' + product_id + '_' + rand_id + ' > .ec_details_thumbnail' ).removeClass( 'ec_active' ); jQuery( this ).addClass( 'ec_active' ); if( jQuery( this ).hasClass( 'ec_details_thumbnail_video' ) ) { var video_src = jQuery( this ).find( 'a' ).attr( 'href' ); jQuery( '.ec_details_main_image_' + product_id + '_' + rand_id ).find( 'img' ).attr( 'data-src', src ).attr( 'src', src ).hide(); jQuery( '.ec_details_main_image_' + product_id + '_' + rand_id ).find( '.wp-easycart-video-box' ).remove(); if( jQuery( this ).hasClass( 'videoType' ) ) { jQuery( '.ec_details_main_image_' + product_id + '_' + rand_id ).append( '
' ); } else { jQuery( '.ec_details_main_image_' + product_id + '_' + rand_id ).append( '
' ); } jQuery( '.ec_details_large_popup_main_' + product_id + '_' + rand_id ).find( 'img' ).attr( 'data-src', src ).attr( 'src', src ); jQuery( '.ec_details_magbox_' + product_id + '_' + rand_id ).addClass( 'inactive' ); jQuery( '.ec_details_magbox_image_' + product_id + '_' + rand_id ).css( 'background', 'url( "' + src + '" ) no-repeat' ); } else { if ( jQuery( '.ec_details_main_image_' + product_id + '_' + rand_id ).find( 'picture > source[type="image/webp"]' ).length ) { jQuery( '.ec_details_main_image_' + product_id + '_' + rand_id ).find( 'picture > source[type="image/webp"]' ).remove(); } if ( jQuery( '.ec_details_large_popup_main_' + product_id + '_' + rand_id ).find( 'picture > source[type="image/webp"]' ).length ) { jQuery( '.ec_details_large_popup_main_' + product_id + '_' + rand_id ).find( 'picture > source[type="image/webp"]' ).remove(); } if ( jQuery( '.ec_details_magbox_image_' + product_id + '_' + rand_id ).find( 'picture > source[type="image/webp"]' ).length ) { jQuery( '.ec_details_magbox_image_' + product_id + '_' + rand_id ).find( 'picture > source[type="image/webp"]' ).remove(); } jQuery( '.ec_details_main_image_' + product_id + '_' + rand_id ).find( 'img' ).attr( 'data-src', src ).attr( 'src', src ).show(); jQuery( '.ec_details_main_image_' + product_id + '_' + rand_id ).find( '.wp-easycart-video-box' ).remove(); jQuery( '.ec_details_large_popup_main_' + product_id + '_' + rand_id ).find( 'img' ).attr( 'data-src', src ).attr( 'src', src ); jQuery( '.ec_details_magbox_' + product_id + '_' + rand_id ).removeClass( 'inactive' ); jQuery( '.ec_details_magbox_image_' + product_id + '_' + rand_id ).css( 'background', 'url( "' + src + '" ) no-repeat' ).attr( 'data-bg', 'url( "' + src + '" ) no-repeat' ); } return false; } ); } if( jQuery( '.ec_details_large_popup_thumbnail' ).length ) { jQuery( '.ec_details_large_popup_thumbnail' ).on( 'click', function() { var product_id = jQuery( this ).attr( 'data-product-id' ); var rand_id = jQuery( this ).attr( 'data-rand-id' ); var src = ''; if ( jQuery( this ).find( 'img' ).attr( 'data-large-src' ) ) { src = jQuery( this ).find( 'img' ).attr( 'data-large-src' ); } else if ( jQuery( this ).find( 'img' ).parent().attr( 'data-large-src' ) ) { src = jQuery( this ).find( 'img' ).parent().attr( 'data-large-src' ); } else if ( jQuery( this ).find( 'img' ).parent().parent().attr( 'data-large-src' ) ) { src = jQuery( this ).find( 'img' ).parent().parent().attr( 'data-large-src' ); } else if ( jQuery( this ).find( 'img' ).attr( 'data-src' ) ) { src = jQuery( this ).find( 'img' ).attr( 'data-src' ); } else { src = jQuery( this ).find( 'img' ).attr( 'src' ); } jQuery( '.ec_details_large_popup_thumbnails_' + product_id + '_' + rand_id + ' > .ec_details_large_popup_thumbnail' ).removeClass( 'ec_active' ); jQuery( this ).addClass( 'ec_active' ); if ( jQuery( this ).hasClass( 'ec_details_thumbnail_video' ) ) { var video_src = jQuery( this ).find( 'a' ).attr( 'href' ); jQuery( '.ec_details_main_image_' + product_id + '_' + rand_id ).find( 'img' ).attr( 'data-src', src ).attr( 'src', src ).hide(); jQuery( '.ec_details_main_image_' + product_id + '_' + rand_id ).find( '.wp-easycart-video-box' ).remove(); jQuery( '.ec_details_large_popup_main_' + product_id + '_' + rand_id ).find( 'img' ).attr( 'data-src', src ).attr( 'src', src ).hide(); jQuery( '.ec_details_large_popup_main_' + product_id + '_' + rand_id ).find( '.wp-easycart-video-box' ).remove(); if( jQuery( this ).hasClass( 'videoType' ) ) { jQuery( '.ec_details_main_image_' + product_id + '_' + rand_id ).append( '
' ); jQuery( '.ec_details_large_popup_main_' + product_id + '_' + rand_id ).append( '
' ); } else { jQuery( '.ec_details_main_image_' + product_id + '_' + rand_id ).append( '
' ); jQuery( '.ec_details_large_popup_main_' + product_id + '_' + rand_id ).append( '
' ); } jQuery( '.ec_details_magbox_' + product_id + '_' + rand_id ).addClass( 'inactive' ); jQuery( '.ec_details_magbox_image_' + product_id + '_' + rand_id ).css( 'background', 'url( "' + src + '" ) no-repeat' ); } else { if ( jQuery( '.ec_details_main_image_' + product_id + '_' + rand_id ).find( 'picture > source[type="image/webp"]' ).length ) { jQuery( '.ec_details_main_image_' + product_id + '_' + rand_id ).find( 'picture > source[type="image/webp"]' ).remove(); } if ( jQuery( '.ec_details_large_popup_main_' + product_id + '_' + rand_id ).find( 'picture > source[type="image/webp"]' ).length ) { jQuery( '.ec_details_large_popup_main_' + product_id + '_' + rand_id ).find( 'picture > source[type="image/webp"]' ).remove(); } if ( jQuery( '.ec_details_magbox_image_' + product_id + '_' + rand_id ).find( 'picture > source[type="image/webp"]' ).length ) { jQuery( '.ec_details_magbox_image_' + product_id + '_' + rand_id ).find( 'picture > source[type="image/webp"]' ).remove(); } jQuery( '.ec_details_thumbnails_' + product_id + '_' + rand_id + ' > .ec_details_thumbnail' ).removeClass( 'ec_active' ); jQuery( '.ec_details_main_image_' + product_id + '_' + rand_id ).find( 'img' ).attr( 'data-src', src ).attr( 'src', src ).show(); jQuery( '.ec_details_large_popup_main_' + product_id + '_' + rand_id ).find( 'img' ).attr( 'data-src', src ).attr( 'src', src ).show(); jQuery( '.ec_details_main_image_' + product_id + '_' + rand_id ).find( '.wp-easycart-video-box' ).remove(); jQuery( '.ec_details_large_popup_main_' + product_id + '_' + rand_id ).find( '.wp-easycart-video-box' ).remove(); jQuery( '.ec_details_magbox_image_' + product_id + '_' + rand_id ).css( 'background', 'url( "' + src + '" ) no-repeat' ); } return false; }); } if ( jQuery( '.ec_details_main_image.mag_enabled' ).length ) { var img = new Image( ); var img_width = 400; var img_height = 400; jQuery( '.ec_details_main_image' ).mousemove( function( e ){ var parentOffset = jQuery( this ).parent( ).offset( ); var mouse_x = e.pageX - parentOffset.left; var mouse_y = e.pageY - parentOffset.top; var div_width = jQuery( this ).width( ); var div_height = jQuery( this ).height( ); var x_val = '-' + ( ( img_width - div_width ) * ( mouse_x / div_width ) ) + 'px'; var y_val = '-' + ( ( img_height - div_height ) * ( mouse_y / div_height ) ) + 'px'; var product_id = jQuery( this ).attr( 'data-product-id' ); var rand_id = jQuery( this ).attr( 'data-rand-id' ); jQuery( '.ec_details_magbox_image_' + product_id + '_' + rand_id ).css( 'background-position', x_val + ' ' + y_val ); } ); jQuery( '.ec_details_main_image' ).hover( function() { var product_id = jQuery( this ).attr( 'data-product-id' ); var rand_id = jQuery( this ).attr( 'data-rand-id' ); img = new Image( ); img.onload = function( ) { img_width = this.width; img_height = this.height; 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' ); 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' ); } img.src = jQuery( this ).find( 'img' ).attr( 'src' ); jQuery( '.ec_details_magbox_' + product_id + '_' + rand_id ).fadeIn( 'fast' ); }, function() { var product_id = jQuery( this ).attr( 'data-product-id' ); var rand_id = jQuery( this ).attr( 'data-rand-id' ); jQuery( '.ec_details_magbox_' + product_id + '_' + rand_id ).fadeOut( 'fast' ); } ); } if ( jQuery( '.ec_minus' ).length ) { jQuery( '.ec_minus' ).on( 'click', function() { var product_id = jQuery( this ).parent().attr( 'data-product-id' ); var rand_id = jQuery( this ).parent().attr( 'data-rand-id' ); var min_quantity = jQuery( this ).parent().attr( 'data-min-purchase-quantity' ); var use_advanced_optionset = jQuery( this ).parent().attr( 'data-use-advanced-optionset' ); ec_minus_quantity( product_id + '_' + rand_id, min_quantity ); if ( '1' == use_advanced_optionset ) { ec_details_advanced_adjust_price( product_id, rand_id ); } else { ec_details_base_adjust_price( product_id, rand_id ); } } ); } if ( jQuery( '.ec_plus' ).length ) { jQuery( '.ec_plus' ).on( 'click', function() { var product_id = jQuery( this ).parent().attr( 'data-product-id' ); var rand_id = jQuery( this ).parent().attr( 'data-rand-id' ); var show_stock_quantity = jQuery( this ).parent().attr( 'data-show-stock-quantity' ); var max_quantity = jQuery( this ).parent().attr( 'data-min-purchase-quantity' ); var use_advanced_optionset = jQuery( this ).parent().attr( 'data-use-advanced-optionset' ); ec_plus_quantity( product_id + '_' + rand_id, show_stock_quantity, max_quantity ); if ( '1' == use_advanced_optionset ) { ec_details_advanced_adjust_price( product_id, rand_id ); } else { ec_details_base_adjust_price( product_id, rand_id ); } } ); } if ( jQuery( '.ec_quantity' ).length ) { jQuery( '.ec_quantity' ).on( 'change', function() { var product_id = jQuery( this ).parent().attr( 'data-product-id' ); var rand_id = jQuery( this ).parent().attr( 'data-rand-id' ); var use_advanced_optionset = jQuery( this ).parent().attr( 'data-use-advanced-optionset' ); if ( '1' == use_advanced_optionset ) { ec_details_advanced_adjust_price( product_id, rand_id ); } else { ec_details_base_adjust_price( product_id, rand_id ); } } ); } if ( jQuery( '.ec_donation_amount' ).length ) { jQuery( '.ec_donation_amount' ).on( 'change', function() { var product_id = jQuery( this ).attr( 'data-product-id' ); var rand_id = jQuery( this ).attr( 'data-rand-id' ); var use_advanced_optionset = jQuery( this ).attr( 'data-use-advanced-optionset' ); if ( '1' == use_advanced_optionset ) { ec_details_advanced_adjust_price( product_id, rand_id ); } else { ec_details_base_adjust_price( product_id, rand_id ); } } ); } jQuery( '.ec_details_checkbox_row > input, .ec_details_radio_row > input' ).click( function( ){ var product_id = jQuery( this ).parent().parent().parent().attr( 'data-product-id' ); var rand_id = jQuery( this ).parent().parent().parent().attr( 'data-rand-id' ); ec_details_advanced_conditional_logic( product_id, rand_id ); ec_details_advanced_adjust_price( product_id, rand_id ); } ); jQuery( '.ec_details_option_row.ec_option_type_combo > .ec_details_option_data > select' ).change( function( ){ var product_id = jQuery( this ).parent().parent().attr( 'data-product-id' ); var rand_id = jQuery( this ).parent().parent().attr( 'data-rand-id' ); var product_option_id = jQuery( this ).parent().parent().attr( 'data-product-option-id' ); var is_required = jQuery( this ).parent().parent().attr( 'data-option-required' ); var val = jQuery( this ).val(); if ( val == '0' && is_required == '1' ) { jQuery( document.getElementById( 'ec_details_adv_option_row_error_' + product_option_id + '_' + product_id + '_' + rand_id ) ).show( ); } else { jQuery( document.getElementById( 'ec_details_adv_option_row_error_' + product_option_id + '_' + product_id + '_' + rand_id ) ).hide( ); } ec_details_advanced_conditional_logic( product_id, rand_id ); ec_details_advanced_adjust_price( product_id, rand_id ); } ); jQuery( '.ec_details_option_row.ec_option_type_date > .ec_details_option_data > input' ).change( function( ){ var product_id = jQuery( this ).parent().parent().attr( 'data-product-id' ); var rand_id = jQuery( this ).parent().parent().attr( 'data-rand-id' ); ec_details_advanced_conditional_logic( product_id, rand_id ); ec_details_advanced_adjust_price( product_id, rand_id ); } ); jQuery( '.ec_details_option_row.ec_option_type_file > .ec_details_option_data > input' ).change( function( ){ var product_id = jQuery( this ).parent().parent().attr( 'data-product-id' ); var rand_id = jQuery( this ).parent().parent().attr( 'data-rand-id' ); ec_details_advanced_conditional_logic( product_id, rand_id ); ec_details_advanced_adjust_price( product_id, rand_id ); } ); jQuery( '.ec_details_option_row.ec_option_type_text > .ec_details_option_data > input' ).change( function( ){ var product_id = jQuery( this ).parent().parent().attr( 'data-product-id' ); var rand_id = jQuery( this ).parent().parent().attr( 'data-rand-id' ); ec_details_advanced_conditional_logic( product_id, rand_id ); ec_details_advanced_adjust_price( product_id, rand_id ); } ); jQuery( '.ec_details_option_row.ec_option_type_number > .ec_details_option_data > input' ).change( function( ){ var product_id = jQuery( this ).parent().parent().attr( 'data-product-id' ); var rand_id = jQuery( this ).parent().parent().attr( 'data-rand-id' ); ec_details_advanced_conditional_logic( product_id, rand_id ); ec_details_advanced_adjust_price( product_id, rand_id ); } ); jQuery( '.ec_details_option_row.ec_option_type_textarea > .ec_details_option_data > textarea' ).change( function( ){ var product_id = jQuery( this ).parent().parent().attr( 'data-product-id' ); var rand_id = jQuery( this ).parent().parent().attr( 'data-rand-id' ); ec_details_advanced_conditional_logic( product_id, rand_id ); ec_details_advanced_adjust_price( product_id, rand_id ); } ); jQuery( '.ec_details_grid_row > input' ).change( function( ){ var product_id = jQuery( this ).parent().parent().parent().attr( 'data-product-id' ); var rand_id = jQuery( this ).parent().parent().parent().attr( 'data-rand-id' ); ec_details_advanced_conditional_logic( product_id, rand_id ); ec_details_advanced_adjust_price( product_id, rand_id ); } ); jQuery( '.ec_details_swatches > li.ec_advanced, .ec_details_swatches_ele > li.ec_advanced' ).click( function( ){ var optionitem_id = jQuery( this ).attr( 'data-optionitem-id' ); var product_option_id = jQuery( this ).attr( 'data-product-option-id' ); var product_id = jQuery( this ).parent().parent().parent().attr( 'data-product-id' ); var rand_id = jQuery( this ).parent().parent().parent().attr( 'data-rand-id' ); jQuery( document.getElementById( 'ec_option_adv_' + product_option_id + "_" + product_id + '_' + rand_id ) ).val( optionitem_id ); jQuery( '.ec_details_swatches > li.ec_option_adv_' + product_option_id + "_" + product_id + '_' + rand_id ).removeClass( 'ec_selected' ); jQuery( '.ec_details_swatches_ele > li.ec_option_adv_' + product_option_id + "_" + product_id + '_' + rand_id ).removeClass( 'ec_selected' ); jQuery( this ).addClass( 'ec_selected' ); jQuery( document.getElementById( 'ec_details_option_row_error_' + product_option_id + "_" + product_id + '_' + rand_id ) ).hide( ); if ( jQuery( this ).find( 'img' ).length ) { if ( '' == jQuery( this ).find( 'img' ).attr( 'title' ) && '' != jQuery( this ).find( 'img' ).attr( 'pac_da_title' ) ) { jQuery( this ).parent( ).parent( ).parent( ).find( '.ec_details_option_label_selected' ).html( jQuery( this ).find( 'img' ).attr( 'pac_da_title' ) ); } else { jQuery( this ).parent( ).parent( ).parent( ).find( '.ec_details_option_label_selected' ).html( jQuery( this ).find( 'img' ).attr( 'title' ) ); } } else { jQuery( this ).parent( ).parent( ).parent( ).find( '.ec_details_option_label_selected' ).html( jQuery( this ).attr( 'title' ) ); } ec_details_advanced_conditional_logic( product_id, rand_id ); ec_details_advanced_adjust_price( product_id, rand_id ); } ); jQuery( '.ec_details_option_row.ec_option_type_dimensions1 > .ec_details_option_data > input' ).change( function( ){ var product_id = jQuery( this ).parent().parent().attr( 'data-product-id' ); var rand_id = jQuery( this ).parent().parent().attr( 'data-rand-id' ); ec_details_advanced_conditional_logic( product_id, rand_id ); ec_details_advanced_adjust_price( product_id, rand_id ); } ); jQuery( '.ec_details_option_row.ec_option_type_dimensions2 > .ec_details_option_data > input' ).change( function( ){ var product_id = jQuery( this ).parent().parent().attr( 'data-product-id' ); var rand_id = jQuery( this ).parent().parent().attr( 'data-rand-id' ); ec_details_advanced_conditional_logic( product_id, rand_id ); ec_details_advanced_adjust_price( product_id, rand_id ); } ); jQuery( '.ec_details_option_row.ec_option_type_dimensions2 > .ec_details_option_data > select' ).change( function( ){ var product_id = jQuery( this ).parent().parent().attr( 'data-product-id' ); var rand_id = jQuery( this ).parent().parent().attr( 'data-rand-id' ); ec_details_advanced_conditional_logic( product_id, rand_id ); ec_details_advanced_adjust_price( product_id, rand_id ); } ); if ( jQuery( '.ec_details_swatches > li.ec_option1, .ec_details_swatches_ele > li.ec_option1' ).length ) { jQuery( '.ec_details_swatches > li.ec_option1, .ec_details_swatches_ele > li.ec_option1' ).each( function() { var product_id = jQuery( this ).parent().parent().parent().attr( 'data-product-id' ); var rand_id = jQuery( this ).parent().parent().parent().attr( 'data-rand-id' ); var optionitem_id_1 = jQuery( this ).attr( 'data-optionitem-id' ); ec_option1_init_swatches( product_id, rand_id, jQuery( this ), optionitem_id_1 ); } ); } if ( jQuery( '.ec_details_combo.ec_option1' ).length ) { jQuery( '.ec_details_combo.ec_option1' ).each( function() { var product_id = jQuery( this ).parent().parent().attr( 'data-product-id' ); var rand_id = jQuery( this ).parent().parent().attr( 'data-rand-id' ); ec_option1_init_combo( product_id, rand_id ); } ); } jQuery( '.ec_details_swatches > li.ec_option1, .ec_details_swatches_ele > li.ec_option1' ).click( function( ){ if( jQuery( this ).hasClass( 'ec_active' ) ){ var product_id = jQuery( this ).parent().parent().parent().attr( 'data-product-id' ); var rand_id = jQuery( this ).parent().parent().parent().attr( 'data-rand-id' ); var optionitem_id_1 = jQuery( this ).attr( 'data-optionitem-id' ); var quantity = jQuery( this ).attr( 'data-optionitem-quantity' ); var use_optionitem_quantity_tracking = jQuery( document.getElementById( 'use_optionitem_quantity_tracking_' + product_id + '_' + rand_id ) ).val(); if ( jQuery( document.getElementById( 'ec_allow_backorders_' + product_id + '_' + rand_id ) ).length && '1' == jQuery( document.getElementById( 'ec_allow_backorders_' + product_id + '_' + rand_id ) ).val() ) { use_optionitem_quantity_tracking = '0'; } if ( '1' == use_optionitem_quantity_tracking ) { ec_option1_selected( product_id, rand_id, optionitem_id_1, quantity ); } else { ec_option1_updated( product_id, rand_id, optionitem_id_1 ); } ec_option1_image_change( product_id, rand_id, optionitem_id_1, quantity ); jQuery( '.ec_details_swatches > li.ec_option1_' + product_id + '_' + rand_id ).removeClass( 'ec_selected' ); jQuery( '.ec_details_swatches_ele > li.ec_option1_' + product_id + '_' + rand_id ).removeClass( 'ec_selected' ); jQuery( this ).addClass( 'ec_selected' ); jQuery( '.ec_option1_' + product_id + '_' + rand_id + '.ec_details_option_row_error' ).hide( ); jQuery( document.getElementById( 'ec_option1_' + product_id + '_' + rand_id ) ).val( optionitem_id_1 ); if ( jQuery( this ).find( 'img' ).length ) { if ( '' == jQuery( this ).find( 'img' ).attr( 'title' ) && '' != jQuery( this ).find( 'img' ).attr( 'pac_da_title' ) ) { jQuery( this ).parent( ).parent( ).find( '.ec_details_option_label_selected' ).html( jQuery( this ).find( 'img' ).attr( 'pac_da_title' ) ); } else { jQuery( this ).parent( ).parent( ).find( '.ec_details_option_label_selected' ).html( jQuery( this ).find( 'img' ).attr( 'title' ) ); } } else { jQuery( this ).parent( ).parent( ).find( '.ec_details_option_label_selected' ).html( jQuery( this ).attr( 'title' ) ); } ec_details_base_adjust_price( product_id, rand_id ); } } ); jQuery( '.ec_details_swatches > li.ec_option2, .ec_details_swatches_ele > li.ec_option2' ).click( function( ){ if( jQuery( this ).hasClass( 'ec_active' ) ){ var product_id = jQuery( this ).parent().parent().parent().attr( 'data-product-id' ); var rand_id = jQuery( this ).parent().parent().parent().attr( 'data-rand-id' ); var optionitem_id_1 = 0; 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 ){ 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' ); }else{ optionitem_id_1 = jQuery( '.ec_details_combo.ec_option1_' + product_id + '_' + rand_id ).val( ); } var optionitem_id_2 = jQuery( this ).attr( 'data-optionitem-id' ); var use_optionitem_quantity_tracking = jQuery( document.getElementById( 'use_optionitem_quantity_tracking_' + product_id + '_' + rand_id ) ).val(); if ( jQuery( document.getElementById( 'ec_allow_backorders_' + product_id + '_' + rand_id ) ).length && '1' == jQuery( document.getElementById( 'ec_allow_backorders_' + product_id + '_' + rand_id ) ).val() ) { use_optionitem_quantity_tracking = '0'; } if ( '1' == use_optionitem_quantity_tracking ) { var quantity = jQuery( this ).attr( 'data-optionitem-quantity' ); option2_selected( product_id, rand_id, optionitem_id_1, optionitem_id_2, quantity ); } else { ec_option2_updated( product_id, rand_id, optionitem_id_1, optionitem_id_2 ); } jQuery( '.ec_details_swatches > li.ec_option2_' + product_id + '_' + rand_id ).removeClass( 'ec_selected' ); jQuery( '.ec_details_swatches_ele > li.ec_option2_' + product_id + '_' + rand_id ).removeClass( 'ec_selected' ); jQuery( this ).addClass( 'ec_selected' ); jQuery( '.ec_option2_' + product_id + '_' + rand_id + '.ec_details_option_row_error' ).hide( ); jQuery( document.getElementById( 'ec_option2_' + product_id + '_' + rand_id ) ).val( optionitem_id_2 ); if ( jQuery( this ).find( 'img' ).length ) { if ( '' == jQuery( this ).find( 'img' ).attr( 'title' ) && '' != jQuery( this ).find( 'img' ).attr( 'pac_da_title' ) ) { jQuery( this ).parent( ).parent( ).find( '.ec_details_option_label_selected' ).html( jQuery( this ).find( 'img' ).attr( 'pac_da_title' ) ); } else { jQuery( this ).parent( ).parent( ).find( '.ec_details_option_label_selected' ).html( jQuery( this ).find( 'img' ).attr( 'title' ) ); } } else { jQuery( this ).parent( ).parent( ).find( '.ec_details_option_label_selected' ).html( jQuery( this ).attr( 'title' ) ); } ec_details_base_adjust_price( product_id, rand_id ); } } ); jQuery( '.ec_details_swatches > li.ec_option3, .ec_details_swatches_ele > li.ec_option3' ).click( function( ){ if( jQuery( this ).hasClass( 'ec_active' ) ){ var product_id = jQuery( this ).parent().parent().parent().attr( 'data-product-id' ); var rand_id = jQuery( this ).parent().parent().parent().attr( 'data-rand-id' ); var optionitem_id_1 = 0; 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 ){ 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' ); }else{ optionitem_id_1 = jQuery( '.ec_details_combo.ec_option1_' + product_id + '_' + rand_id ).val( ); } var optionitem_id_2 = 0; 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 ){ 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' ); }else{ optionitem_id_2 = jQuery( '.ec_details_combo.ec_option2_' + product_id + '_' + rand_id ).val( ); } var optionitem_id_3 = jQuery( this ).attr( 'data-optionitem-id' ); var use_optionitem_quantity_tracking = jQuery( document.getElementById( 'use_optionitem_quantity_tracking_' + product_id + '_' + rand_id ) ).val(); if ( jQuery( document.getElementById( 'ec_allow_backorders_' + product_id + '_' + rand_id ) ).length && '1' == jQuery( document.getElementById( 'ec_allow_backorders_' + product_id + '_' + rand_id ) ).val() ) { use_optionitem_quantity_tracking = '0'; } if ( '1' == use_optionitem_quantity_tracking ) { var quantity = jQuery( this ).attr( 'data-optionitem-quantity' ); option3_selected( product_id, rand_id, optionitem_id_1, optionitem_id_2, optionitem_id_3, quantity ); } else { ec_option3_updated( product_id, rand_id, optionitem_id_1, optionitem_id_2, optionitem_id_3 ); } jQuery( '.ec_details_swatches > li.ec_option3_' + product_id + '_' + rand_id ).removeClass( 'ec_selected' ); jQuery( '.ec_details_swatches_ele > li.ec_option3_' + product_id + '_' + rand_id ).removeClass( 'ec_selected' ); jQuery( this ).addClass( 'ec_selected' ); jQuery( '.ec_option3_' + product_id + '_' + rand_id + '.ec_details_option_row_error' ).hide( ); jQuery( document.getElementById( 'ec_option3_' + product_id + '_' + rand_id ) ).val( optionitem_id_3 ); if ( jQuery( this ).find( 'img' ).length ) { if ( '' == jQuery( this ).find( 'img' ).attr( 'title' ) && '' != jQuery( this ).find( 'img' ).attr( 'pac_da_title' ) ) { jQuery( this ).parent( ).parent( ).find( '.ec_details_option_label_selected' ).html( jQuery( this ).find( 'img' ).attr( 'pac_da_title' ) ); } else { jQuery( this ).parent( ).parent( ).find( '.ec_details_option_label_selected' ).html( jQuery( this ).find( 'img' ).attr( 'title' ) ); } } else { jQuery( this ).parent( ).parent( ).find( '.ec_details_option_label_selected' ).html( jQuery( this ).attr( 'title' ) ); } ec_details_base_adjust_price( product_id, rand_id ); } } ); jQuery( '.ec_details_swatches > li.ec_option4, .ec_details_swatches_ele > li.ec_option4' ).click( function( ){ if( jQuery( this ).hasClass( 'ec_active' ) ){ var product_id = jQuery( this ).parent().parent().parent().attr( 'data-product-id' ); var rand_id = jQuery( this ).parent().parent().parent().attr( 'data-rand-id' ); var optionitem_id_1 = 0; 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 ){ 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' ); }else{ optionitem_id_1 = jQuery( '.ec_details_combo.ec_option1_' + product_id + '_' + rand_id ).val( ); } var optionitem_id_2 = 0; 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 ){ 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' ); }else{ optionitem_id_2 = jQuery( '.ec_details_combo.ec_option2_' + product_id + '_' + rand_id ).val( ); } var optionitem_id_3 = 0; 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 ){ 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' ); }else{ optionitem_id_3 = jQuery( '.ec_details_combo.ec_option3_' + product_id + '_' + rand_id ).val( ); } var optionitem_id_4 = jQuery( this ).attr( 'data-optionitem-id' ); var use_optionitem_quantity_tracking = jQuery( document.getElementById( 'use_optionitem_quantity_tracking_' + product_id + '_' + rand_id ) ).val(); if ( jQuery( document.getElementById( 'ec_allow_backorders_' + product_id + '_' + rand_id ) ).length && '1' == jQuery( document.getElementById( 'ec_allow_backorders_' + product_id + '_' + rand_id ) ).val() ) { use_optionitem_quantity_tracking = '0'; } if ( '1' == use_optionitem_quantity_tracking ) { var quantity = jQuery( this ).attr( 'data-optionitem-quantity' ); option4_selected( product_id, rand_id, optionitem_id_1, optionitem_id_2, optionitem_id_3, optionitem_id_4, quantity ); } else { ec_option4_updated( product_id, rand_id, optionitem_id_1, optionitem_id_2, optionitem_id_3, optionitem_id_4 ); } jQuery( '.ec_details_swatches > li.ec_option4_' + product_id + '_' + rand_id ).removeClass( 'ec_selected' ); jQuery( '.ec_details_swatches_ele > li.ec_option4_' + product_id + '_' + rand_id ).removeClass( 'ec_selected' ); jQuery( this ).addClass( 'ec_selected' ); jQuery( '.ec_option4_' + product_id + '_' + rand_id + '.ec_details_option_row_error' ).hide( ); jQuery( document.getElementById( 'ec_option4_' + product_id + '_' + rand_id ) ).val( optionitem_id_4 ); if ( jQuery( this ).find( 'img' ).length ) { if ( '' == jQuery( this ).find( 'img' ).attr( 'title' ) && '' != jQuery( this ).find( 'img' ).attr( 'pac_da_title' ) ) { jQuery( this ).parent( ).parent( ).find( '.ec_details_option_label_selected' ).html( jQuery( this ).find( 'img' ).attr( 'pac_da_title' ) ); } else { jQuery( this ).parent( ).parent( ).find( '.ec_details_option_label_selected' ).html( jQuery( this ).find( 'img' ).attr( 'title' ) ); } } else { jQuery( this ).parent( ).parent( ).find( '.ec_details_option_label_selected' ).html( jQuery( this ).attr( 'title' ) ); } ec_details_base_adjust_price( product_id, rand_id ); } } ); jQuery( '.ec_details_swatches > li.ec_option5, .ec_details_swatches_ele > li.ec_option5' ).click( function( ){ if( jQuery( this ).hasClass( 'ec_active' ) ){ var product_id = jQuery( this ).parent().parent().parent().attr( 'data-product-id' ); var rand_id = jQuery( this ).parent().parent().parent().attr( 'data-rand-id' ); var optionitem_id_5 = jQuery( this ).attr( 'data-optionitem-id' ); jQuery( '.ec_details_swatches > li.ec_option5_' + product_id + '_' + rand_id ).removeClass( 'ec_selected' ); jQuery( '.ec_details_swatches_ele > li.ec_option5_' + product_id + '_' + rand_id ).removeClass( 'ec_selected' ); var quantity = jQuery( this ).attr( 'data-optionitem-quantity' ); jQuery( document.getElementById( 'ec_details_stock_quantity_' + product_id + '_' + rand_id ) ).html( quantity ); if ( 'inf' != quantity ) { jQuery( '.ec_details_stock_total' ).show(); } else { jQuery( '.ec_details_stock_total' ).hide(); } jQuery( document.getElementById('ec_quantity_' + product_id + '_' + rand_id ) ).attr( 'max', quantity ); if( Number( jQuery( document.getElementById('ec_quantity_' + product_id + '_' + rand_id ) ).val( ) ) > Number( quantity ) ){ jQuery( document.getElementById('ec_quantity_' + product_id + '_' + rand_id ) ).val( quantity ); } jQuery( this ).addClass( 'ec_selected' ); jQuery( '.ec_option5_' + product_id + '_' + rand_id + '.ec_details_option_row_error' ).hide( ); jQuery( document.getElementById( 'ec_option5_' + product_id + '_' + rand_id ) ).val( optionitem_id_5 ); if ( jQuery( this ).find( 'img' ).length ) { if ( '' == jQuery( this ).find( 'img' ).attr( 'title' ) && '' != jQuery( this ).find( 'img' ).attr( 'pac_da_title' ) ) { jQuery( this ).parent( ).parent( ).find( '.ec_details_option_label_selected' ).html( jQuery( this ).find( 'img' ).attr( 'pac_da_title' ) ); } else { jQuery( this ).parent( ).parent( ).find( '.ec_details_option_label_selected' ).html( jQuery( this ).find( 'img' ).attr( 'title' ) ); } } else { jQuery( this ).parent( ).parent( ).find( '.ec_details_option_label_selected' ).html( jQuery( this ).attr( 'title' ) ); } ec_details_base_adjust_price( product_id, rand_id ); } } ); jQuery( '.ec_details_radio_row.ec_optionitem_images > input' ).click( function( ){ var product_id = jQuery( this ).parent().parent().parent().attr( 'data-product-id' ); var rand_id = jQuery( this ).parent().parent().parent().attr( 'data-rand-id' ); var optionitem_id_1 = jQuery( this ).val( ); ec_option1_image_change( product_id, rand_id, optionitem_id_1, 1 ); } ); jQuery( '.ec_option_type_combo .ec_optionitem_images' ).click( function( ){ var product_id = jQuery( this ).parent().parent().attr( 'data-product-id' ); var rand_id = jQuery( this ).parent().parent().attr( 'data-rand-id' ); var optionitem_id_1 = jQuery( this ).val( ); ec_option1_image_change( product_id, rand_id, optionitem_id_1, 1 ); } ); jQuery( '.ec_option_type_combo .ec_optionitem_images' ).on( 'change', function( ){ var product_id = jQuery( this ).parent().parent().attr( 'data-product-id' ); var rand_id = jQuery( this ).parent().parent().attr( 'data-rand-id' ); var optionitem_id_1 = jQuery( this ).val( ); ec_option1_image_change( product_id, rand_id, optionitem_id_1, 1 ); } ); jQuery( '.ec_option_type_swatch li.ec_optionitem_images' ).click( function( ){ var product_id = jQuery( this ).parent().parent().parent().attr( 'data-product-id' ); var rand_id = jQuery( this ).parent().parent().parent().attr( 'data-rand-id' ); var optionitem_id_1 = jQuery( this ).attr( 'data-optionitem-id' ); ec_option1_image_change( product_id, rand_id, optionitem_id_1, 1 ); } ); jQuery( '.ec_details_combo.ec_option1' ).change( function( ){ var product_id = jQuery( this ).parent().parent().attr( 'data-product-id' ); var rand_id = jQuery( this ).parent().parent().attr( 'data-rand-id' ); var optionitem_id_1 = jQuery( '.ec_details_combo.ec_option1_' + product_id + '_' + rand_id ).val( ); var quantity = jQuery( '.ec_details_combo.ec_option1_' + product_id + '_' + rand_id + ' option:selected' ).attr( 'data-optionitem-quantity' ); var use_optionitem_quantity_tracking = jQuery( document.getElementById( 'use_optionitem_quantity_tracking_' + product_id + '_' + rand_id ) ).val(); if ( jQuery( document.getElementById( 'ec_allow_backorders_' + product_id + '_' + rand_id ) ).length && '1' == jQuery( document.getElementById( 'ec_allow_backorders_' + product_id + '_' + rand_id ) ).val() ) { use_optionitem_quantity_tracking = '0'; } if ( '1' == use_optionitem_quantity_tracking ) { if( optionitem_id_1 != '0' ){ ec_option1_selected( product_id, rand_id, optionitem_id_1, quantity ); }else{ jQuery( '.ec_details_combo.ec_option2_' + product_id + '_' + rand_id ).val( '0' ).prop( 'disabled', true ).addClass( 'ec_inactive' ); jQuery( '.ec_details_combo.ec_option3_' + product_id + '_' + rand_id ).val( '0' ).prop( 'disabled', true ).addClass( 'ec_inactive' ); jQuery( '.ec_details_combo.ec_option4_' + product_id + '_' + rand_id ).val( '0' ).prop( 'disabled', true ).addClass( 'ec_inactive' ); jQuery( '.ec_details_combo.ec_option5_' + product_id + '_' + rand_id ).val( '0' ).prop( 'disabled', true ).addClass( 'ec_inactive' ); jQuery( document.getElementById( 'ec_details_stock_quantity_' + product_id + '_' + rand_id ) ).html( quantity ); if ( 'inf' != quantity ) { jQuery( '.ec_details_stock_total' ).show(); } else { jQuery( '.ec_details_stock_total' ).hide(); } } } else { ec_option1_updated( product_id, rand_id, optionitem_id_1 ); } ec_option1_image_change( product_id, rand_id, optionitem_id_1, quantity ); jQuery( '.ec_option1_' + product_id + '_' + rand_id + '.ec_details_option_row_error' ).hide( ); ec_details_base_adjust_price( product_id, rand_id ); } ); jQuery( '.ec_details_combo.ec_option2' ).change( function( ){ var product_id = jQuery( this ).parent().parent().attr( 'data-product-id' ); var rand_id = jQuery( this ).parent().parent().attr( 'data-rand-id' ); var use_optionitem_quantity_tracking = jQuery( document.getElementById( 'use_optionitem_quantity_tracking_' + product_id + '_' + rand_id ) ).val(); if ( jQuery( document.getElementById( 'ec_allow_backorders_' + product_id + '_' + rand_id ) ).length && '1' == jQuery( document.getElementById( 'ec_allow_backorders_' + product_id + '_' + rand_id ) ).val() ) { use_optionitem_quantity_tracking = '0'; } var optionitem_id_1 = 0; 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 ){ 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' ); }else{ optionitem_id_1 = jQuery( '.ec_details_combo.ec_option1_' + product_id + '_' + rand_id ).val( ); } var optionitem_id_2 = jQuery( '.ec_details_combo.ec_option2_' + product_id + '_' + rand_id ).val( ); if ( '1' == use_optionitem_quantity_tracking ) { var quantity = jQuery( '.ec_details_combo.ec_option2_' + product_id + '_' + rand_id + ' option:selected' ).attr( 'data-optionitem-quantity' ); if( optionitem_id_2 != '0' ){ option2_selected( product_id, rand_id, optionitem_id_1, optionitem_id_2, quantity ); }else{ jQuery( document.getElementById( 'ec_details_stock_quantity_' + product_id + '_' + rand_id ) ).html( quantity ); if ( 'inf' != quantity ) { jQuery( '.ec_details_stock_total' ).show(); } else { jQuery( '.ec_details_stock_total' ).hide(); } } } else { ec_option2_updated( product_id, rand_id, optionitem_id_1, optionitem_id_2 ); } jQuery( '.ec_option2_' + product_id + '_' + rand_id + '.ec_details_option_row_error' ).hide( ); ec_details_base_adjust_price( product_id, rand_id ); } ); jQuery( '.ec_details_combo.ec_option3' ).change( function( ){ var product_id = jQuery( this ).parent().parent().attr( 'data-product-id' ); var rand_id = jQuery( this ).parent().parent().attr( 'data-rand-id' ); var use_optionitem_quantity_tracking = jQuery( document.getElementById( 'use_optionitem_quantity_tracking_' + product_id + '_' + rand_id ) ).val(); if ( jQuery( document.getElementById( 'ec_allow_backorders_' + product_id + '_' + rand_id ) ).length && '1' == jQuery( document.getElementById( 'ec_allow_backorders_' + product_id + '_' + rand_id ) ).val() ) { use_optionitem_quantity_tracking = '0'; } var optionitem_id_1 = 0; 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 ){ 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' ); }else{ optionitem_id_1 = jQuery( '.ec_details_combo.ec_option1_' + product_id + '_' + rand_id ).val( ); } var optionitem_id_2 = 0; 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 ){ 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' ); }else{ optionitem_id_2 = jQuery( '.ec_details_combo.ec_option2_' + product_id + '_' + rand_id ).val( ); } var optionitem_id_3 = jQuery( '.ec_details_combo.ec_option3_' + product_id + '_' + rand_id ).val( ); if ( '1' == use_optionitem_quantity_tracking ) { var quantity = jQuery( '.ec_details_combo.ec_option3_' + product_id + '_' + rand_id + ' option:selected' ).attr( 'data-optionitem-quantity' ); if( optionitem_id_3 != '0' ){ option3_selected( product_id, rand_id, optionitem_id_1, optionitem_id_2, optionitem_id_3, quantity ); }else{ jQuery( document.getElementById( 'ec_details_stock_quantity_' + product_id + '_' + rand_id ) ).html( quantity ); if ( 'inf' != quantity ) { jQuery( '.ec_details_stock_total' ).show(); } else { jQuery( '.ec_details_stock_total' ).hide(); } } } else { ec_option3_updated( product_id, rand_id, optionitem_id_1, optionitem_id_2, optionitem_id_3 ); } jQuery( '.ec_option3_' + product_id + '_' + rand_id + '.ec_details_option_row_error' ).hide( ); ec_details_base_adjust_price( product_id, rand_id ); } ); jQuery( '.ec_details_combo.ec_option4' ).change( function( ){ var product_id = jQuery( this ).parent().parent().attr( 'data-product-id' ); var rand_id = jQuery( this ).parent().parent().attr( 'data-rand-id' ); var use_optionitem_quantity_tracking = jQuery( document.getElementById( 'use_optionitem_quantity_tracking_' + product_id + '_' + rand_id ) ).val(); if ( jQuery( document.getElementById( 'ec_allow_backorders_' + product_id + '_' + rand_id ) ).length && '1' == jQuery( document.getElementById( 'ec_allow_backorders_' + product_id + '_' + rand_id ) ).val() ) { use_optionitem_quantity_tracking = '0'; } var optionitem_id_1 = 0; 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 ){ 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' ); }else{ optionitem_id_1 = jQuery( '.ec_details_combo.ec_option1_' + product_id + '_' + rand_id ).val( ); } var optionitem_id_2 = 0; 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 ){ 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' ); }else{ optionitem_id_2 = jQuery( '.ec_details_combo.ec_option2_' + product_id + '_' + rand_id ).val( ); } var optionitem_id_3 = 0; 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 ){ 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' ); }else{ optionitem_id_3 = jQuery( '.ec_details_combo.ec_option3_' + product_id + '_' + rand_id ).val( ); } var optionitem_id_4 = jQuery( '.ec_details_combo.ec_option4_' + product_id + '_' + rand_id ).val( ); if ( '1' == use_optionitem_quantity_tracking ) { var quantity = jQuery( '.ec_details_combo.ec_option4_' + product_id + '_' + rand_id + ' option:selected' ).attr( 'data-optionitem-quantity' ); if( optionitem_id_4 != '0' ){ option4_selected( product_id, rand_id, optionitem_id_1, optionitem_id_2, optionitem_id_3, optionitem_id_4, quantity ); }else{ jQuery( document.getElementById( 'ec_details_stock_quantity_' + product_id + '_' + rand_id ) ).html( quantity ); if ( 'inf' != quantity ) { jQuery( '.ec_details_stock_total' ).show(); } else { jQuery( '.ec_details_stock_total' ).hide(); } } } else { ec_option4_updated( product_id, rand_id, optionitem_id_1, optionitem_id_2, optionitem_id_3, optionitem_id_4 ); } jQuery( '.ec_option4_' + product_id + '_' + rand_id + '.ec_details_option_row_error' ).hide( ); ec_details_base_adjust_price( product_id, rand_id ); } ); jQuery( '.ec_details_combo.ec_option5' ).change( function( ){ var product_id = jQuery( this ).parent().parent().attr( 'data-product-id' ); var rand_id = jQuery( this ).parent().parent().attr( 'data-rand-id' ); var use_optionitem_quantity_tracking = jQuery( document.getElementById( 'use_optionitem_quantity_tracking_' + product_id + '_' + rand_id ) ).val(); if ( jQuery( document.getElementById( 'ec_allow_backorders_' + product_id + '_' + rand_id ) ).length && '1' == jQuery( document.getElementById( 'ec_allow_backorders_' + product_id + '_' + rand_id ) ).val() ) { use_optionitem_quantity_tracking = '0'; } if ( '1' == use_optionitem_quantity_tracking ) { var quantity = jQuery( '.ec_details_combo.ec_option5_' + product_id + '_' + rand_id + ' option:selected' ).attr( 'data-optionitem-quantity' ); jQuery( document.getElementById( 'ec_details_stock_quantity_' + product_id + '_' + rand_id ) ).html( quantity ); if ( 'inf' != quantity ) { jQuery( '.ec_details_stock_total' ).show(); } else { jQuery( '.ec_details_stock_total' ).hide(); } } jQuery( '.ec_option5_' + product_id + '_' + rand_id + '.ec_details_option_row_error' ).hide( ); ec_details_base_adjust_price( product_id, rand_id ); } ); jQuery( '.ec_details_tab' ).click( function( ){ var product_id = jQuery( this ).parent().attr( 'data-product-id' ); var rand_id = jQuery( this ).parent().attr( 'data-rand-id' ); jQuery( '.ec_details_tab_' + product_id + '_' + rand_id ).removeClass( 'ec_active' ); jQuery( this ).addClass( 'ec_active' ); jQuery( '.ec_details_extra_area_' + product_id + '_' + rand_id ).children( 'div' ).each( function( ){ jQuery( this ).hide() } ); if( jQuery( this ).hasClass( 'ec_description' ) ) { jQuery( '.ec_details_description_tab_' + product_id + '_' + rand_id ).show( ); } else if( jQuery( this ).hasClass( 'ec_specifications' ) ) { jQuery( '.ec_details_specifications_tab_' + product_id + '_' + rand_id ).show( ); } else if( jQuery( this ).hasClass( 'ec_customer_reviews' ) ) { jQuery( '.ec_details_customer_reviews_tab_' + product_id + '_' + rand_id ).show( ); } else { jQuery( '.ec_details_' + jQuery( this ).attr( 'data-tab-id' ) + '_tab' ).show( ); } jQuery( this ).parent().toggleClass( 'ec_is_open' ); } ); jQuery( '.ec_details_review_input' ).hover( function() { var product_id = jQuery( this ).parent().attr( 'data-product-id' ); var rand_id = jQuery( this ).parent().attr( 'data-rand-id' ); var score = jQuery( this ).attr( 'data-review-score' ); 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' ) ) { jQuery( '.ec_details_review_input_' + product_id + '_' + rand_id ).removeClass( 'ec_product_details_star_on_ele' ).addClass( 'ec_product_details_star_off_ele' ); } else { jQuery( '.ec_details_review_input_' + product_id + '_' + rand_id ).removeClass( 'ec_product_details_star_on' ).addClass( 'ec_product_details_star_off' ); } for( var i=0; i reviews_per_page ){ var i=0; reviews.each( function( ){ if( i < (reviews_per_page * page ) && i >= (reviews_per_page * (page-1) ) ){ jQuery( this ).show( ); }else{ jQuery( this ).hide( ); } i++; } ); i=0; review_ele.find( '#ec_details_customer_review_paging_' + product_id + ' > button' ).removeClass( 'selected' ).each( function( ){ if( ( i+1 ) == page ){ jQuery( this ).addClass( 'selected' ); } i++; } ); } } function wpeasycart_login_recaptcha_callback( response ){ jQuery( document.getElementById( 'ec_grecaptcha_response_login' ) ).val( response ); if( response.length ){ jQuery( '#ec_account_login_recaptcha > div' ).css( 'border', 'none' ); }else{ jQuery( '#ec_account_login_recaptcha > div' ).css( 'border', '1px solid red' ); } } function wpeasycart_login_widget_recaptcha_callback( response ){ jQuery( document.getElementById( 'ec_grecaptcha_response_login_widget' ) ).val( response ); if( response.length ){ jQuery( '#ec_account_login_widget_recaptcha > div' ).css( 'border', 'none' ); }else{ jQuery( '#ec_account_login_widget_recaptcha > div' ).css( 'border', '1px solid red' ); } } function wpeasycart_register_recaptcha_callback( response ){ jQuery( document.getElementById( 'ec_grecaptcha_response_register' ) ).val( response ); if( response.length ){ jQuery( '#ec_account_register_recaptcha > div' ).css( 'border', 'none' ); }else{ jQuery( '#ec_account_register_recaptcha > div' ).css( 'border', '1px solid red' ); } } function wpeasycart_product_details_recaptcha_callback( response ){ jQuery( document.getElementById( 'ec_grecaptcha_response_product_details' ) ).val( response ); if( response.length ){ jQuery( '#ec_product_details_recaptcha > div' ).css( 'border', 'none' ); }else{ jQuery( '#ec_product_details_recaptcha > div' ).css( 'border', '1px solid red' ); } } function wpeasycart_inquiry_recaptcha_callback( response ){ jQuery( document.getElementById( 'ec_grecaptcha_response_inquiry' ) ).val( response ); if( response.length ){ jQuery( '#ec_product_details_inquiry_recaptcha > div' ).css( 'border', 'none' ); }else{ jQuery( '#ec_product_details_inquiry_recaptcha > div' ).css( 'border', '1px solid red' ); } } function wpeasycart_cart_billing_country_update( ){ if( document.getElementById( 'ec_cart_billing_country' ) ){ var selected_country = jQuery( document.getElementById( 'ec_cart_billing_country' ) ).val( ); if( ec_is_state_required( selected_country ) ) jQuery( document.getElementById( 'ec_billing_state_required' ) ).show( ); else jQuery( document.getElementById( 'ec_billing_state_required' ) ).hide( ); if( document.getElementById( 'ec_cart_billing_state_' + selected_country ) ){ jQuery( '.ec_billing_state_dropdown, #ec_cart_billing_state' ).hide( ); jQuery( document.getElementById( 'ec_cart_billing_state_' + selected_country ) ).show( ); }else{ jQuery( '.ec_billing_state_dropdown' ).hide( ); jQuery( document.getElementById( 'ec_cart_billing_state' ) ).show( ); } } } function wpeasycart_cart_shipping_country_update( ){ if( document.getElementById( 'ec_cart_shipping_country' ) ){ var selected_country = jQuery( document.getElementById( 'ec_cart_shipping_country' ) ).val( ); if( ec_is_state_required( selected_country ) ) jQuery( document.getElementById( 'ec_shipping_state_required' ) ).show( ); else jQuery( document.getElementById( 'ec_shipping_state_required' ) ).hide( ); if( document.getElementById( 'ec_cart_shipping_state_' + selected_country ) ){ jQuery( '.ec_shipping_state_dropdown, #ec_cart_shipping_state' ).hide( ); jQuery( document.getElementById( 'ec_cart_shipping_state_' + selected_country ) ).show( ); }else{ jQuery( '.ec_shipping_state_dropdown' ).hide( ); jQuery( document.getElementById( 'ec_cart_shipping_state' ) ).show( ); } } } function wpeasycart_account_billing_country_update( ){ if( document.getElementById( 'ec_account_billing_information_country' ) ){ var selected_country = jQuery( document.getElementById( 'ec_account_billing_information_country' ) ).val( ); if( ec_is_state_required( selected_country ) ) jQuery( document.getElementById( 'ec_billing_state_required' ) ).show( ); else jQuery( document.getElementById( 'ec_billing_state_required' ) ).hide( ); if( document.getElementById( 'ec_account_billing_information_state_' + selected_country ) ){ jQuery( '.ec_billing_state_dropdown, #ec_account_billing_information_state' ).hide( ); jQuery( document.getElementById( 'ec_account_billing_information_state_' + selected_country ) ).show( ); }else{ jQuery( '.ec_billing_state_dropdown' ).hide( ); jQuery( document.getElementById( 'ec_account_billing_information_state' ) ).show( ); } } } function wpeasycart_account_shipping_country_update( ){ if( document.getElementById( 'ec_account_shipping_information_country' ) ){ var selected_country = jQuery( document.getElementById( 'ec_account_shipping_information_country' ) ).val( ); if( ec_is_state_required( selected_country ) ) jQuery( document.getElementById( 'ec_shipping_state_required' ) ).show( ); else jQuery( document.getElementById( 'ec_shipping_state_required' ) ).hide( ); if( document.getElementById( 'ec_account_shipping_information_state_' + selected_country ) ){ jQuery( '.ec_shipping_state_dropdown, #ec_account_shipping_information_state' ).hide( ); jQuery( document.getElementById( 'ec_account_shipping_information_state_' + selected_country ) ).show( ); }else{ jQuery( '.ec_shipping_state_dropdown' ).hide( ); jQuery( document.getElementById( 'ec_account_shipping_information_state' ) ).show( ); } } } function wpeasycart_isTouchDevice() { return 'ontouchstart' in window || !!(navigator.msMaxTouchPoints); } function ec_product_show_quick_view_link( modelnum ){ jQuery( document.getElementById( 'ec_product_quickview_container_' + modelnum ) ).fadeIn(100); } function ec_product_hide_quick_view_link( modelnum ){ jQuery( document.getElementById( 'ec_product_quickview_container_' + modelnum ) ).fadeOut(100); } function 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 = '' ){ var url_string = URL + divider + "filternum=" + document.getElementById('sortfield').value; if( subsubmenu_id != 0 ){ url_string = url_string + "&subsubmenuid=" + subsubmenu_id; if( subsubmenu_name != 0 ) url_string = url_string + "&subsubmenu=" + subsubmenu_name; }else if( submenu_id != 0 ){ url_string = url_string + "&submenuid=" + submenu_id; if( submenu_name != 0 ) url_string = url_string + "&submenu=" + submenu_name; }else if( menu_id != 0 ){ url_string = url_string + "&menuid=" + menu_id; if( menu_name != 0 ) url_string = url_string + "&menu=" + menu_name; } if( manufacturer_id > 0 ) url_string = url_string + "&manufacturer=" + manufacturer_id; if( pricepoint_id > 0 ) url_string = url_string + "&pricepoint=" + pricepoint_id; if( currentpage_selected ) url_string = url_string + "&pagenum=" + currentpage_selected; if( perpage ) url_string = url_string + "&perpage=" + perpage; if( filter_option ) url_string = url_string + "&filter_option=" + filter_option; window.location = url_string; } function ec_add_to_cart_redirect( product_id, model_number, quantity, use_quantity_tracking, min_quantity, max_quantity, nonce, quantity_ele = false ) { return true; } function ec_add_to_cart( product_id, model_number, quantity, use_quantity_tracking, min_quantity, max_quantity, nonce, quantity_ele = false ) { if( !use_quantity_tracking || ( !isNaN( quantity ) && quantity > 0 && quantity >= min_quantity && quantity <= max_quantity ) ){ if ( quantity_ele && jQuery( '#' + quantity_ele ).length ) { if ( Number( jQuery( '#' + quantity_ele ).val() ) >= min_quantity && Number( jQuery( '#' + quantity_ele ).val() ) <= max_quantity ) { quantity = Number( jQuery( '#' + quantity_ele ).val() ); } } ec_product_hide_quick_view_link( model_number ); jQuery( document.getElementById( 'ec_addtocart_quantity_exceeded_error_' + model_number ) ).hide( ); jQuery( document.getElementById( 'ec_addtocart_quantity_minimum_error_' + model_number ) ).hide( ); jQuery( document.getElementById( "ec_product_loader_" + model_number ) ).show( ); var data = { action: 'ec_ajax_add_to_cart', product_id: product_id, model_number: model_number, quantity: quantity, nonce: nonce }; jQuery.ajax({url: wpeasycart_ajax_object.ajax_url, type: 'post', data: data, success: function( data ){ var json_data = JSON.parse( data ); jQuery( document.getElementById( "ec_product_loader_" + model_number ) ).hide( ); jQuery( document.getElementById( "ec_product_added_" + model_number ) ).show( ).delay( 2500 ).fadeOut( 'slow' ); if ( jQuery( document.getElementById( "ec_added_to_cart_" + product_id ) ).length ) { jQuery( document.getElementById( "ec_add_to_cart_" + product_id ) ).css( 'display', 'none' ); jQuery( document.getElementById( "ec_added_to_cart_" + product_id ) ).css( 'display', 'inline-block' ); } if ( jQuery( document.getElementById( "ec_added_to_cart_type6_" + product_id ) ).length ) { jQuery( document.getElementById( "ec_add_to_cart_" + product_id ) ).css( 'display', 'none' ); jQuery( document.getElementById( "ec_added_to_cart_type6_" + product_id ) ).css( 'display', 'inline-block' ); } jQuery( '.ec_product_added_to_cart' ).fadeIn( 'slow' ); jQuery( ".ec_cart_items_total" ).html( json_data[0].total_items ); jQuery( ".ec_cart_price_total" ).html( json_data[0].total_price ); if( json_data[0].total_items == 1 ){ jQuery( ".ec_menu_cart_singular_text" ).show( ); jQuery( ".ec_menu_cart_plural_text" ).hide( ); }else{ jQuery( ".ec_menu_cart_singular_text" ).hide( ); jQuery( ".ec_menu_cart_plural_text" ).show( ); } if( json_data[0].total_items == 0 ){ jQuery( ".ec_cart_price_total" ).hide( ); }else{ jQuery( ".ec_cart_price_total" ).show( ); } if( jQuery( '.ec_cart_widget_minicart_product_padding' ).length ){ jQuery( '.ec_cart_widget_minicart_product_padding' ).html(''); for( var i=0; i' + json_data[i].title + ' x ' + json_data[i].quantity + ' @ ' + json_data[i].price + '' ); } } } } ); }else{ if( !isNaN( quantity ) && ( quantity < min_quantity || quantity < 1 ) ){ jQuery( document.getElementById( 'ec_addtocart_quantity_minimum_error_' + model_number ) ).show( ); jQuery( document.getElementById( 'ec_addtocart_quantity_exceeded_error_' + model_number ) ).hide( ); }else{ jQuery( document.getElementById( 'ec_addtocart_quantity_exceeded_error_' + model_number ) ).show( ); jQuery( document.getElementById( 'ec_addtocart_quantity_minimum_error_' + model_number ) ).hide( ); } } } function ec_minus_quantity( product_id, min_quantity ){ var currval = jQuery( document.getElementById( 'ec_quantity_' + product_id ) ).val( ); currval = Number( currval ) - 1; if( currval <= 0 ){ currval = 1; } if( currval < min_quantity ){ currval = min_quantity; } jQuery( document.getElementById( 'ec_quantity_' + product_id ) ).val( currval ); } function ec_plus_quantity( product_id, track_quantity, max_quantity ){ if( jQuery( document.getElementById( 'ec_details_stock_quantity_' + product_id ) ).length && jQuery( document.getElementById( 'ec_details_stock_quantity_' + product_id ) ).val( ) != 10000000 ){ 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( ) ); } if( max_quantity > 0 && max_quantity != 10000000 ){ jQuery( document.getElementById( 'ec_quantity_' + product_id ) ).attr( 'max', max_quantity ); } var currval = Number( jQuery( document.getElementById( 'ec_quantity_' + product_id ) ).val( ) ); if( currval < Number( max_quantity ) ){ currval = currval + 1; }else if( max_quantity != 10000000 ){ currval = Number( max_quantity ); }else{ currval = currval + 1; } jQuery( document.getElementById( 'ec_quantity_' + product_id ) ).val( currval ); } function ec_cartitem_delete( cartitem_id, model_number, nonce ){ var data = { action: 'ec_ajax_cartitem_delete', ec_v3_24: 'true', cartitem_id: cartitem_id, nonce: nonce } jQuery( document.getElementById( 'ec_cartitem_delete_' + cartitem_id ) ).hide( ); jQuery( document.getElementById( 'ec_cartitem_deleting_' + cartitem_id ) ).show( ); jQuery.ajax({url: wpeasycart_ajax_object.ajax_url, type: 'post', data: data, success: function(data){ jQuery( document.getElementById( 'ec_cartitem_row_' + cartitem_id ) ).remove( ); jQuery( '.ec_cartitem_' + cartitem_id ).remove(); jQuery( document.getElementById( 'ec_cartitem_min_error_' + cartitem_id ) ).remove( ); jQuery( document.getElementById( 'ec_cartitem_max_error_' + cartitem_id ) ).remove( ); jQuery( document.getElementById( 'ec_cart_widget_row_' + cartitem_id ) ).remove( ); // Get Response Data var response_obj = JSON.parse( data ); // Update Cart ec_update_cart( response_obj ); } } ); } var ec_cartitem_update_clickTimeout; function ec_cartitem_update_v2( cartitem_id, model_number, nonce ){ clearTimeout( ec_cartitem_update_clickTimeout ); ec_cartitem_update_clickTimeout = setTimeout( function() { ec_cartitem_update( cartitem_id, model_number, nonce ); }, 500 ); } function ec_cartitem_update( cartitem_id, model_number, nonce ){ var data = { action: 'ec_ajax_cartitem_update', ec_v3_24: 'true', cartitem_id: cartitem_id, quantity: jQuery( document.getElementById( 'ec_quantity_' + model_number ) ).val( ), nonce: nonce }; jQuery( document.getElementById( 'ec_cartitem_updating_' + cartitem_id ) ).show( ); jQuery.ajax({url: wpeasycart_ajax_object.ajax_url, type: 'post', data: data, success: function( data ){ jQuery( document.getElementById( 'ec_cartitem_updating_' + cartitem_id ) ).hide( ); // Get Response Data var response_obj = JSON.parse( data ); // Update Cart ec_update_cart( response_obj ); } } ); } function ec_apply_coupon( nonce, is_mobile = false ){ jQuery( document.getElementById( 'ec_apply_coupon' ) ).hide( ); if ( jQuery( '#ec_applying_coupon_v2' ).length ) { jQuery( '#ec_applying_coupon_v2' ).addClass( 'ec_cart_button_working_active' ); jQuery( '#ec_applying_coupon_v2_mobile' ).addClass( 'ec_cart_button_working_active' ); jQuery( document.getElementById( 'ec_apply_coupon_mobile' ) ).hide( ); } else { jQuery( document.getElementById( 'ec_applying_coupon' ) ).show( ); } var coupon_code = ( is_mobile ) ? jQuery( document.getElementById( 'ec_coupon_code_mobile' ) ).val() : jQuery( document.getElementById( 'ec_coupon_code' ) ).val( ); if ( is_mobile ) { jQuery( document.getElementById( 'ec_coupon_code' ) ).val( coupon_code ); } else { if ( jQuery( document.getElementById( 'ec_coupon_code_mobile' ) ).length ) { jQuery( document.getElementById( 'ec_coupon_code_mobile' ) ).val( coupon_code ) } } var data = { action: 'ec_ajax_redeem_coupon_code', ec_v3_24: 'true', couponcode: coupon_code, nonce: nonce }; jQuery.ajax( { url: wpeasycart_ajax_object.ajax_url, type: 'post', data: data, success: function( data ){ jQuery( document.getElementById( 'ec_apply_coupon' ) ).show( ); if ( jQuery( '#ec_applying_coupon_v2' ).length ) { jQuery( '#ec_applying_coupon_v2' ).removeClass( 'ec_cart_button_working_active' ); jQuery( '#ec_applying_coupon_v2_mobile' ).removeClass( 'ec_cart_button_working_active' ); jQuery( document.getElementById( 'ec_apply_coupon_mobile' ) ).show( ); } else { jQuery( document.getElementById( 'ec_applying_coupon' ) ).hide( ); } // Get Response Data var response_obj = JSON.parse( data ); // Update Cart ec_update_cart( response_obj ); // Update Coupon Info if( response_obj.is_coupon_valid ){ jQuery( document.getElementById( 'ec_coupon_error' ) ).hide( ); jQuery( document.getElementById( 'ec_coupon_success' ) ).html( response_obj.coupon_message ).show( ); if ( jQuery( '#ec_applying_coupon_v2' ).length ) { jQuery( document.getElementById( 'ec_coupon_error_mobile' ) ).hide( ); jQuery( document.getElementById( 'ec_coupon_success_mobile' ) ).html( response_obj.coupon_message ).show( ); } }else{ jQuery( document.getElementById( 'ec_coupon_success' ) ).hide( ); jQuery( document.getElementById( 'ec_coupon_error' ) ).html( response_obj.coupon_message ).show( ); if ( jQuery( '#ec_applying_coupon_v2' ).length ) { jQuery( document.getElementById( 'ec_coupon_success_mobile' ) ).hide( ); jQuery( document.getElementById( 'ec_coupon_error_mobile' ) ).html( response_obj.coupon_message ).show( ); } } } } ); } function subscription_create_account( nonce ) { var email_complete = ec_validate_email_block( 'ec_contact' ); var create_account_complete = ec_validate_create_account( 'ec_contact' ); var recaptcha_complete = true; var recaptcha_response = ''; if ( document.getElementById( 'ec_account_register_recaptcha' ) ) { recaptcha_response = jQuery( document.getElementById( 'ec_grecaptcha_response_register' ) ).val(); if ( ! recaptcha_response.length ) { jQuery( '#ec_account_register_recaptcha > div' ).css( 'border', '1px solid red' ); recaptcha_complete = false; } else { jQuery( '#ec_account_register_recaptcha > div' ).css( 'border', 'none' ); } } if ( email_complete && create_account_complete && recaptcha_complete ) { jQuery( document.getElementById( 'ec_cart_create_account_loader' ) ).show(); var email = jQuery( document.getElementById( 'ec_contact_email' ) ).val(); var first_name = ( jQuery( document.getElementById( 'ec_contact_first_name' ) ).length ) ? jQuery( document.getElementById( 'ec_contact_first_name' ) ).val() : ''; var last_name = ( jQuery( document.getElementById( 'ec_contact_last_name' ) ).length ) ? jQuery( document.getElementById( 'ec_contact_last_name' ) ).val() : ''; var password = jQuery( document.getElementById( 'ec_contact_password' ) ).val(); var data = { action: 'ec_ajax_subscription_create_account', nonce: nonce, ec_contact_email: email, ec_contact_first_name: first_name, ec_contact_last_name: last_name, ec_contact_password: password, recaptcha_response: recaptcha_response }; jQuery.ajax( { url: wpeasycart_ajax_object.ajax_url, type: 'post', data: data, success: function( response ){ var data_arr = JSON.parse( response ); if ( data_arr['error'] ) { jQuery( document.getElementById( 'ec_subscription_email_exists' ) ).show(); jQuery( document.getElementById( 'ec_cart_create_account_loader' ) ).hide(); } else { ec_reload_cart(); jQuery( document.getElementById( 'ec_subscription_email_exists' ) ).hide(); jQuery( document.getElementById( 'ec_user_contact_form' ) ).hide(); jQuery( document.getElementById( 'ec_user_logged_out_header' ) ).hide(); jQuery( document.getElementById( 'ec_cart_user_logged_in_name' ) ).html( data_arr['name'] ); jQuery( document.getElementById( 'ec_cart_billing_first_name' ) ).val( data_arr['first_name'] ); jQuery( document.getElementById( 'ec_cart_billing_last_name' ) ).val( data_arr['last_name'] ); jQuery( document.getElementById( 'ec_cart_shipping_first_name' ) ).val( data_arr['first_name'] ); jQuery( document.getElementById( 'ec_cart_shipping_last_name' ) ).val( data_arr['last_name'] ); jQuery( document.getElementById( 'ec_user_logged_in_form' ) ).show(); jQuery( document.getElementById( 'ec_cart_billing_form' ) ).show(); jQuery( document.getElementById( 'ec_cart_billing_locked' ) ).hide(); if ( jQuery( document.getElementById( 'ec_cart_shipping_locked' ) ).length ) { jQuery( document.getElementById( 'ec_cart_shipping_locked' ) ).hide(); } jQuery( document.getElementById( 'ec_cart_subscription_end_form' ) ).hide(); } } } ); } } function update_subscription_totals( product_id, nonce ){ var billing_complete = ec_validate_address_block( 'ec_cart_billing' ); var shipping_complete = true; if( jQuery( document.getElementById( 'ec_shipping_selector' ) ).is( ':checked' ) ) { shipping_complete = ec_validate_address_block( 'ec_cart_shipping' ); } if ( billing_complete && shipping_complete ) { jQuery( document.getElementById( 'ec_cart_address_loader' ) ).show(); var shipping_selector = 0; if( jQuery( document.getElementById( 'ec_shipping_selector' ) ).length && jQuery( document.getElementById( 'ec_shipping_selector' ) ).is( ':checked' ) ){ shipping_selector = 1; } var vat_registration_number = ''; if( jQuery( document.getElementById( 'ec_cart_billing_vat_registration_number' ) ).length ){ vat_registration_number = jQuery( document.getElementById( 'ec_cart_billing_vat_registration_number' ) ).val( ); } var billing_first_name = ( jQuery( document.getElementById( 'ec_cart_billing_first_name' ) ).length ) ? jQuery( document.getElementById( 'ec_cart_billing_first_name' ) ).val() : ''; var billing_last_name = ( jQuery( document.getElementById( 'ec_cart_billing_last_name' ) ).length ) ? jQuery( document.getElementById( 'ec_cart_billing_last_name' ) ).val() : ''; var billing_company_name = ( jQuery( document.getElementById( 'ec_cart_billing_company_name' ) ).length ) ? jQuery( document.getElementById( 'ec_cart_billing_company_name' ) ).val() : ''; var billing_address_line_1 = ( jQuery( document.getElementById( 'ec_cart_billing_address' ) ).length ) ? jQuery( document.getElementById( 'ec_cart_billing_address' ) ).val() : ''; var billing_address_line_2 = ( jQuery( document.getElementById( 'ec_cart_billing_address2' ) ).length ) ? jQuery( document.getElementById( 'ec_cart_billing_address2' ) ).val() : ''; var billing_city = ( jQuery( document.getElementById( 'ec_cart_billing_city' ) ).length ) ? jQuery( document.getElementById( 'ec_cart_billing_city' ) ).val() : ''; var billing_state = jQuery( document.getElementById( 'ec_cart_billing_state' ) ).val(); var billing_zip = ( jQuery( document.getElementById( 'ec_cart_billing_zip' ) ).length ) ? jQuery( document.getElementById( 'ec_cart_billing_zip' ) ).val() : ''; var billing_country = jQuery( document.getElementById( 'ec_cart_billing_country' ) ).val(); if( '0' != billing_country && jQuery( document.getElementById( 'ec_cart_billing_state_' + billing_country ) ).length ){ billing_state = jQuery( document.getElementById( 'ec_cart_billing_state_' + billing_country ) ).val(); } var billing_phone = ( jQuery( document.getElementById( 'ec_cart_billing_phone' ) ).length ) ? jQuery( document.getElementById( 'ec_cart_billing_phone' ) ).val() : ''; var shipping_first_name = billing_first_name; var shipping_last_name = billing_last_name; var shipping_company_name = billing_company_name; var shipping_address_line_1 = billing_address_line_1; var shipping_address_line_2 = billing_address_line_2; var shipping_city = billing_city; var shipping_state = billing_state; var shipping_zip = billing_zip; var shipping_country = billing_country; var shipping_phone = billing_phone; if ( shipping_selector ) { shipping_state = jQuery( document.getElementById( 'ec_cart_shipping_state' ) ).val(); shipping_country = jQuery( document.getElementById( 'ec_cart_shipping_country' ) ).val(); if( '0' != shipping_country && jQuery( document.getElementById( 'ec_cart_shipping_state_' + shipping_country ) ).length ){ shipping_state = jQuery( document.getElementById( 'ec_cart_shipping_state_' + shipping_country ) ).val(); } shipping_first_name = ( jQuery( document.getElementById( 'ec_cart_shipping_first_name' ) ).length ) ? jQuery( document.getElementById( 'ec_cart_shipping_first_name' ) ).val() : ''; shipping_last_name = ( jQuery( document.getElementById( 'ec_cart_shipping_last_name' ) ).length ) ? jQuery( document.getElementById( 'ec_cart_shipping_last_name' ) ).val() : ''; shipping_company_name = ( jQuery( document.getElementById( 'ec_cart_shipping_company_name' ) ).length ) ? jQuery( document.getElementById( 'ec_cart_shipping_company_name' ) ).val() : ''; shipping_address_line_1 = ( jQuery( document.getElementById( 'ec_cart_shipping_address' ) ).length ) ? jQuery( document.getElementById( 'ec_cart_shipping_address' ) ).val() : ''; shipping_address_line_2 = ( jQuery( document.getElementById( 'ec_cart_shipping_address2' ) ).length ) ? jQuery( document.getElementById( 'ec_cart_shipping_address2' ) ).val() : ''; shipping_city = ( jQuery( document.getElementById( 'ec_cart_shipping_city' ) ).length ) ? jQuery( document.getElementById( 'ec_cart_shipping_city' ) ).val() : ''; shipping_zip = ( jQuery( document.getElementById( 'ec_cart_shipping_zip' ) ).length ) ? jQuery( document.getElementById( 'ec_cart_shipping_zip' ) ).val() : ''; shipping_phone = ( jQuery( document.getElementById( 'ec_cart_shipping_phone' ) ).length ) ? jQuery( document.getElementById( 'ec_cart_shipping_phone' ) ).val() : ''; } var data = { action: 'ec_ajax_update_subscription_tax', product_id: product_id, shipping_selector: shipping_selector, nonce: nonce, vat_registration_number: vat_registration_number, billing_first_name: billing_first_name, billing_last_name: billing_last_name, billing_company_name: billing_company_name, billing_country: billing_country, billing_address: billing_address_line_1, billing_address2: billing_address_line_2, billing_city: billing_city, billing_state: billing_state, billing_zip: billing_zip, billing_phone: billing_phone, shipping_first_name: shipping_first_name, shipping_last_name: shipping_last_name, shipping_company_name: shipping_company_name, shipping_country: shipping_country, shipping_address: shipping_address_line_1, shipping_address2: shipping_address_line_2, shipping_city: shipping_city, shipping_state: shipping_state, shipping_zip: shipping_zip, shipping_phone: shipping_phone }; jQuery.ajax( { url: wpeasycart_ajax_object.ajax_url, type: 'post', data: data, success: function( response ){ var data_arr = JSON.parse( response ); wpeasycart_subscription_cart_update_totals( data_arr ); jQuery( document.getElementById( 'ec_cart_billing_form' ) ).hide(); jQuery( document.getElementById( 'ec_cart_billing_address_display' ) ).html( data_arr['billing_address_display'] ); jQuery( document.getElementById( 'ec_cart_billing_locked' ) ).show(); if ( jQuery( document.getElementById( 'ec_cart_shipping_locked' ) ).length ) { jQuery( document.getElementById( 'ec_cart_shipping_address_display' ) ).html( data_arr['shipping_address_display'] ); jQuery( document.getElementById( 'ec_cart_shipping_locked' ) ).show(); } jQuery( document.getElementById( 'ec_cart_subscription_end_form' ) ).show(); jQuery( document.getElementById( 'ec_cart_address_loader' ) ).hide(); } } ); } } function wpeasycart_subscription_cart_update_totals( data_arr ) { jQuery( document.getElementById( 'ec_cart_discount' ) ).html( data_arr['discount_total'] ); jQuery( document.getElementById( 'ec_cart_discount_mobile' ) ).html( data_arr['discount_total'] ); if ( data_arr['has_discount'] ) { jQuery( '.ec_cart_price_row_discount_total' ).removeClass( 'ec_no_discount' ); } else { jQuery( '.ec_cart_price_row_discount_total' ).removeClass( 'ec_no_discount' ).addClass( 'ec_no_discount' ); } if( jQuery( document.getElementById( 'ec_cart_tax' ) ).length ){ jQuery( document.getElementById( 'ec_cart_tax' ) ).html( data_arr['tax_total'] ); jQuery( document.getElementById( 'ec_cart_tax_mobile' ) ).html( data_arr['tax_total'] ); } if( jQuery( document.getElementById( 'ec_cart_vat' ) ).length ){ jQuery( document.getElementById( 'ec_cart_vat' ) ).html( data_arr['vat_total'] ); jQuery( document.getElementById( 'ec_cart_vat_mobile' ) ).html( data_arr['vat_total'] ); } if( jQuery( document.getElementById( 'ec_cart_vat_rate' ) ).length ){ jQuery( document.getElementById( 'ec_cart_vat_rate' ) ).html( data_arr['vat_rate_formatted'] ); } if( jQuery( document.getElementById( 'ec_cart_vat_rate_mobile' ) ).length ){ jQuery( document.getElementById( 'ec_cart_vat_rate_mobile' ) ).html( data_arr['vat_rate_formatted'] ); } if( jQuery( document.getElementById( 'ec_cart_hst' ) ).length ){ jQuery( document.getElementById( 'ec_cart_hst' ) ).html( data_arr['hst_total'] ); jQuery( document.getElementById( 'ec_cart_hst_mobile' ) ).html( data_arr['hst_total'] ); jQuery( document.getElementById( 'ec_cart_hst_rate' ) ).html( data_arr['hst_rate'] ); jQuery( document.getElementById( 'ec_cart_hst_rate_mobile' ) ).html( data_arr['hst_rate'] ); if( data_arr['hst_rate'] > 0 ){ jQuery( document.getElementById( 'ec_cart_hst_row' ) ).show( ); jQuery( document.getElementById( 'ec_cart_hst_row_mobile' ) ).show( ); }else{ jQuery( document.getElementById( 'ec_cart_hst_row' ) ).hide( ); jQuery( document.getElementById( 'ec_cart_hst_row_mobile' ) ).hide( ); } } if( jQuery( document.getElementById( 'ec_cart_pst' ) ).length ){ jQuery( document.getElementById( 'ec_cart_pst' ) ).html( data_arr['pst_total'] ); jQuery( document.getElementById( 'ec_cart_pst_mobile' ) ).html( data_arr['pst_total'] ); jQuery( document.getElementById( 'ec_cart_pst_rate' ) ).html( data_arr['pst_rate'] ); jQuery( document.getElementById( 'ec_cart_pst_rate_mobile' ) ).html( data_arr['pst_rate'] ); if( data_arr['pst_rate'] > 0 ){ jQuery( document.getElementById( 'ec_cart_pst_row' ) ).show( ); jQuery( document.getElementById( 'ec_cart_pst_row_mobile' ) ).show( ); }else{ jQuery( document.getElementById( 'ec_cart_pst_row' ) ).hide( ); jQuery( document.getElementById( 'ec_cart_pst_row_mobile' ) ).hide( ); } } if( jQuery( document.getElementById( 'ec_cart_gst' ) ).length ){ jQuery( document.getElementById( 'ec_cart_gst' ) ).html( data_arr['gst_total'] ); jQuery( document.getElementById( 'ec_cart_gst_mobile' ) ).html( data_arr['gst_total'] ); jQuery( document.getElementById( 'ec_cart_gst_rate' ) ).html( data_arr['gst_rate'] ); jQuery( document.getElementById( 'ec_cart_gst_rate_mobile' ) ).html( data_arr['gst_rate'] ); if( data_arr['gst_rate'] > 0 ){ jQuery( document.getElementById( 'ec_cart_gst_row' ) ).show( ); jQuery( document.getElementById( 'ec_cart_gst_row_mobile' ) ).show( ); }else{ jQuery( document.getElementById( 'ec_cart_gst_row' ) ).hide( ); jQuery( document.getElementById( 'ec_cart_gst_row_mobile' ) ).hide( ); } } if( jQuery( document.getElementById( 'ec_cart_shipping' ) ).length ){ jQuery( document.getElementById( 'ec_cart_shipping' ) ).html( data_arr['shipping_total'] ); jQuery( document.getElementById( 'ec_cart_shipping_mobile' ) ).html( data_arr['shipping_total'] ); } if ( jQuery( document.getElementById( 'ec_cart_subscription_shipping_methods' ) ).length ) { jQuery( document.getElementById( 'ec_cart_subscription_shipping_methods' ) ).html( data_arr['shipping_methods'] ); } jQuery( document.getElementById( 'ec_cart_total' ) ).html( data_arr['grand_total'] ); jQuery( document.getElementById( 'ec_cart_total_mobile' ) ).html( data_arr['grand_total'] ); if( Number( data_arr['has_tax'] ) == 1 ){ jQuery( '#ec_cart_tax_row' ).show( ); jQuery( '#ec_cart_tax_row_mobile' ).show( ); }else{ jQuery( '#ec_cart_tax_row' ).hide( ); jQuery( '#ec_cart_tax_row_mobile' ).hide( ); } if( Number( data_arr['has_vat'] ) == 1 ){ jQuery( '#ec_cart_vat_row' ).show( ); jQuery( '#ec_cart_vat_row_mobile' ).show( ); }else{ jQuery( '#ec_cart_vat_row' ).hide( ); jQuery( '#ec_cart_vat_row_mobile' ).hide( ); } } function ec_apply_subscription_coupon( product_id, manufacturer_id, nonce, is_mobile = false ){ jQuery( document.getElementById( 'ec_apply_coupon' ) ).hide( ); jQuery( document.getElementById( 'ec_applying_coupon' ) ).show( ); jQuery( document.getElementById( 'ec_apply_coupon_mobile' ) ).hide( ); jQuery( document.getElementById( 'ec_applying_coupon_mobile' ) ).show( ); var coupon_code = ( is_mobile ) ? jQuery( document.getElementById( 'ec_coupon_code_mobile' ) ).val() : jQuery( document.getElementById( 'ec_coupon_code' ) ).val(); jQuery( document.getElementById( 'ec_coupon_code_mobile' ) ).val( coupon_code ); jQuery( document.getElementById( 'ec_coupon_code' ) ).val( coupon_code); var data = { action: 'ec_ajax_redeem_subscription_coupon_code', product_id: product_id, manufacturer_id: manufacturer_id, couponcode: coupon_code, nonce: nonce }; jQuery.ajax( { url: wpeasycart_ajax_object.ajax_url, type: 'post', data: data, success: function( data ){ jQuery( document.getElementById( 'ec_apply_coupon' ) ).show( ); jQuery( document.getElementById( 'ec_applying_coupon' ) ).hide( ); jQuery( document.getElementById( 'ec_apply_coupon_mobile' ) ).show( ); jQuery( document.getElementById( 'ec_applying_coupon_mobile' ) ).hide( ); var data_arr = JSON.parse( data ); if( data_arr['coupon_status'] == "valid" ){ jQuery( document.getElementById( 'ec_coupon_error' ) ).hide( ); jQuery( document.getElementById( 'ec_coupon_success' ) ).html( data_arr['coupon_message'] ).show( ); jQuery( document.getElementById( 'ec_coupon_error_mobile' ) ).hide( ); jQuery( document.getElementById( 'ec_coupon_success_mobile' ) ).html( data_arr['coupon_message'] ).show( ); }else{ jQuery( document.getElementById( 'ec_coupon_success' ) ).hide( ); jQuery( document.getElementById( 'ec_coupon_error' ) ).html( data_arr['coupon_message'] ).show( ); jQuery( document.getElementById( 'ec_coupon_success_mobile' ) ).hide( ); jQuery( document.getElementById( 'ec_coupon_error_mobile' ) ).html( data_arr['coupon_message'] ).show( ); } wpeasycart_subscription_cart_update_totals( data_arr ); } } ); } function ec_apply_gift_card( nonce, is_mobile = false ){ jQuery( document.getElementById( 'ec_apply_gift_card' ) ).hide( ); if ( jQuery( '#ec_applying_gift_card_v2' ).length ) { jQuery( '#ec_applying_gift_card_v2' ).addClass( 'ec_cart_button_working_active' ); jQuery( '#ec_applying_gift_card_v2_mobile' ).addClass( 'ec_cart_button_working_active' ); jQuery( document.getElementById( 'ec_apply_gift_card_mobile' ) ).hide(); } else { jQuery( document.getElementById( 'ec_applying_gift_card' ) ).show( ); } var gift_card = ( is_mobile ) ? jQuery( document.getElementById( 'ec_gift_card_mobile' ) ).val() : jQuery( document.getElementById( 'ec_gift_card' ) ).val(); if ( is_mobile ) { jQuery( document.getElementById( 'ec_gift_card' ) ).val( gift_card ); } else { if ( jQuery( document.getElementById( 'ec_gift_card_mobile' ) ).length ) { jQuery( document.getElementById( 'ec_gift_card_mobile' ) ).val( gift_card ); } } var data = { action: 'ec_ajax_redeem_gift_card', ec_v3_24: 'true', giftcard: gift_card, nonce: nonce }; jQuery.ajax( { url: wpeasycart_ajax_object.ajax_url, type: 'post', data: data, success: function( data ){ jQuery( document.getElementById( 'ec_apply_gift_card' ) ).show( ); if ( jQuery( '#ec_applying_gift_card_v2' ).length ) { jQuery( '#ec_applying_gift_card_v2' ).removeClass( 'ec_cart_button_working_active' ); jQuery( '#ec_applying_gift_card_v2_mobile' ).removeClass( 'ec_cart_button_working_active' ); jQuery( document.getElementById( 'ec_apply_gift_card_mobile' ) ).show( ); } else { jQuery( document.getElementById( 'ec_applying_gift_card' ) ).hide( ); } // Get Response Data var response_obj = JSON.parse( data ); // Update Cart ec_update_cart( response_obj ); // Update Gift Card Info if( response_obj.is_giftcard_valid ){ jQuery( document.getElementById( 'ec_gift_card_error' ) ).hide( ); jQuery( document.getElementById( 'ec_gift_card_success' ) ).html( response_obj.giftcard_message ).show( ); if ( jQuery( '#ec_applying_gift_card_v2' ).length ) { jQuery( document.getElementById( 'ec_gift_card_error_mobile' ) ).hide( ); jQuery( document.getElementById( 'ec_gift_card_success_mobile' ) ).html( response_obj.giftcard_message ).show( ); } }else{ jQuery( document.getElementById( 'ec_gift_card_success' ) ).hide( ); jQuery( document.getElementById( 'ec_gift_card_error' ) ).html( response_obj.giftcard_message ).show( ); if ( jQuery( '#ec_applying_gift_card_v2' ).length ) { jQuery( document.getElementById( 'ec_gift_card_success_mobile' ) ).hide( ); jQuery( document.getElementById( 'ec_gift_card_error_mobile' ) ).html( response_obj.giftcard_message ).show( ); } } } } ); } function ec_estimate_shipping( nonce ){ jQuery( document.getElementById( 'ec_estimate_shipping' ) ).hide( ); jQuery( document.getElementById( 'ec_estimating_shipping' ) ).show( ); var data = { action: 'ec_ajax_estimate_shipping', ec_v3_24: 'true', zipcode: jQuery( document.getElementById( 'ec_estimate_zip' ) ).val( ), country: jQuery( document.getElementById( 'ec_estimate_country' ) ).val( ), nonce: nonce }; jQuery.ajax({ url: wpeasycart_ajax_object.ajax_url, type: 'post', data: data, success: function( data ){ jQuery( document.getElementById( 'ec_estimate_shipping' ) ).show( ); jQuery( document.getElementById( 'ec_estimating_shipping' ) ).hide( ); // Get Response Data var response_obj = JSON.parse( data ); // Update Cart ec_update_cart( response_obj ); // Show the Shipping Row if Hidden jQuery( document.getElementById( 'ec_cart_shipping_row' ) ).show( ); } } ); } function ec_update_cart( response_obj ){ if( response_obj.cart.length == 0 ){ ec_reload_cart( ); }else{ // Update Cart Data for( var i=0; i .ec_cart_price_row_total_v2' ).html( response_obj.cart[i].total_price ); 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 ) ){ jQuery( document.getElementById( 'ec_cartitem_backorder_' + response_obj.cart[i].id ) ).show( ); }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 ) ){ jQuery( document.getElementById( 'ec_cartitem_backorder_' + response_obj.cart[i].id ) ).hide( ); }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 ) ){ jQuery( document.getElementById( 'ec_cartitem_backorder_' + response_obj.cart[i].id ) ).show( ); }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 ) ){ jQuery( document.getElementById( 'ec_cartitem_backorder_' + response_obj.cart[i].id ) ).hide( ); } if ( jQuery( document.getElementById( 'ec_cartitem_shipping_restriction_' + response_obj.cart[i].id ) ).length && '1' == response_obj.cart[i].shipping_restricted ) { jQuery( document.getElementById( 'ec_cartitem_shipping_restriction_' + response_obj.cart[i].id ) ).show( ); } else if ( jQuery( document.getElementById( 'ec_cartitem_shipping_restriction_' + response_obj.cart[i].id ) ).length ) { jQuery( document.getElementById( 'ec_cartitem_shipping_restriction_' + response_obj.cart[i].id ) ).hide( ); } } // Update Cart Totals jQuery( document.getElementById( 'ec_cart_subtotal' ) ).html( response_obj.order_totals.sub_total ); if ( jQuery( '.paylater_message_v2' ).length ) { if ( Number( jQuery( '.paylater_message_v2' ).attr( 'data-min-price' ) ) <= Number( response_obj.order_totals.sub_total_amt ) ) { jQuery( '.paylater_message_v2' ).hide(); } else { jQuery( '.paylater_message_v2' ).show(); } } if ( jQuery( '#wpec-payment-method-messaging-element' ).length ) { ec_cart_stripe_paylater_messaging_v2( Math.round( response_obj.order_totals.sub_total_amt * 100 ) ); if ( Number( jQuery( '.paylater_message_v2' ).attr( 'data-min-price' ) ) <= Number( response_obj.order_totals.sub_total_amt ) ) { jQuery( '#wpec-payment-method-messaging-element' ).show(); } else { jQuery( '#wpec-payment-method-messaging-element' ).hide(); } } if ( jQuery( '.ec_cart_table_subtotal_amount' ).length ) { jQuery( '.ec_cart_table_subtotal_amount' ).html( response_obj.order_totals.sub_total ); } jQuery( document.getElementById( 'ec_cart_tax' ) ).html( response_obj.order_totals.tax_total ); if( response_obj.order_totals.has_tax == '1' ){ jQuery( document.getElementById( 'ec_cart_tax' ) ).parent( ).show( ); }else{ jQuery( document.getElementById( 'ec_cart_tax' ) ).parent( ).hide( ); } jQuery( document.getElementById( 'ec_cart_shipping' ) ).html( response_obj.order_totals.shipping_total ); jQuery( document.getElementById( 'ec_cart_duty' ) ).html( response_obj.order_totals.duty_total ); if( response_obj.order_totals.has_duty == '1' ){ jQuery( document.getElementById( 'ec_cart_duty' ) ).parent( ).show( ); }else{ jQuery( document.getElementById( 'ec_cart_duty' ) ).parent( ).hide( ); } jQuery( document.getElementById( 'ec_cart_vat' ) ).html( response_obj.order_totals.vat_total ); if( response_obj.order_totals.has_vat == '1' ){ jQuery( document.getElementById( 'ec_cart_vat' ) ).parent( ).show( ); }else{ jQuery( document.getElementById( 'ec_cart_vat' ) ).parent( ).hide( ); } if( jQuery( document.getElementById( 'ec_cart_vat_rate' ) ).length ){ jQuery( document.getElementById( 'ec_cart_vat_rate' ) ).html( response_obj.order_totals.vat_rate_formatted ); } jQuery( document.getElementById( 'ec_cart_gst' ) ).html( response_obj.order_totals.gst_total ); if( response_obj.order_totals.has_gst == '1' ){ jQuery( document.getElementById( 'ec_cart_gst' ) ).parent( ).show( ); }else{ jQuery( document.getElementById( 'ec_cart_gst' ) ).parent( ).hide( ); } jQuery( document.getElementById( 'ec_cart_hst' ) ).html( response_obj.order_totals.hst_total ); if( response_obj.order_totals.has_hst == '1' ){ jQuery( document.getElementById( 'ec_cart_hst' ) ).parent( ).show( ); }else{ jQuery( document.getElementById( 'ec_cart_hst' ) ).parent( ).hide( ); } jQuery( document.getElementById( 'ec_cart_pst' ) ).html( response_obj.order_totals.pst_total ); if( response_obj.order_totals.has_pst == '1' ){ jQuery( document.getElementById( 'ec_cart_pst' ) ).parent( ).show( ); }else{ jQuery( document.getElementById( 'ec_cart_pst' ) ).parent( ).hide( ); } if( jQuery( document.getElementById( 'ec_cart_tip' ) ).length ){ jQuery( document.getElementById( 'ec_cart_tip' ) ).html( response_obj.order_totals.tip_total ); } if ( response_obj.order_totals.fees ) { jQuery( '.ec_cart_price_row_fee' ).remove(); var fee_html = ''; for ( var j=0; j < response_obj.order_totals.fees.length; j++ ) { fee_html += '
' + response_obj.order_totals.fees[j].fee_label + '
' + response_obj.order_totals.fees[j].fee_total + '
'; } if ( '' != fee_html ) { jQuery( fee_html ).insertBefore( '.ec_cart_price_row.ec_order_total' ); } } jQuery( document.getElementById( 'ec_cart_discount' ) ).html( response_obj.order_totals.discount_total ); jQuery( '.ec_cart_promotions_list.ec_cart_promotions_discount' ).remove(); if ( '' != response_obj.order_totals.discount_message ) { jQuery( '.ec_cart_price_row_discount_total > .ec_cart_price_row_label' ).append( response_obj.order_totals.discount_message ); } jQuery( '.ec_cart_promotions_list.ec_cart_shipping_discount' ).remove(); if ( '' != response_obj.order_totals.shipping_discount_message ) { jQuery( '.ec_cart_price_row_shipping_total > .ec_cart_price_row_label' ).append( response_obj.order_totals.shipping_discount_message ); } jQuery( document.getElementById( 'ec_cart_total' ) ).html( response_obj.order_totals.grand_total ); jQuery( ".ec_cart_items_total" ).html( response_obj.items_total ); jQuery( ".ec_cart_price_total" ).html( response_obj.order_totals.grand_total ); // Hide/Show Discount if( response_obj.has_discount == '1' ){ jQuery( '.ec_no_discount' ).show( ); jQuery( '.ec_has_discount' ).show( ); }else{ jQuery( '.ec_no_discount' ).hide( ); jQuery( '.ec_has_discount' ).hide( ); } // Hide/Show Backorder if( response_obj.has_backorder ){ jQuery( document.getElementById( 'ec_cart_backorder_message' ) ).show( ); }else{ jQuery( document.getElementById( 'ec_cart_backorder_message' ) ).hide( ); } // Hide/Show Minimum if( jQuery( '.ec_minimum_purchase_box' ).length ){ if( Number( response_obj.order_totals.sub_total_amt ) < Number( jQuery( '.ec_minimum_purchase_box' ).attr( 'data-min-cart' ) ) ){ jQuery( '.ec_minimum_purchase_box' ).show( ); if( jQuery( document.getElementById( 'sq-walletbox' ) ).length ){ jQuery( document.getElementById( 'sq-walletbox' ) ).hide( ); } }else{ jQuery( '.ec_minimum_purchase_box' ).hide( ); if( jQuery( document.getElementById( 'sq-walletbox' ) ).length ){ jQuery( document.getElementById( 'sq-walletbox' ) ).show( ); } } } // Stripe Update Wallet if( jQuery( document.getElementById( 'ec-stripe-wallet-button' ) ).length && ! jQuery( document.getElementById( 'ec_cart_onepage_cart' ) ).length ){ jQuery( document.getElementById( 'ec-stripe-wallet-button' ) ).replaceWith( response_obj.stripe_wallet ); } // PayPal Express Update if( response_obj.paypal_express_button ){ jQuery( document.getElementById( 'paypal-button-container' ) ).find( '.paypal-button' ).remove( ); jQuery( document.getElementById( 'paypal-button-container' ) ).append( response_obj.paypal_express_button ); } } } function ec_reload_cart( ){ location.reload( ); } function ec_open_login_click( ){ jQuery( document.getElementById( 'ec_alt_login' ) ).slideToggle(300); return false; } function ec_update_shipping_view( ){ if( jQuery( document.getElementById( 'ec_shipping_selector' ) ).is( ':checked' ) ){ jQuery( document.getElementById( 'ec_shipping_form' ) ).show( ); }else{ jQuery( document.getElementById( 'ec_shipping_form' ) ).hide( ); } } function ec_cart_toggle_login( ){ if( jQuery( document.getElementById( 'ec_login_selector' ) ).is( ':checked' ) ){ jQuery( document.getElementById( 'ec_user_login_form' ) ).show( ); }else{ jQuery( document.getElementById( 'ec_user_login_form' ) ).hide( ); } } function ec_cart_toggle_login_v2() { if ( jQuery( document.getElementById( 'ec_user_login_form' ) ).is( ':visible' ) ) { jQuery( document.getElementById( 'ec_user_login_form' ) ).hide( ); jQuery( document.getElementById( 'ec_user_contact_form' ) ).show( ); jQuery( document.getElementById( 'ec_user_login_link' ) ).show( ); jQuery( document.getElementById( 'ec_user_login_cancel_link' ) ).hide( ); jQuery( document.getElementById( 'ec_login_selector' ) ).prop( 'checked', false ); if ( jQuery( document.getElementById( 'ec_user_create_form' ) ).length ) { jQuery( document.getElementById( 'ec_user_create_form' ) ).show(); } jQuery( '#ec_cart_onepage_info > div.ec_cart_input_row, #ec_cart_onepage_info > .ec_cart_header' ).show( ); jQuery( document.getElementById( 'ec_cart_onepage_shipping' ) ).show( ); jQuery( document.getElementById( 'ec_cart_onepage_payment' ) ).show( ); } else { jQuery( document.getElementById( 'ec_user_login_form' ) ).show( ); jQuery( document.getElementById( 'ec_user_contact_form' ) ).hide( ); jQuery( document.getElementById( 'ec_user_login_link' ) ).hide( ); jQuery( document.getElementById( 'ec_user_login_cancel_link' ) ).show( ); jQuery( document.getElementById( 'ec_login_selector' ) ).prop( 'checked', true ); if ( jQuery( document.getElementById( 'ec_user_create_form' ) ).length ) { jQuery( document.getElementById( 'ec_user_create_form' ) ).hide(); } jQuery( '#ec_cart_onepage_info > div.ec_cart_input_row, #ec_cart_onepage_info > .ec_cart_header' ).hide( ); jQuery( '#ec_cart_contact_header' ).show( ); jQuery( document.getElementById( 'ec_cart_onepage_shipping' ) ).hide( ); jQuery( document.getElementById( 'ec_cart_onepage_payment' ) ).hide( ); } return false; } function ec_cart_validate_login_v2( nonce ) { var recaptcha_complete = true; var recaptcha_response = ''; if ( document.getElementById( 'ec_account_login_recaptcha' ) ) { recaptcha_response = jQuery( document.getElementById( 'ec_grecaptcha_response_login' ) ).val(); if ( ! recaptcha_response.length ) { jQuery( '#ec_account_login_recaptcha > div' ).css( 'border', '1px solid red' ); recaptcha_complete = false; } else { jQuery( '#ec_account_login_recaptcha > div' ).css( 'border', 'none' ); } } if ( ec_validate_cart_login() && recaptcha_complete ) { jQuery( document.getElementById( 'ec_user_login_form' ) ).append( '
' ); var data = { action: 'ec_ajax_cart_login_v2', ec_cart_login_email: jQuery( document.getElementById( 'ec_cart_login_email' ) ).val(), ec_cart_login_password: jQuery( document.getElementById( 'ec_cart_login_password' ) ).val(), ec_grecaptcha_response_login: recaptcha_response, wpeasycart_nonce: nonce }; jQuery.ajax( { url: wpeasycart_ajax_object.ajax_url, type: 'post', data: data, success: function( data ) { var response_obj = JSON.parse( data ); jQuery( document.getElementById( 'ec_cart_login_invalid_error' ) ).hide(); jQuery( document.getElementById( 'ec_cart_not_activated_error' ) ).hide(); if ( response_obj.error ) { jQuery( document.getElementById( 'ec_cart_login_form_loader' ) ).remove(); if ( 'not_activated' == response_obj ) { jQuery( document.getElementById( 'ec_cart_not_activated_error' ) ).show(); } else { jQuery( document.getElementById( 'ec_cart_login_invalid_error' ) ).show(); } } else { window.location.href = response_obj.url; } } } ); return false; } else { return false; } } function ec_cart_stripe_paylater_messaging_v2( sub_total ) { if ( jQuery( '#wpec-payment-method-messaging-element' ).length ) { const appearance = { theme: jQuery( '#wpec-payment-method-messaging-element' ).attr( 'data-theme' ), }; const elements = stripe.elements( appearance ); const options = { amount: sub_total, currency: jQuery( '#wpec-payment-method-messaging-element' ).attr( 'data-currency' ), paymentMethodTypes: jQuery( '#wpec-payment-method-messaging-element' ).attr( 'data-types' ).split( ',' ), countryCode: jQuery( '#wpec-payment-method-messaging-element' ).attr( 'data-country' ), }; const PaymentMessageElement = elements.create( 'paymentMethodMessaging', options ); PaymentMessageElement.mount( '#wpec-payment-method-messaging-element' ); } } function ec_cart_logout_v2() { jQuery( document.getElementById( 'ec_cart_logged_in_section' ) ).append( '
' ); } function ec_cart_toggle_address_edit( ) { if ( jQuery( document.getElementById( 'ec_cart_billing_form' ) ).is( ':visible' ) ) { jQuery( document.getElementById( 'ec_cart_billing_form' ) ).hide(); jQuery( document.getElementById( 'ec_cart_billing_locked' ) ).show(); if ( jQuery( document.getElementById( 'ec_cart_shipping_locked' ) ).length ) { jQuery( document.getElementById( 'ec_cart_shipping_locked' ) ).show(); } jQuery( document.getElementById( 'ec_cart_subscription_end_form' ) ).show(); } else { jQuery( document.getElementById( 'ec_cart_billing_form' ) ).show(); jQuery( document.getElementById( 'ec_cart_billing_locked' ) ).hide(); if ( jQuery( document.getElementById( 'ec_cart_shipping_locked' ) ).length ) { jQuery( document.getElementById( 'ec_cart_shipping_locked' ) ).hide(); } jQuery( document.getElementById( 'ec_cart_subscription_end_form' ) ).hide(); } } function wp_easycart_update_contact_email_v2() { var data = { action: 'ec_ajax_update_contact_email', ec_create_account: ( ( jQuery( document.getElementById( 'ec_user_create_form' ) ).length ) ? 1 : 0 ), ec_contact_email: jQuery( document.getElementById( 'ec_contact_email' ) ).val(), wpeasycart_checkout_nonce: jQuery( document.getElementById( 'wpeasycart_checkout_nonce' ) ).val() }; jQuery.ajax( { url: wpeasycart_ajax_object.ajax_url, type: 'post', data: data, success: function( data ) { var response_obj = JSON.parse( data ); if ( response_obj.error && 'user_create_error' == response_obj.error && jQuery( document.getElementById( 'ec_user_create_form' ) ).length ) { jQuery( document.getElementById( 'ec_create_account_email_error' ) ).show(); } else { jQuery( document.getElementById( 'ec_create_account_email_error' ) ).hide(); } }, } ); } function wp_easycart_goto_page_v2( page, nonce, add_state = true ) { if ( 'shipping' == page && jQuery( '#wpeasycart_shipping_page_link' ).hasClass( 'wpeasycart-deactivated-link' ) ) { return false; } if ( 'payment' == page && jQuery( '#wpeasycart_payment_page_link' ).hasClass( 'wpeasycart-deactivated-link' ) ) { return false; } var valid_pages = [ 'cart', 'information', 'shipping', 'payment' ]; if ( ! valid_pages.includes( page ) ) { page = 'information'; } jQuery( '.ec_cart_left' ).append( '
' ); if ( add_state ) { wp_easycart_goto_push_state( page ); } var data = { action: 'ec_ajax_goto_page_v2', page: page, wpeasycart_checkout_nonce: nonce, }; jQuery.ajax( { url: wpeasycart_ajax_object.ajax_url, type: 'post', data: data, success: function( data ) { var response_obj = JSON.parse( data ); ec_update_cart( response_obj.cart_data ); if ( jQuery( document.getElementById( 'ec_cart_onepage_cart' ) ).length ) { jQuery( document.getElementById( 'ec_cart_goto_page_loader' ) ).remove(); if ( 'cart' == page ) { jQuery( '.ec_cart_left' ).addClass( 'ec_cart_full' ); jQuery( '.ec_cart_right' ).hide(); if ( jQuery( document.getElementById( 'ec_cart_onepage_cart' ) ).length ) { jQuery( document.getElementById( 'ec_cart_onepage_cart' ) ).show(); jQuery( document.getElementById( 'ec_cart_onepage_cart' ) ).html( response_obj.html_content ); } if ( jQuery( document.getElementById( 'ec_cart_onepage_info' ) ).length ) { jQuery( document.getElementById( 'ec_cart_onepage_info' ) ).hide(); } if ( jQuery( document.getElementById( 'ec_cart_onepage_shipping' ) ).length ) { jQuery( document.getElementById( 'ec_cart_onepage_shipping' ) ).hide(); } if ( jQuery( document.getElementById( 'ec_cart_onepage_payment' ) ).length ) { jQuery( document.getElementById( 'ec_cart_onepage_payment' ) ).hide(); } } else { jQuery( '.ec_cart_left' ).removeClass( 'ec_cart_full' ); jQuery( '.ec_cart_right' ).show(); if ( jQuery( document.getElementById( 'ec_cart_onepage_cart' ) ).length ) { jQuery( document.getElementById( 'ec_cart_onepage_cart' ) ).remove(); } if ( jQuery( document.getElementById( 'ec_cart_onepage_info' ) ).length ) { jQuery( document.getElementById( 'ec_cart_onepage_info' ) ).remove(); } if ( jQuery( document.getElementById( 'ec_cart_onepage_shipping' ) ).length ) { jQuery( document.getElementById( 'ec_cart_onepage_shipping' ) ).remove(); } if ( jQuery( document.getElementById( 'ec_cart_onepage_payment' ) ).length ) { jQuery( document.getElementById( 'ec_cart_onepage_payment' ) ).remove(); } jQuery( document.getElementById( 'wpeasycart_checkout_details_form' ) ).append( response_obj.html_content ); } } else { jQuery( '.ec_cart_left' ).html( response_obj.html_content ); if ( 'cart' == page ) { jQuery( '.ec_cart_left' ).addClass( 'ec_cart_full' ); jQuery( '.ec_cart_right' ).hide(); } else { jQuery( '.ec_cart_left' ).removeClass( 'ec_cart_full' ); jQuery( '.ec_cart_right' ).show(); } if ( '1' == response_obj.shipping_allowed ) { jQuery( '#wpeasycart_shipping_page_link' ).removeClass( 'wpeasycart-deactivated-link' ); } if ( '1' == response_obj.payment_allowed ) { jQuery( '#wpeasycart_payment_page_link' ).removeClass( 'wpeasycart-deactivated-link' ); } } } } ); return false; } function wp_easycart_goto_push_state( page ) { var url = window.location.href; var var_key = 'eccheckout'; var re = new RegExp( "([?&])" + var_key + "=.*?(&|$)", "i"); var separator = url.indexOf( '?' ) !== -1 ? '&' : '?'; if ( url.match( re ) ) { url = url.replace( re, '$1' + var_key + "=" + page + '$2'); } else { url = url + separator + var_key + "=" + page; } window.history.pushState( { eccheckout: page }, document.title, url ); } function wp_easycart_save_order_notes_v2() { var data = { action: 'ec_ajax_update_order_notes', ec_order_notes: jQuery( document.getElementById( 'ec_order_notes' ) ).val(), wpeasycart_checkout_nonce: jQuery( document.getElementById( 'wpeasycart_checkout_nonce' ) ).val() }; jQuery.ajax( { url: wpeasycart_ajax_object.ajax_url, type: 'post', data: data, } ); } function wp_easycart_save_email_other_v2() { var data = { action: 'ec_ajax_update_email_other', ec_email_other: jQuery( document.getElementById( 'ec_email_other' ) ).val(), wpeasycart_checkout_nonce: jQuery( document.getElementById( 'wpeasycart_checkout_nonce' ) ).val() }; jQuery.ajax( { url: wpeasycart_ajax_object.ajax_url, type: 'post', data: data, } ); } function wp_easycart_goto_shipping_v2( should_scroll = false ) { var has_errors = false; var scrolled_top = false; var has_shipping_error = false; if ( jQuery( document.getElementById( 'ec_contact_email' ) ).length && ! ec_validate_email_block( 'ec_contact' ) ) { jQuery( document.getElementById( 'ec_email_order2_error' ) ).show(); has_errors = true; if ( should_scroll && ! scrolled_top ) { jQuery( [ document.documentElement, document.body ] ).animate( { scrollTop: jQuery( document.getElementById( 'ec_cart_contact_header' ) ).offset().top }, 750 ); scrolled_top = true; } } else { jQuery( document.getElementById( 'ec_email_order2_error' ) ).hide(); } if ( jQuery( document.getElementById( 'ec_user_create_form' ) ).length ) { jQuery( document.getElementById( 'ec_user_login_form' ) ).hide( ); jQuery( document.getElementById( 'ec_user_contact_form' ) ).show( ); jQuery( document.getElementById( 'ec_user_login_link' ) ).show( ); jQuery( document.getElementById( 'ec_user_login_cancel_link' ) ).hide( ); jQuery( document.getElementById( 'ec_login_selector' ) ).prop( 'checked', false ); jQuery( document.getElementById( 'ec_user_create_form' ) ).show(); if ( ! ec_validate_create_account( 'ec_contact' ) ) { jQuery( document.getElementById( 'ec_create_account_order_error' ) ).show(); has_errors = true; if ( should_scroll && ! scrolled_top ) { jQuery( [ document.documentElement, document.body ] ).animate( { scrollTop: jQuery( document.getElementById( 'ec_cart_create_account_header' ) ).offset().top }, 750 ); scrolled_top = true; } } else { jQuery( document.getElementById( 'ec_create_account_order_error' ) ).hide(); } } if ( jQuery( document.getElementById( 'ec_shipping_complete' ) ).length ) { if ( '0' == jQuery( document.getElementById( 'ec_shipping_complete' ) ).val() ) { jQuery( '#ec_shipping_order_error' ).show(); has_errors = true; has_shipping_error = true; } else { jQuery( '#ec_shipping_order_error' ).hide(); } } else if ( jQuery( document.getElementById( 'ec_cart_shipping_first_name' ) ).length && ! ec_validate_address_block( 'ec_cart_shipping' ) ) { jQuery( '#ec_shipping_order_error' ).show(); has_errors = true; has_shipping_error = true; } 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' ) ) { jQuery( '#ec_shipping_order_error' ).show(); has_errors = true; has_shipping_error = true; } 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() ) { jQuery( '#ec_shipping_order_error' ).show(); has_errors = true; has_shipping_error = true; } else { jQuery( '#ec_shipping_order_error' ).hide(); } if ( should_scroll && has_shipping_error && ! scrolled_top ) { jQuery( [ document.documentElement, document.body ] ).animate( { scrollTop: jQuery( document.getElementById( 'ec_cart_shipping_header' ) ).offset().top }, 750 ); scrolled_top = true; } if ( has_errors ) { return false; } if( jQuery( document.getElementById( 'ec_cart_onepage_shipping' ) ).length ) { var header_html = jQuery( document.getElementById( 'ec_cart_onepage_shipping' ) ).find( '.ec_cart_header' ); jQuery( document.getElementById( 'ec_cart_onepage_shipping' ) ).html( '
' ).prepend( header_html ); if ( jQuery( document.getElementById( 'ec_cart_onepage_payment' ) ).find( '.ec_cart_locked_panel' ).length ) { var payment_header_html = jQuery( document.getElementById( 'ec_cart_onepage_payment' ) ).find( '.ec_cart_header' ); jQuery( document.getElementById( 'ec_cart_onepage_payment' ) ).html( '
' ).prepend( payment_header_html ); } } else if( jQuery( document.getElementById( 'ec_cart_onepage_payment' ) ).length ) { var header_html = jQuery( document.getElementById( 'ec_cart_onepage_payment' ) ).find( '.ec_cart_header' ); if ( jQuery( document.getElementById( 'ec_cart_onepage_payment' ) ).find( '.ec_cart_locked_panel' ).length ) { jQuery( document.getElementById( 'ec_cart_onepage_payment' ) ).html( '
' ).prepend( header_html ); } } else { jQuery( '.ec_cart_left' ).append( '
' ); } if ( jQuery( document.getElementById( 'ec_shipping_complete' ) ).length || jQuery( document.getElementById( 'ec_cart_shipping_first_name' ) ).length ) { 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(); 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(); if ( jQuery( document.getElementById( 'ec_cart_shipping_state_' + shipping_country ) ).length ) { shipping_state = jQuery( document.getElementById( 'ec_cart_shipping_state_' + shipping_country ) ).val(); } var data = { action: 'ec_ajax_save_checkout_info', ec_cart_is_subscriber: ( jQuery( document.getElementById( 'ec_cart_is_subscriber' ) ).is( ':checked' ) ) ? '1' : '0', ec_shipping_selector: jQuery( document.getElementById( 'ec_shipping_selector' ) ).val(), 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(), 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(), 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(), ec_shipping_state: shipping_state, 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(), ec_shipping_country: shipping_country, 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(), 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(), 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(), 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(), ec_contact_email: jQuery( document.getElementById( 'ec_contact_email' ) ).val(), ec_order_notes: jQuery( document.getElementById( 'ec_order_notes' ) ).val(), wpeasycart_checkout_nonce: jQuery( document.getElementById( 'wpeasycart_checkout_nonce' ) ).val(), }; wp_easycart_goto_push_state( 'shipping' ); } else { 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(); 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(); if ( jQuery( document.getElementById( 'ec_cart_billing_state_' + billing_country ) ).length ) { billing_state = jQuery( document.getElementById( 'ec_cart_billing_state_' + billing_country ) ).val(); } var data = { action: 'ec_ajax_save_checkout_info', ec_cart_is_subscriber: ( jQuery( document.getElementById( 'ec_cart_is_subscriber' ) ).is( ':checked' ) ) ? '1' : '0', 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(), 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(), 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(), ec_billing_state: billing_state, 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(), ec_billing_country: billing_country, 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(), 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(), 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(), 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(), ec_contact_email: jQuery( document.getElementById( 'ec_contact_email' ) ).val(), ec_order_notes: jQuery( document.getElementById( 'ec_order_notes' ) ).val(), wpeasycart_checkout_nonce: jQuery( document.getElementById( 'wpeasycart_checkout_nonce' ) ).val(), }; wp_easycart_goto_push_state( 'payment' ); } if ( jQuery( document.getElementById( 'ec_user_create_form' ) ).length ) { data.ec_create_account = 1; if ( jQuery( document.getElementById( 'ec_contact_first_name' ) ).length ) { data.ec_contact_first_name = jQuery( document.getElementById( 'ec_contact_first_name' ) ).val(); } if ( jQuery( document.getElementById( 'ec_contact_last_name' ) ).length ) { data.ec_contact_last_name = jQuery( document.getElementById( 'ec_contact_last_name' ) ).val(); } data.ec_contact_password = jQuery( document.getElementById( 'ec_contact_password' ) ).val(); } jQuery.ajax( { url: wpeasycart_ajax_object.ajax_url, type: 'post', data: data, success: function( data ) { var response_obj = JSON.parse( data ); jQuery( document.getElementById( 'ec_cart_shipping_loader' ) ).remove(); if ( response_obj.error && 'user_create_error' == response_obj.error ) { jQuery( document.getElementById( 'ec_create_account_email_error' ) ).show(); } else { jQuery( document.getElementById( 'ec_create_account_email_error' ) ).hide(); } ec_update_cart( response_obj.cart_data ); if( jQuery( document.getElementById( 'ec_cart_onepage_payment' ) ).length ) { if ( jQuery( document.getElementById( 'ec_cart_onepage_shipping' ) ).length ) { jQuery( document.getElementById( 'ec_cart_onepage_shipping' ) ).html( response_obj.shipping_content ); if ( jQuery( 'input[name=ec_cart_shipping_method]:checked' ).length ) { if ( jQuery( document.getElementById( 'ec_shipping_method_order_error' ) ).length ) { jQuery( document.getElementById( 'ec_shipping_method_order_error' ) ).hide(); } } } 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 ) { jQuery( document.getElementById( 'ec_cart_onepage_payment' ) ).html( response_obj.payment_content ); } } else { if ( ! response_obj.error ) { jQuery( '.ec_cart_left' ).html( response_obj.html_content ); if ( '1' == response_obj.shipping_allowed ) { jQuery( '#wpeasycart_shipping_page_link' ).removeClass( 'wpeasycart-deactivated-link' ); } if ( '1' == response_obj.payment_allowed ) { jQuery( '#wpeasycart_payment_page_link' ).removeClass( 'wpeasycart-deactivated-link' ); } } } } } ); } function wp_easycart_goto_payment_v2() { jQuery( '.ec_cart_left' ).append( '
' ); var ship_express = 0; var shipping_method = jQuery( '.ec_cart_shipping_method_row > input:checked' ).val(); if ( jQuery( document.getElementById( 'ec_cart_ship_express' ) ).length ) { if ( jQuery( document.getElementById( 'ec_cart_ship_express' ) ).is( ':checked' ) ) { ship_express = 1; } } if ( 'shipexpress' == shipping_method ) { shipping_method = 'standard'; if ( jQuery( document.getElementById( 'ec_cart_shipping_method_free' ) ).length ) { jQuery( document.getElementById( 'ec_cart_shipping_method_free' ) ).prop( 'checked', false ); } jQuery( document.getElementById( 'ec_cart_shipping_method' ) ).prop( 'checked', 'checked' ); } else if( 'free' == shipping_method ) { if ( jQuery( document.getElementById( 'ec_cart_ship_express' ) ).length ) { jQuery( document.getElementById( 'ec_cart_ship_express' ) ).prop( 'checked', false ); } } wp_easycart_goto_push_state( 'payment' ); var data = { action: 'ec_ajax_save_shipping_method', shipping_method: shipping_method, ship_express: ship_express, wpeasycart_checkout_nonce: jQuery( document.getElementById( 'wpeasycart_checkout_nonce' ) ).val(), }; jQuery.ajax( { url: wpeasycart_ajax_object.ajax_url, type: 'post', data: data, success: function( data ) { var response_obj = JSON.parse( data ); jQuery( '.ec_cart_left' ).html( response_obj.html_content ); if ( '1' == response_obj.shipping_allowed ) { jQuery( '#wpeasycart_shipping_page_link' ).removeClass( 'wpeasycart-deactivated-link' ); } if ( '1' == response_obj.payment_allowed ) { jQuery( '#wpeasycart_payment_page_link' ).removeClass( 'wpeasycart-deactivated-link' ); } } } ); } function ec_toggle_create_account( ){ if( jQuery( document.getElementById( 'ec_user_create_form' ) ).is( ':visible' ) ){ jQuery( document.getElementById( 'ec_user_create_form' ) ).hide( ); }else{ jQuery( document.getElementById( 'ec_user_create_form' ) ).show( ); } } function ec_update_payment_display( nonce ) { jQuery( '.ec_cart_payment_table_row ' ).removeClass( 'ec_payment_row_selected' ); var payment_method = "manual_bill"; jQuery( document.getElementById( 'ec_apple_pay_form' ) ).hide( ); jQuery( document.getElementById( 'ec_manual_payment_form' ) ).hide( ); jQuery( document.getElementById( 'ec_amazonpay_form' ) ).hide( ); jQuery( document.getElementById( 'ec_affirm_form' ) ).hide( ); jQuery( document.getElementById( 'ec_third_party_form' ) ).hide( ); jQuery( document.getElementById( 'ec_credit_card_form' ) ).hide( ); jQuery( document.getElementById( 'ec_ideal_form' ) ).hide( ); if( jQuery( document.getElementById( 'ec_payment_apple' ) ).is( ':checked' ) ){ jQuery( '#ec_payment_apple' ).parent().parent().addClass( 'ec_payment_row_selected' ); jQuery( document.getElementById( 'ec_apple_pay_form' ) ).show( ); if( jQuery( document.getElementById( 'ec_terms_row' ) ).length ) jQuery( document.getElementById( 'ec_terms_row' ) ).show( ); if( jQuery( document.getElementById( 'ec_terms_agreement_row' ) ).length ) jQuery( document.getElementById( 'ec_terms_agreement_row' ) ).show( ); if( jQuery( document.getElementById( 'wpeasycart_submit_order_row' ) ).length ) jQuery( document.getElementById( 'wpeasycart_submit_order_row' ) ).show( ); if( jQuery( document.getElementById( 'wpeasycart_submit_paypal_order_row' ) ).length ) jQuery( document.getElementById( 'wpeasycart_submit_paypal_order_row' ) ).hide( ); payment_method = "apple_pay"; }else if( jQuery( document.getElementById( 'ec_payment_manual' ) ).is( ':checked' ) ){ jQuery( '#ec_payment_manual' ).parent().parent().addClass( 'ec_payment_row_selected' ); jQuery( document.getElementById( 'ec_manual_payment_form' ) ).show( ); if( jQuery( document.getElementById( 'ec_terms_row' ) ).length ) jQuery( document.getElementById( 'ec_terms_row' ) ).show( ); if( jQuery( document.getElementById( 'ec_terms_agreement_row' ) ).length ) jQuery( document.getElementById( 'ec_terms_agreement_row' ) ).show( ); if( jQuery( document.getElementById( 'wpeasycart_submit_order_row' ) ).length ) jQuery( document.getElementById( 'wpeasycart_submit_order_row' ) ).show( ); if( jQuery( document.getElementById( 'wpeasycart_submit_paypal_order_row' ) ).length ) jQuery( document.getElementById( 'wpeasycart_submit_paypal_order_row' ) ).hide( ); payment_method = "manual_bill"; }else if( jQuery( document.getElementById( 'ec_payment_affirm' ) ).is( ':checked' ) ){ jQuery( '#ec_payment_affirm' ).parent().parent().addClass( 'ec_payment_row_selected' ); jQuery( document.getElementById( 'ec_affirm_form' ) ).show( ); if( jQuery( document.getElementById( 'ec_terms_row' ) ).length ) jQuery( document.getElementById( 'ec_terms_row' ) ).show( ); if( jQuery( document.getElementById( 'ec_terms_agreement_row' ) ).length ) jQuery( document.getElementById( 'ec_terms_agreement_row' ) ).show( ); if( jQuery( document.getElementById( 'wpeasycart_submit_order_row' ) ).length ) jQuery( document.getElementById( 'wpeasycart_submit_order_row' ) ).show( ); if( jQuery( document.getElementById( 'wpeasycart_submit_paypal_order_row' ) ).length ) jQuery( document.getElementById( 'wpeasycart_submit_paypal_order_row' ) ).hide( ); payment_method = "affirm"; }else if( jQuery( document.getElementById( 'ec_payment_third_party' ) ).is( ':checked' ) ){ jQuery( '#ec_payment_third_party' ).parent().parent().addClass( 'ec_payment_row_selected' ); jQuery( document.getElementById( 'ec_third_party_form' ) ).show( ); if( jQuery( document.getElementById( 'wpeasycart_submit_paypal_order_row' ) ).length ){ jQuery( document.getElementById( 'wpeasycart_submit_paypal_order_row' ) ).show( ); if( jQuery( document.getElementById( 'ec_terms_row' ) ).length ) jQuery( document.getElementById( 'ec_terms_row' ) ).show( ); if( jQuery( document.getElementById( 'ec_submit_order_error' ) ).length ) jQuery( document.getElementById( 'ec_submit_order_error' ) ).hide( ); if( jQuery( document.getElementById( 'ec_terms_agreement_row' ) ).length ) jQuery( document.getElementById( 'ec_terms_agreement_row' ) ).show( ); if( jQuery( document.getElementById( 'wpeasycart_submit_order_row' ) ).length ) jQuery( document.getElementById( 'wpeasycart_submit_order_row' ) ).hide( ); } payment_method = "third_party"; }else if( jQuery( document.getElementById( 'ec_payment_credit_card' ) ).is( ':checked' ) ){ jQuery( '#ec_payment_credit_card' ).parent().parent().addClass( 'ec_payment_row_selected' ); jQuery( document.getElementById( 'ec_credit_card_form' ) ).show( ); if( jQuery( document.getElementById( 'ec_terms_row' ) ).length ) jQuery( document.getElementById( 'ec_terms_row' ) ).show( ); if( jQuery( document.getElementById( 'ec_terms_agreement_row' ) ).length ) jQuery( document.getElementById( 'ec_terms_agreement_row' ) ).show( ); if( jQuery( document.getElementById( 'wpeasycart_submit_order_row' ) ).length ) jQuery( document.getElementById( 'wpeasycart_submit_order_row' ) ).show( ); if( jQuery( document.getElementById( 'wpeasycart_submit_paypal_order_row' ) ).length ) jQuery( document.getElementById( 'wpeasycart_submit_paypal_order_row' ) ).hide( ); payment_method = "credit_card"; }else if( jQuery( document.getElementById( 'ec_payment_ideal' ) ).is( ':checked' ) ){ jQuery( '#ec_payment_ideal' ).parent().parent().addClass( 'ec_payment_row_selected' ); jQuery( document.getElementById( 'ec_ideal_form' ) ).show( ); if( jQuery( document.getElementById( 'ec_terms_row' ) ).length ) jQuery( document.getElementById( 'ec_terms_row' ) ).show( ); if( jQuery( document.getElementById( 'ec_terms_agreement_row' ) ).length ) jQuery( document.getElementById( 'ec_terms_agreement_row' ) ).show( ); if( jQuery( document.getElementById( 'wpeasycart_submit_order_row' ) ).length ) jQuery( document.getElementById( 'wpeasycart_submit_order_row' ) ).show( ); if( jQuery( document.getElementById( 'wpeasycart_submit_paypal_order_row' ) ).length ) jQuery( document.getElementById( 'wpeasycart_submit_paypal_order_row' ) ).hide( ); payment_method = "ideal"; }else if( jQuery( document.getElementById( 'ec_amazonpay' ) ).is( ':checked' ) ){ jQuery( '#ec_amazonpay' ).parent().parent().addClass( 'ec_payment_row_selected' ); jQuery( document.getElementById( 'ec_amazonpay_form' ) ).show( ); if( jQuery( document.getElementById( 'ec_terms_row' ) ).length ) jQuery( document.getElementById( 'ec_terms_row' ) ).show( ); if( jQuery( document.getElementById( 'ec_terms_agreement_row' ) ).length ) jQuery( document.getElementById( 'ec_terms_agreement_row' ) ).show( ); if( jQuery( document.getElementById( 'wpeasycart_submit_order_row' ) ).length ) jQuery( document.getElementById( 'wpeasycart_submit_order_row' ) ).show( ); if( jQuery( document.getElementById( 'wpeasycart_submit_paypal_order_row' ) ).length ) jQuery( document.getElementById( 'wpeasycart_submit_paypal_order_row' ) ).hide( ); payment_method = "amazonpay"; } var data = { action: 'ec_ajax_update_payment_method', payment_method: payment_method, nonce: nonce }; jQuery.ajax( { url: wpeasycart_ajax_object.ajax_url, type: 'post', data: data, success: function( response ){ var response_obj = JSON.parse( response ); ec_update_cart( response_obj.cart_data ); } } ); } function ec_update_billing_address_display( billing_address_type, nonce ) { jQuery( '.ec_cart_billing_table_row' ).removeClass( 'ec_billing_row_selected' ); jQuery( '.ec_cart_billing_table_column > input[value="' + billing_address_type + '"]' ).parent().parent().addClass( 'ec_billing_row_selected' ); if ( '0' == billing_address_type ) { jQuery( '.ec_cart_billing_table_address' ).hide(); if ( jQuery( document.getElementById( 'ec_shipping_selector' ) ).length ) { jQuery( document.getElementById( 'ec_shipping_selector' ) ).val( '0' ); } jQuery( document.getElementById( 'ec_billing_order_error' ) ).hide(); } else { jQuery( '.ec_cart_billing_table_address' ).show(); if ( jQuery( document.getElementById( 'ec_shipping_selector' ) ).length ) { jQuery( document.getElementById( 'ec_shipping_selector' ) ).val( '1' ); } } 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() ); var billing_state = ''; if ( jQuery( document.getElementById( 'ec_billing_state' ) ).length ) { billing_state = jQuery( document.getElementById( 'ec_billing_state' ) ).val(); } else if ( jQuery( document.getElementById( 'ec_cart_billing_state_' + billing_country ) ).length ) { billing_state = jQuery( document.getElementById( 'ec_cart_billing_state_' + billing_country ) ).val(); } else { billing_state = jQuery( document.getElementById( 'ec_cart_billing_state' ) ).val() } var data = { action: 'ec_ajax_update_billing_address_type', billing_address_type: billing_address_type, 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() ), 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() ), 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() ), ec_billing_state: billing_state, 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() ), ec_billing_country: billing_country, 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() ), 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() ), 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() ), 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() ), nonce: nonce }; jQuery.ajax({ url: wpeasycart_ajax_object.ajax_url, type: 'post', data: data, } ); } function ec_show_cc_type( type ){ if( jQuery( document.getElementById( 'ec_card_visa' ) ) ){ if( type == "visa" || type == "all" ){ jQuery( document.getElementById( 'ec_card_visa' ) ).show( ); jQuery( document.getElementById( 'ec_card_visa_inactive' ) ).hide( ); }else{ jQuery( document.getElementById( 'ec_card_visa' ) ).hide( ); jQuery( document.getElementById( 'ec_card_visa_inactive' ) ).show( ); } } if( jQuery( document.getElementById( 'ec_card_discover' ) ) ){ if( type == "discover" || type == "all" ){ jQuery( document.getElementById( 'ec_card_discover' ) ).show( ); jQuery( document.getElementById( 'ec_card_discover_inactive' ) ).hide( ); }else{ jQuery( document.getElementById( 'ec_card_discover' ) ).hide( ); jQuery( document.getElementById( 'ec_card_discover_inactive' ) ).show( ); } } if( jQuery( document.getElementById( 'ec_card_mastercard' ) ) ){ if( type == "mastercard" || type == "all" ){ jQuery( document.getElementById( 'ec_card_mastercard' ) ).show( ); jQuery( document.getElementById( 'ec_card_mastercard_inactive' ) ).hide( ); }else{ jQuery( document.getElementById( 'ec_card_mastercard' ) ).hide( ); jQuery( document.getElementById( 'ec_card_mastercard_inactive' ) ).show( ); } } if( jQuery( document.getElementById( 'ec_card_amex' ) ) ){ if( type == "amex" || type == "all" ){ jQuery( document.getElementById( 'ec_card_amex' ) ).show( ); jQuery( document.getElementById( 'ec_card_amex_inactive' ) ).hide( ); }else{ jQuery( document.getElementById( 'ec_card_amex' ) ).hide( ); jQuery( document.getElementById( 'ec_card_amex_inactive' ) ).show( ); } } if( jQuery( document.getElementById( 'ec_card_jcb' ) ) ){ if( type == "jcb" || type == "all" ){ jQuery( document.getElementById( 'ec_card_jcb' ) ).show( ); jQuery( document.getElementById( 'ec_card_jcb_inactive' ) ).hide( ); }else{ jQuery( document.getElementById( 'ec_card_jcb' ) ).hide( ); jQuery( document.getElementById( 'ec_card_jcb_inactive' ) ).show( ); } } if( jQuery( document.getElementById( 'ec_card_diners' ) ) ){ if( type == "diners" || type == "all" ){ jQuery( document.getElementById( 'ec_card_diners' ) ).show( ); jQuery( document.getElementById( 'ec_card_diners_inactive' ) ).hide( ); }else{ jQuery( document.getElementById( 'ec_card_diners' ) ).hide( ); jQuery( document.getElementById( 'ec_card_diners_inactive' ) ).show( ); } } if( jQuery( document.getElementById( 'ec_card_laser' ) ) ){ if( type == "laser" || type == "all" ){ jQuery( document.getElementById( 'ec_card_laser' ) ).show( ); jQuery( document.getElementById( 'ec_card_laser_inactive' ) ).hide( ); }else{ jQuery( document.getElementById( 'ec_card_laser' ) ).hide( ); jQuery( document.getElementById( 'ec_card_laser_inactive' ) ).show( ); } } if( jQuery( document.getElementById( 'ec_card_maestro' ) ) ){ if( type == "maestro" || type == "all" ){ jQuery( document.getElementById( 'ec_card_maestro' ) ).show( ); jQuery( document.getElementById( 'ec_card_maestro_inactive' ) ).hide( ); }else{ jQuery( document.getElementById( 'ec_card_maestro' ) ).hide( ); jQuery( document.getElementById( 'ec_card_maestro_inactive' ) ).show( ); } } } function wpeasycart_bluecheck_verify( ){ try { BlueCheckService.showModal(); return false; } catch(e) { console.error('[BlueCheckService::customValidation]', e); BlueCheckService.BcWebLogger('Error: ' + (e.message || e)); return false; } } function ec_validate_cart_details( ){ var login_complete = true; var billing_complete = ec_validate_address_block( 'ec_cart_billing' ); var shipping_complete = true; var email_complete = true; var create_account_complete = true; var terms_complete = true; var recaptcha_complete = true; var bluecheck_complete = true; if( jQuery( document.getElementById( 'ec_login_selector' ) ).is( ':checked' ) ) login_complete = ec_validate_cart_login( ); if( jQuery( document.getElementById( 'ec_shipping_selector' ) ).is( ':checked' ) ) shipping_complete = ec_validate_address_block( 'ec_cart_shipping' ); if( jQuery( document.getElementById( 'ec_contact_email' ) ).length ) email_complete = ec_validate_email_block( 'ec_contact' ); 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" ) ) { create_account_complete = ec_validate_create_account( 'ec_contact' ); terms_complete = ec_validate_terms_section(); } if( document.getElementById( 'ec_account_register_recaptcha' ) ){ var recaptcha_response = jQuery( document.getElementById( 'ec_grecaptcha_response_register' ) ).val( ); if( !recaptcha_response.length ){ jQuery( '#ec_account_register_recaptcha > div' ).css( 'border', '1px solid red' ); recaptcha_complete = false; }else{ jQuery( '#ec_account_register_recaptcha > div' ).css( 'border', 'none' ); } } if( document.getElementById( 'bcvTrigger' ) ){ bluecheck_complete = wpeasycart_bluecheck_verify( ); if( !bluecheck_complete ) return false; } if( login_complete && billing_complete && shipping_complete && email_complete && create_account_complete && terms_complete && recaptcha_complete ){ ec_hide_error( 'ec_checkout' ); ec_hide_error( 'ec_checkout2' ); jQuery( '.ec_checkout_details_submit' ).parent().addClass( 'wp-easycart-running' ); return true; }else{ ec_show_error( 'ec_checkout' ); ec_show_error( 'ec_checkout2' ); return false; } } function ec_validate_paypal_express_submit_order( ){ var terms_complete = ec_validate_terms( ); if( terms_complete ){ jQuery( document.getElementById( 'ec_cart_submit_order' ) ).hide( ); jQuery( document.getElementById( 'ec_cart_submit_order_working' ) ).show( ); ec_hide_error( 'ec_submit_order' ); return true; }else{ jQuery( document.getElementById( 'ec_cart_submit_order' ) ).show( ); jQuery( document.getElementById( 'ec_cart_submit_order_working' ) ).hide( ); ec_show_error( 'ec_submit_order' ); return false; } } function ec_validate_submit_order( ){ var email_complete = true; var create_account_complete = true; var shipping_info_complete = true; var shipping_method_complete = true; var billing_info_complete = true; var pickup_info_complete = true; var scrolled_top = false; if ( jQuery( document.getElementById( 'ec_user_create_form' ) ).length ) { wp_easycart_update_contact_email_v2(); } if ( jQuery( document.getElementById( 'ec_contact_email_complete' ) ).length ) { if ( '0' == jQuery( document.getElementById( 'ec_contact_email_complete' ) ).val() ) { email_complete = false; if ( ! scrolled_top ) { jQuery( [ document.documentElement, document.body ] ).animate( { scrollTop: jQuery( document.getElementById( 'ec_cart_onepage_info' ) ).offset().top }, 750 ); scrolled_top = true; } } } else if ( jQuery( document.getElementById( 'ec_contact_email' ) ).length ) { 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' ) ) ) { email_complete = false; if ( ! scrolled_top ) { jQuery( [ document.documentElement, document.body ] ).animate( { scrollTop: jQuery( document.getElementById( 'ec_cart_contact_header' ) ).offset().top }, 750 ); scrolled_top = true; } } } if ( jQuery( document.getElementById( 'ec_user_create_form' ) ).length ) { jQuery( document.getElementById( 'ec_user_login_form' ) ).hide( ); jQuery( document.getElementById( 'ec_user_contact_form' ) ).show( ); jQuery( document.getElementById( 'ec_user_login_link' ) ).show( ); jQuery( document.getElementById( 'ec_user_login_cancel_link' ) ).hide( ); jQuery( document.getElementById( 'ec_login_selector' ) ).prop( 'checked', false ); jQuery( document.getElementById( 'ec_user_create_form' ) ).show(); if ( ! ec_validate_create_account( 'ec_contact' ) ) { jQuery( document.getElementById( 'ec_create_account_order_error' ) ).show(); create_account_complete = false; if ( ! scrolled_top ) { jQuery( [ document.documentElement, document.body ] ).animate( { scrollTop: jQuery( document.getElementById( 'ec_cart_create_account_header' ) ).offset().top }, 750 ); scrolled_top = true; } } else { jQuery( document.getElementById( 'ec_create_account_order_error' ) ).hide(); } } if ( jQuery( document.getElementById( 'ec_cart_onepage_info' ) ).length ) { if ( '0' == jQuery( document.getElementById( 'ec_shipping_complete' ) ).val() ) { shipping_info_complete = false; if ( ! scrolled_top ) { jQuery( [ document.documentElement, document.body ] ).animate( { scrollTop: jQuery( document.getElementById( 'ec_cart_onepage_info' ) ).offset().top }, 750 ); scrolled_top = true; } } else if ( jQuery( document.getElementById( 'ec_cart_shipping_country' ) ).length ) { if ( ! ec_validate_address_block( 'ec_cart_shipping' ) ) { shipping_info_complete = false; if ( ! scrolled_top ) { jQuery( [ document.documentElement, document.body ] ).animate( { scrollTop: jQuery( document.getElementById( 'ec_cart_onepage_info' ) ).offset().top }, 750 ); scrolled_top = true; } } } else if ( jQuery( document.getElementById( 'ec_cart_billing_country' ) ).length ) { if ( ! ec_validate_address_block( 'ec_cart_billing' ) ) { billing_info_complete = false; if ( ! scrolled_top ) { jQuery( [ document.documentElement, document.body ] ).animate( { scrollTop: jQuery( document.getElementById( 'ec_cart_onepage_info' ) ).offset().top }, 750 ); scrolled_top = true; } } } } if ( jQuery( document.getElementById( 'ec_cart_onepage_shipping' ) ).length ) { if ( ! jQuery( 'input[name=ec_cart_shipping_method]:checked' ).length ) { shipping_method_complete = false; if ( ! scrolled_top ) { jQuery( [ document.documentElement, document.body ] ).animate( { scrollTop: jQuery( document.getElementById( 'ec_cart_onepage_shipping' ) ).offset().top - 50 }, 750 ); scrolled_top = true; } } } if ( jQuery( document.getElementById( 'billing_address_type_different' ) ).length && jQuery( document.getElementById( 'billing_address_type_different' ) ).is( ':checked' ) ) { if ( jQuery( document.getElementById( 'ec_billing_complete' ) ).length && '0' == jQuery( document.getElementById( 'ec_billing_complete' ) ).val() ) { billing_info_complete = false; } else if ( jQuery( document.getElementById( 'ec_cart_billing_country' ) ).length && ! ec_validate_address_block( 'ec_cart_billing' ) ) { billing_info_complete = false; } } if ( jQuery( '#preorder_pickup_date' ).length ) { if ( ! jQuery( '#preorder_pickup_date' ).datepicker( 'getDate' ) ) { pickup_info_complete = false; jQuery( '#ec_preorder_pickup_error' ).show(); } else if ( '' == jQuery( '#preorder_pickup_time' ).val() ) { pickup_info_complete = false; jQuery( '#ec_preorder_pickup_error' ).show(); } else { jQuery( '#ec_preorder_pickup_error' ).hide(); } } var payment_method_complete = ec_validate_payment_method( ); var terms_complete = ec_validate_terms( ); if ( jQuery( document.getElementById( 'ec_email_order1_error' ) ).length ) { if ( email_complete ) { ec_hide_error( 'ec_email_order1' ); ec_hide_error( 'ec_email_order2' ); } else { ec_show_error( 'ec_email_order1' ); ec_show_error( 'ec_email_order2' ); } } if ( jQuery( document.getElementById( 'ec_shipping_order_error' ) ).length ) { if ( shipping_info_complete ) { ec_hide_error( 'ec_shipping_order' ); } else { ec_show_error( 'ec_shipping_order' ); } } if ( jQuery( document.getElementById( 'ec_shipping_method_order_error' ) ).length ) { if ( shipping_method_complete ) { ec_hide_error( 'ec_shipping_method_order' ); } else { ec_show_error( 'ec_shipping_method_order' ); } } if ( billing_info_complete ) { ec_hide_error( 'ec_billing_order' ); } else { ec_show_error( 'ec_billing_order' ); } if ( payment_method_complete && terms_complete && email_complete && shipping_info_complete && shipping_method_complete && billing_info_complete && pickup_info_complete ) { if( !document.getElementById( 'ec_stripe_card_row' ) && !document.getElementById( 'wpec_braintree_dropin' ) ){ jQuery( document.getElementById( 'ec_cart_submit_order' ) ).hide( ); jQuery( document.getElementById( 'ec_cart_submit_order_working' ) ).show( ); ec_hide_error( 'ec_submit_order' ); if( jQuery( document.getElementById( 'ec_card_number' ) ).length ) jQuery( document.getElementById( 'ec_card_number' ) ).val( jQuery( document.getElementById( 'ec_card_number' ) ).val( ).replace( /\s+/g, '' ) ); } return true; }else{ jQuery( document.getElementById( 'ec_cart_submit_order' ) ).show( ); jQuery( document.getElementById( 'ec_cart_submit_order_working' ) ).hide( ); ec_show_error( 'ec_submit_order' ); return false; } } function ec_validate_submit_invoice( ){ var payment_method_complete = ec_validate_payment_method( ); var terms_complete = ec_validate_terms( ); var billing_complete = ec_validate_address_block( 'ec_cart_billing' ); if( payment_method_complete && terms_complete && billing_complete ){ if( !document.getElementById( 'ec_stripe_card_row' ) && !document.getElementById( 'wpec_braintree_dropin' ) ){ jQuery( document.getElementById( 'ec_cart_submit_order' ) ).hide( ); jQuery( document.getElementById( 'ec_cart_submit_order_working' ) ).show( ); ec_hide_error( 'ec_submit_order' ); if( jQuery( document.getElementById( 'ec_card_number' ) ).length ) jQuery( document.getElementById( 'ec_card_number' ) ).val( jQuery( document.getElementById( 'ec_card_number' ) ).val( ).replace( /\s+/g, '' ) ); } return true; }else{ jQuery( document.getElementById( 'ec_cart_submit_order' ) ).show( ); jQuery( document.getElementById( 'ec_cart_submit_order_working' ) ).hide( ); ec_show_error( 'ec_submit_order' ); return false; } } function ec_validate_submit_subscription( ){ var login_complete = true; var billing_complete = ec_validate_address_block( 'ec_cart_billing' ); var shipping_complete = true; var email_complete = true; var create_account_complete = true; var payment_method_complete = ec_validate_payment_method( ); var terms_complete = ec_validate_terms( ); if ( jQuery( document.getElementById( 'ec_user_login_form' ) ).is( ':visible' ) ) { login_complete = ec_validate_cart_login( ); } if ( jQuery( document.getElementById( 'ec_user_contact_form' ) ).is( ':visible' ) ) { email_complete = ec_validate_email_block( 'ec_contact' ); } if ( jQuery( document.getElementById( 'ec_user_contact_form' ) ).is( ':visible' ) ) { create_account_complete = ec_validate_create_account( 'ec_contact' ); } if ( jQuery( document.getElementById( 'ec_shipping_selector' ) ).is( ':checked' ) ) { shipping_complete = ec_validate_address_block( 'ec_cart_shipping' ); } if( login_complete && billing_complete && shipping_complete && email_complete && create_account_complete && payment_method_complete && terms_complete ){ if( !document.getElementById( 'ec_stripe_card_row' ) && !document.getElementById( 'wpec_braintree_dropin' ) ){ ec_hide_error( 'ec_checkout' ); jQuery( document.getElementById( 'ec_cart_submit_order' ) ).hide( ); jQuery( document.getElementById( 'ec_cart_submit_order_working' ) ).show( ); } return true; }else{ ec_show_error( 'ec_checkout' ); return false; } } function ec_validate_cart_login( ){ var errors = false; var email = jQuery( document.getElementById( 'ec_cart_login_email' ) ).val( ).trim( ); var password = jQuery( document.getElementById( 'ec_cart_login_password' ) ).val( ); if( !ec_validate_email( email ) ){ errors = true; ec_show_error( 'ec_cart_login_email' ); }else{ ec_hide_error( 'ec_cart_login_email' ); } if( !ec_validate_text( password ) ){ errors = true; ec_show_error( 'ec_cart_login_password' ); }else{ ec_hide_error( 'ec_cart_login_password' ); } if( jQuery( document.getElementById( 'ec_account_login_recaptcha' ) ).length ){ var recaptcha_response = jQuery( document.getElementById( 'ec_grecaptcha_response_login' ) ).val( ); if( !recaptcha_response.length ){ jQuery( '#ec_account_login_recaptcha > div' ).css( 'border', '1px solid red' ); errors = true; }else{ jQuery( '#ec_account_login_recaptcha > div' ).css( 'border', 'none' ); } } return ( !errors ); } function ec_validate_address_block( prefix ){ var errors = false; var country = jQuery( document.getElementById( '' + prefix + '_country' ) ).val( ); var first_name = jQuery( document.getElementById( '' + prefix + '_first_name' ) ).val( ); var last_name = jQuery( document.getElementById( '' + prefix + '_last_name' ) ).val( ); var city = jQuery( document.getElementById( '' + prefix + '_city' ) ).val( ); var address = jQuery( document.getElementById( '' + prefix + '_address' ) ).val( ); if( jQuery( document.getElementById( '' + prefix + '_state_' + country ) ) ) var state = jQuery( document.getElementById( '' + prefix + '_state_' + country ) ).val( ); else var state = jQuery( document.getElementById( '' + prefix + '_state' ) ).val( ); var zip = jQuery( document.getElementById( '' + prefix + '_zip' ) ).val( ); var phone = jQuery( document.getElementById( '' + prefix + '_phone' ) ).val( ); var company_name = ( jQuery( document.getElementById( '' + prefix + '_company_name' ) ).length ) ? jQuery( document.getElementById( '' + prefix + '_company_name' ) ).val( ) : ''; if( !ec_validate_select( country ) ){ errors = true; ec_show_error( prefix + '_country' ); }else{ ec_hide_error( prefix + '_country' ); } if( !ec_validate_text( first_name ) ){ errors = true; ec_show_error( prefix + '_first_name' ); }else{ ec_hide_error( prefix + '_first_name' ); } if( !ec_validate_text( last_name ) ){ errors = true; ec_show_error( prefix + '_last_name' ); }else{ ec_hide_error( prefix + '_last_name' ); } if( !ec_validate_text( city ) ){ errors = true; ec_show_error( prefix + '_city' ); }else{ ec_hide_error( prefix + '_city' ); } if( !ec_validate_text( address ) ){ errors = true; ec_show_error( prefix + '_address' ); }else{ ec_hide_error( prefix + '_address' ); } if( jQuery( document.getElementById( '' + prefix + '_state_' + country ) ).length ){ if( !ec_validate_select( state ) ){ errors = true; ec_show_error( prefix + '_state' ); }else{ ec_hide_error( prefix + '_state' ); } }else{ ec_hide_error( prefix + '_state' ); } if( !ec_validate_zip_code( zip, country ) ){ errors = true; ec_show_error( prefix + '_zip' ); }else{ ec_hide_error( prefix + '_zip' ); } if( jQuery( document.getElementById( '' + prefix + '_phone_error' ) ).length ){ if( jQuery( document.getElementById( '' + prefix + '_phone' ) ).length && !ec_validate_text( phone ) ){ errors = true; ec_show_error( prefix + '_phone' ); }else{ ec_hide_error( prefix + '_phone' ); } } if( jQuery( document.getElementById( '' + prefix + '_company_name_error' ) ).length ){ if( jQuery( document.getElementById( '' + prefix + '_company_name' ) ).length && !ec_validate_text( company_name ) ){ errors = true; ec_show_error( prefix + '_company_name' ); }else{ ec_hide_error( prefix + '_company_name' ); } } return ( !errors ); } function ec_validate_email_block( prefix ){ var errors = false; var email = jQuery( document.getElementById( '' + prefix + '_email' ) ).val( ).trim(); var retype_email = ""; if( jQuery( document.getElementById( '' + prefix + '_email_retype' ) ).length ) { retype_email = jQuery( document.getElementById( '' + prefix + '_email_retype' ) ).val( ).trim(); } else if ( jQuery( document.getElementById( '' + prefix + '_retype_email' ) ).length ) { retype_email = jQuery( document.getElementById( '' + prefix + '_retype_email' ) ).val( ).trim(); } else { retype_email = email; } if( !ec_validate_email( email ) ){ errors = true; ec_show_error( prefix + '_email' ); if ( jQuery( document.getElementById( 'ec_create_account_email_error' ) ).length ) { jQuery( document.getElementById( 'ec_create_account_email_error' ) ).hide(); } }else{ ec_hide_error( prefix + '_email' ); } if( !ec_validate_match( email, retype_email) ){ errors = true; ec_show_error( prefix + '_email_retype' ); }else{ ec_hide_error( prefix + '_email_retype' ); } return ( !errors ); } function ec_validate_create_account( prefix ){ var errors = false; var first_name = ( jQuery( document.getElementById( '' + prefix + '_first_name' ) ).length ) ? jQuery( document.getElementById( '' + prefix + '_first_name' ) ).val() : ''; var last_name = ( jQuery( document.getElementById( '' + prefix + '_last_name' ) ).length ) ? jQuery( document.getElementById( '' + prefix + '_last_name' ) ).val() : ''; var password = jQuery( document.getElementById( '' + prefix + '_password' ) ).val( ); var retype_password = ''; if ( jQuery( document.getElementById( '' + prefix + '_password_retype' ) ).length ) { retype_password = jQuery( document.getElementById( '' + prefix + '_password_retype' ) ).val( ); } else { retype_password = password; } if( jQuery( document.getElementById( '' + prefix + '_first_name' ) ).length && ! ec_validate_text( first_name ) ){ errors = true; ec_show_error( prefix + '_first_name' ); }else{ ec_hide_error( prefix + '_first_name' ); } if( jQuery( document.getElementById( '' + prefix + '_last_name' ) ).length && ! ec_validate_text( last_name ) ){ errors = true; ec_show_error( prefix + '_last_name' ); }else{ ec_hide_error( prefix + '_last_name' ); } if ( ! ec_validate_password( password, retype_password ) ) { errors = true; ec_show_error( prefix + '_password' ); } else { ec_hide_error( prefix + '_password' ); } if( jQuery( document.getElementById( prefix + '_password_retype' ) ).length && ! ec_validate_match( password, retype_password ) ){ errors = true; ec_show_error( prefix + '_password_retype' ); }else{ ec_hide_error( prefix + '_password_retype' ); } return ( !errors ); } function ec_validate_terms_section() { var errors = false; if ( jQuery( document.getElementById( 'ec_terms_agree' ) ).length ) { if ( ! ec_validate_terms() ) { errors = true; } } return ( ! errors ); } function ec_validate_payment_method( ){ var errors = false; var payment_method = "credit_card"; if( jQuery( 'input:radio[name=ec_cart_payment_selection]:checked' ).length ){ ec_hide_error( 'ec_payment_method' ); payment_method = jQuery( 'input:radio[name=ec_cart_payment_selection]:checked' ).val( ); }else if( jQuery( 'input:radio[name=ec_cart_payment_selection]' ).length ){ ec_show_error( 'ec_payment_method' ); return false; }else{ // free order or no payment methods ec_hide_error( 'ec_payment_method' ); return true; } var card_holder_name = "-1"; if( document.getElementById( 'ec_card_holder_name' ) ){ card_holder_name = jQuery( document.getElementById( 'ec_card_holder_name' ) ).val( ); } if( payment_method == "affirm" ){ ec_checkout_with_affirm( ); ec_hide_error( 'ec_submit_order' ); return false; }else if( payment_method == "credit_card" && jQuery( document.getElementById( 'wp-easycart-square-card-container' ) ).length ) { return true; }else if( payment_method == "credit_card" && ( document.getElementById( 'ec_stripe_card_row' ) || document.getElementById( 'wpec_braintree_dropin' ) ) ){ return true; }else if( payment_method == "credit_card" && document.getElementById( 'cardpointe_token' ) ){ if( jQuery( document.getElementById( 'cardpointe_token' ) ).val( ) == '' ){ return false; }else{ return true; } }else if( payment_method == "credit_card" ){ var cardType = jQuery.payment.cardType( jQuery( document.getElementById( 'ec_card_number' ) ).val( ) ); if( card_holder_name != "-1" && card_holder_name == "" ){ errors = true; ec_show_error( 'ec_card_holder_name' ); }else{ ec_hide_error( 'ec_card_holder_name' ); } if( !jQuery.payment.validateCardNumber( jQuery( document.getElementById( 'ec_card_number' ) ).val( ) ) ){ errors = true; ec_show_error( 'ec_card_number' ); }else{ ec_hide_error( 'ec_card_number' ); } if( !jQuery.payment.validateCardExpiry( jQuery( document.getElementById( 'ec_cc_expiration' ) ).payment( 'cardExpiryVal' ) ) ){ errors = true; ec_show_error( 'ec_expiration_date' ); }else{ ec_hide_error( 'ec_expiration_date' ); } if( !jQuery.payment.validateCardCVC( jQuery( document.getElementById( 'ec_security_code' ) ).val( ), cardType) ){ errors = true; ec_show_error( 'ec_security_code' ); }else{ ec_hide_error( 'ec_security_code' ); } } return ( !errors ); } function ec_validate_terms( ){ var errors = false; if( jQuery( document.getElementById( 'ec_terms_agree' ) ).is( ':checked' ) || jQuery( document.getElementById( 'ec_terms_agree' ) ).val( ) == '2' ){ ec_hide_error( 'ec_terms' ); }else{ errors = true; ec_show_error( 'ec_terms' ); } return ( !errors ); } function ec_validate_email( email ){ return /^([^\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)(\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 ); } function ec_validate_password( pw ){ if( pw && pw.length > 5 ) return true; else return false; } function ec_validate_text( str ){ if( str && str.length > 0 ) return true; else return false; } function ec_validate_select( val ){ if( val && val != 0 ) return true; else return false; } function ec_validate_match( val1, val2 ){ if( val1 == val2 ) return true; else return false; } function ec_validate_zip_code( zip, country ){ zip = zip.trim( ); if( country == "US" ) return /(^\d{5}$)|(^\d{5}-\d{4}$)/.test( zip ); else if( country == "AU" ) return /^([0-9]{4})$/.test( zip ); else if( country == "CA" ){ var regex = new RegExp( /^[ABCEGHJKLMNPRSTVXY]\d[ABCEGHJKLMNPRSTVWXYZ]( )?\d[ABCEGHJKLMNPRSTVWXYZ]\d$/i ); return regex.test( zip ); }else if( country == "GB" ){ var postcode = zip.replace(/\s/g, ""); 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; return regex.test( postcode ); }else return ec_validate_text( zip ); } function ec_is_state_required( country ){ if( country == "AU" || country == "BR" || country == "CA" || country == "CN" || country == "GB" || country == "IN" || country == "JP" || country == "US" ) return true; else return false; } function ec_get_card_type( card_number ){ var num = card_number; num = num.replace(/[^\d]/g,''); if( num.match( /^5[1-5]\d{14}$/ ) ) return "mastercard"; else if( num.match( /^4\d{15}/ ) || num.match( /^4\d{12}/ ) ) return "visa"; else if( num.match( /(^3[47])((\d{11}$)|(\d{13}$))/ ) ) return "amex"; 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})$/ ) ) return "discover"; else if( num.match( /^(?:5[0678]\d\d|6304|6390|67\d\d)\d{8,15}$/ ) ) return "maestro"; else if( num.match( /(^(352)[8-9](\d{11}$|\d{12}$))|(^(35)[3-8](\d{12}$|\d{13}$))/ ) ) return "jcb"; else if( num.match( /(^(30)[0-5]\d{11}$)|(^(36)\d{12}$)|(^(38[0-8])\d{11}$)/ ) ) return "diners"; else return "all"; } function ec_validate_credit_card( card_number ){ var card_type = ec_get_card_type( card_number ); if( card_type == "visa" || card_type == "delta" || card_type == "uke" ){ if( /^4[0-9]{12}(?:[0-9]{3}|[0-9]{6})?$/.test( card_number ) ) return true; else return false; }else if( card_type == "discover" ){ 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 ) ) return true; else return false; }else if( card_type == "mastercard" || card_type == "mcdebit" ){ if( /^5[1-5]\d{14}$/.test( card_number ) ) return true; else return false; }else if( card_type == "amex" ){ if( /^3[47][0-9]{13}$/.test( card_number ) ) return true; else return false; }else if( card_type == "diners" ){ if( /^3(?:0[0-5]|[68][0-9])[0-9]{11}$/.test( card_number ) ) return true; else return false; }else if( card_type == "jcb" ){ if( /^(?:2131|1800|35\d{3})\d{11}$/.test( card_number ) ) return true; else return false; }else if( card_type == "maestro" ){ if( /(^(5[0678]\d{11,18}$))|(^(6[^0357])\d{11,18}$)|(^(3)\d{13,20}$)/.test( card_number ) ) return true; else return false; } } function ec_validate_security_code( security_code ){ if( /^[0-9]{3,4}$/.test( security_code ) ) return true; else return false; } function ec_show_error( error_field ){ jQuery( document.getElementById( '' + error_field + '_error' ) ).show( ); } function ec_hide_error( error_field ){ jQuery( document.getElementById( '' + error_field + '_error' ) ).hide( ); } function ec_cart_subscription_shipping_method_change( shipping_method, price, nonce ){ jQuery( document.getElementById( 'ec_cart_subscription_shipping_methods_loader' ) ).show(); var ship_express = 0; if ( jQuery( document.getElementById( 'ec_cart_ship_express' ) ).length ) { if ( jQuery( document.getElementById( 'ec_cart_ship_express' ) ).is( ':checked' ) ) { ship_express = 1; } } if ( 'shipexpress' == shipping_method ) { shipping_method = 'standard'; if ( jQuery( document.getElementById( 'ec_cart_shipping_method_free' ) ).length ) { jQuery( document.getElementById( 'ec_cart_shipping_method_free' ) ).prop( 'checked', false ); } jQuery( document.getElementById( 'ec_cart_shipping_method' ) ).prop( 'checked', 'checked' ); } else if( 'free' == shipping_method ) { if ( jQuery( document.getElementById( 'ec_cart_ship_express' ) ).length ) { jQuery( document.getElementById( 'ec_cart_ship_express' ) ).prop( 'checked', false ); } } var data = { action: 'ec_ajax_update_subscription_shipping_method', product_id: jQuery( document.getElementById( 'product_id' ) ).val(), shipping_method: shipping_method, ship_express: ship_express, nonce: nonce }; jQuery.ajax({ url: wpeasycart_ajax_object.ajax_url, type: 'post', data: data, success: function( response ){ var data_arr = JSON.parse( response ); wpeasycart_subscription_cart_update_totals( data_arr ); jQuery( document.getElementById( 'ec_cart_subscription_shipping_methods_loader' ) ).hide(); } } ); } function ec_cart_shipping_method_change( shipping_method, price, nonce ){ jQuery( '.ec_cart_shipping_method_row' ).removeClass( 'ec_method_selected' ); jQuery( '.ec_cart_shipping_method_row > input[value="' + shipping_method + '"]' ).parent().addClass( 'ec_method_selected' ); jQuery( '.ec_cart_price_row.ec_cart_price_row_shipping_total, .ec_cart_price_row.ec_order_total' ).addClass( 'ec_cart_price_row_loading' ); var ship_express = 0; if ( jQuery( document.getElementById( 'ec_cart_ship_express' ) ).length ) { if ( jQuery( document.getElementById( 'ec_cart_ship_express' ) ).is( ':checked' ) ) { ship_express = 1; } } if ( 'shipexpress' == shipping_method ) { shipping_method = 'standard'; if ( jQuery( document.getElementById( 'ec_cart_shipping_method_free' ) ).length ) { jQuery( document.getElementById( 'ec_cart_shipping_method_free' ) ).prop( 'checked', false ); } jQuery( document.getElementById( 'ec_cart_shipping_method' ) ).prop( 'checked', 'checked' ); } else if( 'free' == shipping_method ) { if ( jQuery( document.getElementById( 'ec_cart_ship_express' ) ).length ) { jQuery( document.getElementById( 'ec_cart_ship_express' ) ).prop( 'checked', false ); } } var data = { action: 'ec_ajax_update_shipping_method', shipping_method: shipping_method, ship_express: ship_express, nonce: nonce }; jQuery.ajax({ url: wpeasycart_ajax_object.ajax_url, type: 'post', data: data, success: function( data ){ var data_arr = data.split( '***' ); jQuery( document.getElementById( 'ec_cart_shipping' ) ).html( data_arr[0] ); jQuery( document.getElementById( 'ec_cart_total' ) ).html( data_arr[1] ); jQuery( '.ec_cart_price_row.ec_cart_price_row_shipping_total, .ec_cart_price_row.ec_order_total' ).removeClass( 'ec_cart_price_row_loading' ); } } ); } jQuery( document ).ready( function( $ ){ $( ".ec_menu_vertical" ).accordion({ accordion:true, speed: 500, closedSign: '[+]', openedSign: '[-]' }); }); (function(jQuery){ jQuery.fn.extend({ accordion: function(options) { var defaults = { accordion: 'true', speed: 300, closedSign: '[+]', openedSign: '[-]' }; var opts = jQuery.extend(defaults, options); var jQuerythis = jQuery(this); jQuerythis.find("li").each(function() { if(jQuery(this).find("ul").size() != 0){ jQuery(this).find("a:first").append(""+ opts.closedSign +""); if(jQuery(this).find("a:first").attr('href') == "#"){ jQuery(this).find("a:first").click(function(){return false;}); } } }); jQuerythis.find("li.active").each(function() { jQuery(this).parents("ul").slideDown(opts.speed); jQuery(this).parents("ul").parent("li").find("span:first").html(opts.openedSign); }); jQuerythis.find("li a").click(function() { if(jQuery(this).parent().find("ul").size() != 0){ if(opts.accordion){ if(!jQuery(this).parent().find("ul").is(':visible')){ parents = jQuery(this).parent().parents("ul"); visible = jQuerythis.find("ul:visible"); visible.each(function(visibleIndex){ var close = true; parents.each(function(parentIndex){ if(parents[parentIndex] == visible[visibleIndex]){ close = false; return false; } }); if(close){ if(jQuery(this).parent().find("ul") != visible[visibleIndex]){ jQuery(visible[visibleIndex]).slideUp(opts.speed, function(){ jQuery(this).parent("li").find("span:first").html(opts.closedSign); }); } } }); } } if(jQuery(this).parent().find("ul:first").is(":visible")){ jQuery(this).parent().find("ul:first").slideUp(opts.speed, function(){ jQuery(this).parent("li").find("span:first").delay(opts.speed).html(opts.closedSign); }); }else{ jQuery(this).parent().find("ul:first").slideDown(opts.speed, function(){ jQuery(this).parent("li").find("span:first").delay(opts.speed).html(opts.openedSign); }); } } }); } }); })(jQuery); function ec_cart_widget_click( ){ if( !jQuery('.ec_cart_widget_minicart_wrap').is(':visible') ) jQuery('.ec_cart_widget_minicart_wrap').fadeIn( 200 ); else jQuery('.ec_cart_widget_minicart_wrap').fadeOut( 100 ); } function ec_cart_widget_mouseover( ){ if( !jQuery('.ec_cart_widget_minicart_wrap').is(':visible') ){ jQuery('.ec_cart_widget_minicart_wrap').fadeIn( 200 ); jQuery('.ec_cart_widget_minicart_bg').css( "display", "block" ); } } function ec_cart_widget_mouseout( ){ if( jQuery('.ec_cart_widget_minicart_wrap').is(':visible') ) { jQuery('.ec_cart_widget_minicart_wrap').fadeOut( 100 ); jQuery('.ec_cart_widget_minicart_bg').css( "display", "none" ); } } var wpeasycart_last_search = ""; function ec_live_search_update( nonce ){ var code = event.which || event.keyCode; var search_val = jQuery( '.ec_search_input' ).val( ); if( code != 16 && code != 17 && code != 18 && code != 20 && code != 37 && code != 38 && code != 39 && code != 40 && wpeasycart_last_search != search_val ){ wpeasycart_last_search = search_val; var data = { action: 'ec_ajax_live_search', search_val: search_val, nonce: nonce }; jQuery.ajax({url: wpeasycart_ajax_object.ajax_url, type: 'post', data: data, success: function( data ){ if( wpeasycart_last_search == search_val ){ data = JSON.parse( data ); jQuery( document.getElementById( 'ec_search_suggestions' ) ).empty( ); for( var i=0; i" ); } } } } ); } } function ec_account_forgot_password_button_click( ){ var errors = false; var email = jQuery( document.getElementById( 'ec_account_forgot_password_email' ) ).val( ); if( !ec_validate_email( email ) ){ errors = true; ec_show_error( 'ec_account_forgot_password_email' ); }else{ ec_hide_error( 'ec_account_forgot_password_email' ); } return( !errors ); } function ec_account_register_button_click2( ){ var top_half = ec_account_register_button_click( ); var bottom_half = true; if( jQuery( document.getElementById( 'ec_account_billing_information_country' ) ).length ) bottom_half = ec_account_billing_information_update_click( ); var extra_notes_validated = ec_account_register_validate_notes( ); var recaptcha_validated = true; if( jQuery( document.getElementById( 'ec_account_register_recaptcha' ) ).length ){ var recaptcha_response = jQuery( document.getElementById( 'ec_grecaptcha_response_register' ) ).val( ); if( !recaptcha_response.length ){ jQuery( '#ec_account_register_recaptcha > div' ).css( 'border', '1px solid red' ); recaptcha_validated = false; }else{ jQuery( '#ec_account_register_recaptcha > div' ).css( 'border', 'none' ); } } if( top_half && bottom_half && extra_notes_validated && recaptcha_validated ){ return true; }else{ return false; } } function ec_account_register_button_click( ){ var email_validated = ec_validate_email_block( 'ec_account_register' ); var contact_validated = ec_validate_create_account( 'ec_account_register' ); var terms_validated = ec_validate_terms_section(); var recaptcha_validated = true; if( jQuery( document.getElementById( 'ec_account_register_recaptcha' ) ).length ){ var recaptcha_response = jQuery( document.getElementById( 'ec_grecaptcha_response_register' ) ).val( ); if( !recaptcha_response.length ){ jQuery( '#ec_account_register_recaptcha > div' ).css( 'border', '1px solid red' ); recaptcha_validated = false; }else{ jQuery( '#ec_account_register_recaptcha > div' ).css( 'border', 'none' ); } } if( email_validated && contact_validated && terms_validated && recaptcha_validated ) return true; else return false; } function ec_account_billing_information_update_click( ){ var address_validated = ec_validate_address_block( 'ec_account_billing_information' ); if( address_validated ) return true; else return false; } function ec_account_shipping_information_update_click( ){ var address_validated = ec_validate_address_block( 'ec_account_shipping_information' ); if( address_validated ) return true; else return false; } function ec_account_personal_information_update_click( ){ var errors = false; var email = jQuery( document.getElementById( 'ec_account_personal_information_email' ) ).val( ); if( jQuery( document.getElementById( 'ec_account_personal_information_first_name' ) ).length && !ec_validate_text( jQuery( document.getElementById( 'ec_account_personal_information_first_name' ) ).val( ) ) ){ errors = true; ec_show_error( 'ec_account_personal_information_first_name' ); }else{ ec_hide_error( 'ec_account_personal_information_first_name' ); } if( jQuery( document.getElementById( 'ec_account_personal_information_last_name' ) ).length && !ec_validate_text( jQuery( document.getElementById( 'ec_account_personal_information_last_name' ) ).val( ) ) ){ errors = true; ec_show_error( 'ec_account_personal_information_last_name' ); }else{ ec_hide_error( 'ec_account_personal_information_last_name' ); } if( !ec_validate_email( email ) ){ errors = true; ec_show_error( 'ec_account_personal_information_email' ); }else{ ec_hide_error( 'ec_account_personal_information_email' ); } return( !errors ); } function ec_account_password_button_click( ){ var errors = false; var current_password = jQuery( document.getElementById( 'ec_account_password_current_password' ) ).val( ); var new_password = jQuery( document.getElementById( 'ec_account_password_new_password' ) ).val( ); var retype_password = jQuery( document.getElementById( 'ec_account_password_retype_new_password' ) ).val( ); if( !ec_validate_password( current_password ) ){ errors = true; ec_show_error( 'ec_account_password_current_password' ); }else{ ec_hide_error( 'ec_account_password_current_password' ); } if( !ec_validate_password( new_password ) ){ errors = true; ec_show_error( 'ec_account_password_new_password' ); }else{ ec_hide_error( 'ec_account_password_new_password' ); } if( !ec_validate_match( new_password, retype_password ) ){ errors = true; ec_show_error( 'ec_account_password_retype_new_password' ); }else{ ec_hide_error( 'ec_account_password_retype_new_password' ); } return( !errors ); } function ec_account_register_validate_notes( ){ 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( ) != "" ) ){ ec_hide_error( 'ec_account_register_user_notes' ); return true; }else{ ec_show_error( 'ec_account_register_user_notes' ); return false; } } function ec_account_login_button_click( ){ var errors = false; var email = jQuery( document.getElementById( 'ec_account_login_email' ) ).val( ); var password = jQuery( document.getElementById( 'ec_account_login_password' ) ).val( ); if( !ec_validate_email( email ) ){ errors = true; ec_show_error( 'ec_account_login_email' ); }else{ ec_hide_error( 'ec_account_login_email' ); } if( !ec_validate_text( password ) ){ errors = true; ec_show_error( 'ec_account_login_password' ); }else{ ec_hide_error( 'ec_account_login_password' ); } if( jQuery( document.getElementById( 'ec_account_login_recaptcha' ) ).length ){ var recaptcha_response = jQuery( document.getElementById( 'ec_grecaptcha_response_login' ) ).val( ); if( !recaptcha_response.length ){ jQuery( '#ec_account_login_recaptcha > div' ).css( 'border', '1px solid red' ); errors = true; }else{ jQuery( '#ec_account_login_recaptcha > div' ).css( 'border', 'none' ); } } return ( !errors ); } function ec_account_login_widget_button_click( ){ var errors = false; var email = jQuery( document.getElementById( 'ec_account_login_widget_email' ) ).val( ); var password = jQuery( document.getElementById( 'ec_account_login_widget_password' ) ).val( ); if( !ec_validate_email( email ) ){ errors = true; ec_show_error( 'ec_account_login_widget_email' ); }else{ ec_hide_error( 'ec_account_login_widget_email' ); } if( !ec_validate_text( password ) ){ errors = true; ec_show_error( 'ec_account_login_widget_password' ); }else{ ec_hide_error( 'ec_account_login_widget_password' ); } if( jQuery( document.getElementById( 'ec_account_login_widget_recaptcha' ) ).length ){ var recaptcha_response = jQuery( document.getElementById( 'ec_grecaptcha_response_login_widget' ) ).val( ); if( ! recaptcha_response.length ){ jQuery( '#ec_account_login_widget_recaptcha > div' ).css( 'border', '1px solid red' ); errors = true; }else{ jQuery( '#ec_account_login_widget_recaptcha > div' ).css( 'border', 'none' ); } } return ( !errors ); } function ec_close_popup_newsletter( nonce ){ jQuery( '.ec_newsletter_container' ).fadeOut( 'slow' ); var data = { action: 'ec_ajax_close_newsletter', nonce: nonce }; jQuery.ajax({url: wpeasycart_ajax_object.ajax_url, type: 'post', data: data, success: function( data ){ } } ); } function ec_submit_newsletter_signup( nonce ){ jQuery( '.ec_newsletter_pre_submit' ).hide( ); jQuery( '.ec_newsletter_post_submit' ).show( ); var email_address = jQuery( document.getElementById( 'ec_newsletter_email' ) ).val( ); var newsletter_name = ""; if( document.getElementById( 'ec_newsletter_name' ) ) newsletter_name = jQuery( document.getElementById( 'ec_newsletter_name' ) ).val( ); var data = { action: 'ec_ajax_submit_newsletter_signup', email_address: email_address, newsletter_name: newsletter_name, nonce: nonce }; jQuery.ajax({url: wpeasycart_ajax_object.ajax_url, type: 'post', data: data, success: function( data ){ } } ); } function ec_submit_newsletter_signup_widget( nonce ){ jQuery( '.ec_newsletter_pre_submit' ).hide( ); jQuery( '.ec_newsletter_post_submit' ).show( ); var email_address = jQuery( '#ec_newsletter_email_widget' ).val( ); var newsletter_name = ""; if( document.getElementById( 'ec_newsletter_name_widget' ) ) newsletter_name = jQuery( document.getElementById( 'ec_newsletter_name_widget' ) ).val( ); var data = { action: 'ec_ajax_submit_newsletter_signup', email_address: email_address, newsletter_name: newsletter_name, nonce: nonce }; jQuery.ajax({url: wpeasycart_ajax_object.ajax_url, type: 'post', data: data, success: function( data ){ } } ); } function update_download_count( orderdetail_id ){ if( jQuery( document.getElementById( 'ec_download_count_' + orderdetail_id ) ).length ){ var count = Number( jQuery( document.getElementById( 'ec_download_count_' + orderdetail_id ) ).html( ) ); var max_count = Number( jQuery( document.getElementById( 'ec_download_count_max_' + orderdetail_id ) ).html( ) ); if( count < max_count ){ count++; jQuery( document.getElementById( 'ec_download_count_' + orderdetail_id ) ).html( count ); } } } function show_billing_info( ){ jQuery( document.getElementById( 'ec_account_subscription_billing_information' ) ).slideToggle(600); return false; } function ec_check_update_subscription_info( ){ if( jQuery( document.getElementById( 'ec_account_subscription_billing_information' ) ).is(":visible") ){ var address_validated = ec_validate_address_block( 'ec_account_billing_information' ); var payment_method_complete = ec_validate_payment_method( ); var terms_complete = ec_validate_terms( ); if( address_validated && payment_method_complete && terms_complete ) return true; else return false; }else{ return true; } } function ec_cancel_subscription_check( confirm_text ){ return confirm( confirm_text ); } function ec_details_show_inquiry_form( product_id ){ jQuery( '.ec_details_inquiry_popup_' + product_id ).fadeIn( 'fast' ); return false; } function ec_details_hide_inquiry_popup( product_id ){ jQuery( '.ec_details_inquiry_popup_' + product_id ).fadeOut( 'fast' ); } function ec_details_show_image_popup( model_number ){ jQuery( document.getElementById( 'ec_details_large_popup_' + model_number ) ).show( ); jQuery( 'html' ).css( 'overflow', 'hidden' ); } function ec_details_hide_large_popup( model_number ){ jQuery( document.getElementById( 'ec_details_large_popup_' + model_number ) ).hide( ); jQuery( 'html' ).css( 'overflow', 'scroll' ); } function ec_create_ideal_order_redirect( source, nonce ){ var redirect = source.redirect.url; var data = { action: 'ec_ajax_create_stripe_ideal_order', source: source, nonce: nonce }; jQuery.ajax({url: wpeasycart_ajax_object.ajax_url, type: 'post', data: data, success: function( data ){ window.location.href = redirect; } } ); } function ec_stripe_check_order_status( source, nonce, count = 1 ) { var data = { action: 'ec_ajax_stripe_check_order_status', source: source, nonce: nonce, count: count, }; jQuery.ajax({url: wpeasycart_ajax_object.ajax_url, type: 'post', data: data, success: function( data ){ var response_obj = JSON.parse( data ); if ( 'requires_confirmation' == response_obj.status ) { ec_stripe_check_order_status( source, nonce, count++ ); } else { window.location.href = response_obj.redirect; } } } ); } function ec_notify_submit( product_id, rand_id, nonce ){ var errors = false; var email = jQuery( document.getElementById( 'ec_email_notify_' + product_id + '_' + rand_id ) ).val( ); if( !ec_validate_email( email ) ){ errors = true; jQuery( document.getElementById( 'ec_email_notify_' + product_id + '_' + rand_id + '_error' ) ).show( ); }else{ jQuery( document.getElementById( 'ec_email_notify_' + product_id + '_' + rand_id + '_error' ) ).hide( ); } var recaptcha_response = false; if( jQuery( document.getElementById( 'ec_grecaptcha_response_product_details' ) ).length ){ recaptcha_response = jQuery( document.getElementById( 'ec_grecaptcha_response_product_details' ) ).val( ); if( !recaptcha_response.length ){ jQuery( '#ec_product_details_recaptcha > div' ).css( 'border', '1px solid red' ); errors = true; }else{ jQuery( '#ec_product_details_recaptcha > div' ).css( 'border', 'none' ); } } if( !errors ){ jQuery( document.getElementById( 'ec_product_details_stock_notify_' + product_id + '_' + rand_id + '_loader_cover' ) ).show( ); jQuery( document.getElementById( 'ec_product_details_stock_notify_' + product_id + '_' + rand_id + '_loader' ) ).show( ); var data = { action: 'ec_ajax_subscribe_to_stock_notification', email: email, product_id: product_id, recaptcha_response: recaptcha_response, nonce: nonce }; jQuery.ajax({url: wpeasycart_ajax_object.ajax_url, type: 'post', data: data, success: function( data ){ jQuery( document.getElementById( 'ec_product_details_stock_notify_complete_' + product_id + '_' + rand_id ) ).show( ); jQuery( document.getElementById( 'ec_product_details_stock_notify_' + product_id + '_' + rand_id ) ).hide( ); jQuery( document.getElementById( 'ec_product_details_stock_notify_' + product_id + '_' + rand_id + '_loader_cover' ) ).hide( ); jQuery( document.getElementById( 'ec_product_details_stock_notify_' + product_id + '_' + rand_id + '_loader' ) ).hide( ); } } ); } } function wpeasycart_load_cart( cart_page, success_code, error_code, language = 'NONE', nonce ){ if( language == 'NONE' ){ language = wpeasycart_ajax_object.current_language; } var data = { action: 'ec_ajax_get_dynamic_cart_page', cart_page: cart_page, success_code: success_code, error_code: error_code, language: language, nonce: nonce }; jQuery.ajax( { url: wpeasycart_ajax_object.ajax_url, type: 'post', data: data, success: function( data ){ jQuery( document.getElementById( 'wpeasycart_cart_holder' ) ).replaceWith( data ); } } ); } function wpeasycart_load_account( account_page, page_id, success_code, error_code, language = 'NONE', nonce ){ if( language == 'NONE' ){ language = wpeasycart_ajax_object.current_language; } var data = { action: 'ec_ajax_get_dynamic_account_page', account_page: account_page, page_id: page_id, success_code: success_code, error_code: error_code, language: language, nonce: nonce }; jQuery.ajax( { url: wpeasycart_ajax_object.ajax_url, type: 'post', data: data, success: function( data ){ jQuery( document.getElementById( 'wpeasycart_account_holder' ) ).replaceWith( data ); } } ); } function wpeasycart_update_tip( tip_rate, nonce ){ jQuery( '.ec_cart_tip_item' ).removeClass( 'ec_tip_selected' ); var tip_amount = Number( jQuery( document.getElementById( 'ec_cart_tip_custom' ) ).val( ) ); jQuery( document.getElementById( 'ec_apply_tip_button' ) ).hide( ); jQuery( document.getElementById( 'ec_applying_tip' ) ).show( ); var data = { action: 'ec_ajax_update_tip_amount', tip_rate: tip_rate, tip_amount: tip_amount, language: wpeasycart_ajax_object.current_language, nonce: nonce }; jQuery.ajax( { url: wpeasycart_ajax_object.ajax_url, type: 'post', data: data, success: function( data ){ var response_obj = JSON.parse( data ); ec_update_cart( response_obj ); jQuery( document.getElementById( 'ec_apply_tip_button' ) ).show( ); jQuery( document.getElementById( 'ec_applying_tip' ) ).hide( ); } } ); } function wp_easycart_text_notification_subscribe( wpeasycart_text_iti ) { var isValid = wpeasycart_text_iti.isValidNumber(); if( ! isValid ) { jQuery( '#text_notification_error' ).show(); jQuery( document.getElementById( 'text_notification_success' ) ).hide(); return; } else { jQuery( '#text_notification_error' ).hide(); } jQuery( document.getElementById( 'text_notification_loader' ) ).show(); var text_number = wpeasycart_text_iti.getNumber(); var order_id = jQuery( document.getElementById( 'text_order_id' ) ).val( ); var data = { action: 'ec_ajax_subscribe_text_notification', text_number: text_number, order_id: order_id }; jQuery.ajax( { url: wpeasycart_ajax_object.ajax_url, type: 'post', data: data, success: function( data ){ jQuery( document.getElementById( 'text_notification_loader' ) ).hide(); jQuery( document.getElementById( 'text_notification_success' ) ).fadeIn( 'fast' ); jQuery( document.getElementById( 'text_phone_number' ) ).val( '' ) } } ); } function ec_details_advanced_adjust_price( product_id, rand_id ) { if( jQuery( document.getElementById( 'ec_base_price_' + product_id + '_' + rand_id ) ).length == 0 ) { return; } var base_price = Number( jQuery( document.getElementById( 'ec_base_option_price_' + product_id + '_' + rand_id ) ).val() ); if( jQuery( document.getElementById( 'ec_donation_amount_' + product_id + '_' + rand_id ) ).length ) { base_price = Number( jQuery( document.getElementById( 'ec_donation_amount_' + product_id + '_' + rand_id ) ).val() ); } // Get a quantity in case we need to use in calculating price var current_quantity = 1; if( jQuery( document.getElementById( 'ec_quantity_' + product_id + '_' + rand_id ) ).length > 0 ){ current_quantity = jQuery( document.getElementById( 'ec_quantity_' + product_id + '_' + rand_id ) ).val( ); } if( jQuery( '.ec_details_grid_row > input' ).length > 0 ){ current_quantity = 0; jQuery( '.ec_details_grid_row > input' ).each( function( ){ current_quantity = current_quantity + Number( jQuery( this ).val( ) ); } ); } var tier_quantities = window['tier_quantities_' + product_id + '_' + rand_id]; var tier_prices = window['tier_prices_' + product_id + '_' + rand_id]; for( var i=0; i input' ).each( function() { if( jQuery( this ).val() > 0 ) { grid_quantity += Number( jQuery( this ).val( ) ); if( jQuery( this ).attr( 'data-product-id' ) == product_id && jQuery( this ).attr( 'data-optionitem-price' ) != 0 ){ grid_adj += ( ( Number( jQuery( this ).attr( 'data-optionitem-price' ) ) ) * ( Number( jQuery( this ).val( ) ) ) ); } if( jQuery( this ).attr( 'data-product-id' ) == product_id && jQuery( this ).attr( 'data-optionitem-price-onetime' ) != 0 ){ grid_add += Number( jQuery( this ).attr( 'data-optionitem-price-onetime' ) ); } if( jQuery( this ).attr( 'data-product-id' ) == product_id && jQuery( this ).attr( 'data-optionitem-price-override' ) >= 0 ){ grid_override += ( Number( jQuery( this ).attr( 'data-optionitem-price-override' ) ) - base_price ) * ( ( Number( jQuery( this ).val( ) ) ) ); } if( jQuery( this ).attr( 'data-product-id' ) == product_id && jQuery( this ).attr( 'data-optionitem-price-multiplier' ) > 0 ){ price_multiplier = price_multiplier * Number( jQuery( this ).attr( 'data-optionitem-price-multiplier' ) ); } } } ); jQuery( '.ec_details_checkbox_row:visible > input:checked' ).each( function( ){ if( jQuery( this ).attr( 'data-product-id' ) == product_id && jQuery( this ).attr( 'data-optionitem-price' ) != 0 ){ if( grid_quantity ) checkbox_adj += Number( jQuery( this ).attr( 'data-optionitem-price' ) ) * grid_quantity; else checkbox_adj += Number( jQuery( this ).attr( 'data-optionitem-price' ) ); } if( jQuery( this ).attr( 'data-product-id' ) == product_id && jQuery( this ).attr( 'data-optionitem-price-onetime' ) != 0 ){ checkbox_add += Number( jQuery( this ).attr( 'data-optionitem-price-onetime' ) ); } if( jQuery( this ).attr( 'data-product-id' ) == product_id && jQuery( this ).attr( 'data-optionitem-price-override' ) >= 0 ){ override_price = Number( jQuery( this ).attr( 'data-optionitem-price-override' ) ); } if( jQuery( this ).attr( 'data-product-id' ) == product_id && jQuery( this ).attr( 'data-optionitem-price-multiplier' ) > 0 ){ price_multiplier = price_multiplier * Number( jQuery( this ).attr( 'data-optionitem-price-multiplier' ) ); } } ); jQuery( '.ec_details_option_row.ec_option_type_combo:visible > .ec_details_option_data > select option:selected' ).each( function( ){ if( jQuery( this ).attr( 'data-product-id' ) == product_id && jQuery( this ).attr( 'data-optionitem-price' ) != 0 ){ if( grid_quantity ) combo_adj += Number( jQuery( this ).attr( 'data-optionitem-price' ) ) * grid_quantity; else combo_adj += Number( jQuery( this ).attr( 'data-optionitem-price' ) ); } if( jQuery( this ).attr( 'data-product-id' ) == product_id && jQuery( this ).attr( 'data-optionitem-price-onetime' ) != 0 ){ combo_add += Number( jQuery( this ).attr( 'data-optionitem-price-onetime' ) ); } if( jQuery( this ).attr( 'data-product-id' ) == product_id && jQuery( this ).attr( 'data-optionitem-price-override' ) >= 0 ){ override_price = Number( jQuery( this ).attr( 'data-optionitem-price-override' ) ); } if( jQuery( this ).attr( 'data-product-id' ) == product_id && jQuery( this ).attr( 'data-optionitem-price-multiplier' ) > 0 ){ price_multiplier = price_multiplier * Number( jQuery( this ).attr( 'data-optionitem-price-multiplier' ) ); } } ); jQuery( '.ec_details_option_row.ec_option_type_date:visible > .ec_details_option_data > input' ).each( function( ){ if( jQuery( this ).val( ) != "" ){ if( jQuery( this ).attr( 'data-product-id' ) == product_id && jQuery( this ).attr( 'data-optionitem-price' ) != 0 ){ if( grid_quantity ) date_adj += Number( jQuery( this ).attr( 'data-optionitem-price' ) ) * grid_quantity; else date_adj += Number( jQuery( this ).attr( 'data-optionitem-price' ) ); } if( jQuery( this ).attr( 'data-product-id' ) == product_id && jQuery( this ).attr( 'data-optionitem-price-onetime' ) != 0 ){ date_add += Number( jQuery( this ).attr( 'data-optionitem-price-onetime' ) ); } if( jQuery( this ).attr( 'data-product-id' ) == product_id && jQuery( this ).attr( 'data-optionitem-price-override' ) >= 0 ){ override_price = Number( jQuery( this ).attr( 'data-optionitem-price-override' ) ); } if( jQuery( this ).attr( 'data-product-id' ) == product_id && jQuery( this ).attr( 'data-optionitem-price-multiplier' ) > 0 ){ price_multiplier = price_multiplier * Number( jQuery( this ).attr( 'data-optionitem-price-multiplier' ) ); } } } ); jQuery( '.ec_details_option_row.ec_option_type_file:visible > .ec_details_option_data > input' ).each( function( ){ if( jQuery( this ).val( ) != "" ){ if( jQuery( this ).attr( 'data-product-id' ) == product_id && jQuery( this ).attr( 'data-optionitem-price' ) != 0 ){ if( grid_quantity ) file_adj += Number( jQuery( this ).attr( 'data-optionitem-price' ) ) * grid_quantity; else file_adj += Number( jQuery( this ).attr( 'data-optionitem-price' ) ); } if( jQuery( this ).attr( 'data-product-id' ) == product_id && jQuery( this ).attr( 'data-optionitem-price-onetime' ) != 0 ){ file_add += Number( jQuery( this ).attr( 'data-optionitem-price-onetime' ) ); } if( jQuery( this ).attr( 'data-product-id' ) == product_id && jQuery( this ).attr( 'data-optionitem-price-override' ) >= 0 ){ override_price = Number( jQuery( this ).attr( 'data-optionitem-price-override' ) ); } if( jQuery( this ).attr( 'data-product-id' ) == product_id && jQuery( this ).attr( 'data-optionitem-price-multiplier' ) > 0 ){ price_multiplier = price_multiplier * Number( jQuery( this ).attr( 'data-optionitem-price-multiplier' ) ); } } } ); jQuery( '.ec_details_swatch.ec_advanced.ec_selected:visible' ).each( function( ){ if( jQuery( this ).attr( 'data-product-id' ) == product_id && jQuery( this ).attr( 'data-optionitem-price' ) != 0 ){ if( grid_quantity ) swatch_adj += Number( jQuery( this ).attr( 'data-optionitem-price' ) ) * grid_quantity; else swatch_adj += Number( jQuery( this ).attr( 'data-optionitem-price' ) ); } if( jQuery( this ).attr( 'data-product-id' ) == product_id && jQuery( this ).attr( 'data-optionitem-price-onetime' ) != 0 ){ swatch_add += Number( jQuery( this ).attr( 'data-optionitem-price-onetime' ) ); } if( jQuery( this ).attr( 'data-product-id' ) == product_id && jQuery( this ).attr( 'data-optionitem-price-override' ) >= 0 ){ override_price = Number( jQuery( this ).attr( 'data-optionitem-price-override' ) ); } if( jQuery( this ).attr( 'data-product-id' ) == product_id && jQuery( this ).attr( 'data-optionitem-price-multiplier' ) > 0 ){ price_multiplier = price_multiplier * Number( jQuery( this ).attr( 'data-optionitem-price-multiplier' ) ); } } ); jQuery( '.ec_details_radio_row:visible > input:checked' ).each( function( ){ if( jQuery( this ).attr( 'data-product-id' ) == product_id && jQuery( this ).attr( 'data-optionitem-price' ) != 0 ){ if( grid_quantity ) radio_adj += Number( jQuery( this ).attr( 'data-optionitem-price' ) ) * grid_quantity; else radio_adj += Number( jQuery( this ).attr( 'data-optionitem-price' ) ); } if( jQuery( this ).attr( 'data-product-id' ) == product_id && jQuery( this ).attr( 'data-optionitem-price-onetime' ) != 0 ){ radio_add += Number( jQuery( this ).attr( 'data-optionitem-price-onetime' ) ); } if( jQuery( this ).attr( 'data-product-id' ) == product_id && jQuery( this ).attr( 'data-optionitem-price-override' ) >= 0 ){ override_price = Number( jQuery( this ).attr( 'data-optionitem-price-override' ) ); } if( jQuery( this ).attr( 'data-product-id' ) == product_id && jQuery( this ).attr( 'data-optionitem-price-multiplier' ) > 0 ){ price_multiplier = price_multiplier * Number( jQuery( this ).attr( 'data-optionitem-price-multiplier' ) ); } } ); jQuery( '.ec_details_option_row.ec_option_type_text:visible > .ec_details_option_data > input' ).each( function( ){ if( jQuery( this ).val( ) != "" ){ if( jQuery( this ).attr( 'data-product-id' ) == product_id && jQuery( this ).attr( 'data-optionitem-price' ) != 0 ){ if( grid_quantity ) text_adj += Number( jQuery( this ).attr( 'data-optionitem-price' ) ) * grid_quantity; else text_adj += Number( jQuery( this ).attr( 'data-optionitem-price' ) ); } if( jQuery( this ).attr( 'data-product-id' ) == product_id && jQuery( this ).attr( 'data-optionitem-price-onetime' ) != 0 ){ text_add += Number( jQuery( this ).attr( 'data-optionitem-price-onetime' ) ); } if( jQuery( this ).attr( 'data-product-id' ) == product_id && jQuery( this ).attr( 'data-optionitem-price-override' ) >= 0 ){ override_price = Number( jQuery( this ).attr( 'data-optionitem-price-override' ) ); } if( jQuery( this ).attr( 'data-product-id' ) == product_id && jQuery( this ).attr( 'data-optionitem-price-multiplier' ) > 0 ){ price_multiplier = price_multiplier * Number( jQuery( this ).attr( 'data-optionitem-price-multiplier' ) ); } if( jQuery( this ).attr( 'data-product-id' ) == product_id && jQuery( this ).attr( 'data-optionitem-price-per-character' ) > 0 ){ var num_characters = Number( jQuery( this ).val( ).replace( / /g, '' ).length ); var price_per_char = Number( jQuery( this ).attr( 'data-optionitem-price-per-character' ) ); text_adj = text_adj + ( num_characters * price_per_char ); } } } ); jQuery( '.ec_details_option_row.ec_option_type_number:visible > .ec_details_option_data > input' ).each( function( ){ if( jQuery( this ).val( ) != "" && jQuery( this ).val( ) != "0" ){ if( jQuery( this ).attr( 'data-product-id' ) == product_id && jQuery( this ).attr( 'data-optionitem-price' ) != 0 ){ if( grid_quantity > 0 ) number_adj += Number( jQuery( this ).val( ) ) * Number( jQuery( this ).attr( 'data-optionitem-price' ) ) * grid_quantity; else number_adj += Number( jQuery( this ).val( ) ) * Number( jQuery( this ).attr( 'data-optionitem-price' ) ); } if( jQuery( this ).attr( 'data-product-id' ) == product_id && jQuery( this ).attr( 'data-optionitem-price-onetime' ) != 0 ){ number_add += Number( jQuery( this ).attr( 'data-optionitem-price-onetime' ) ); } if( jQuery( this ).attr( 'data-product-id' ) == product_id && jQuery( this ).attr( 'data-optionitem-price-override' ) >= 0 ){ override_price = Number( jQuery( this ).attr( 'data-optionitem-price-override' ) ); } if( jQuery( this ).attr( 'data-product-id' ) == product_id && jQuery( this ).attr( 'data-optionitem-price-multiplier' ) > 0 ){ price_multiplier = price_multiplier * Number( jQuery( this ).val( ) ) * Number( jQuery( this ).attr( 'data-optionitem-price-multiplier' ) ); } } } ); jQuery( '.ec_details_option_row.ec_option_type_textarea:visible > .ec_details_option_data > textarea' ).each( function( ){ if( jQuery( this ).val( ) != "" ){ if( jQuery( this ).attr( 'data-product-id' ) == product_id && jQuery( this ).attr( 'data-optionitem-price' ) != 0 ){ textarea_adj += Number( jQuery( this ).attr( 'data-optionitem-price' ) ); } if( jQuery( this ).attr( 'data-product-id' ) == product_id && jQuery( this ).attr( 'data-optionitem-price-onetime' ) != 0 ){ textarea_add += Number( jQuery( this ).attr( 'data-optionitem-price-onetime' ) ); } if( jQuery( this ).attr( 'data-product-id' ) == product_id && jQuery( this ).attr( 'data-optionitem-price-override' ) >= 0 ){ override_price = Number( jQuery( this ).attr( 'data-optionitem-price-override' ) ); } if( jQuery( this ).attr( 'data-product-id' ) == product_id && jQuery( this ).attr( 'data-optionitem-price-multiplier' ) > 0 ){ price_multiplier = price_multiplier * Number( jQuery( this ).attr( 'data-optionitem-price-multiplier' ) ); } if( jQuery( this ).attr( 'data-product-id' ) == product_id && jQuery( this ).attr( 'data-optionitem-price-per-character' ) > 0 ){ var num_characters = Number( jQuery( this ).val( ).replace( / /g, '' ).length ); var price_per_char = Number( jQuery( this ).attr( 'data-optionitem-price-per-character' ) ); textarea_adj = textarea_adj + ( num_characters * price_per_char ); } } } ); jQuery( '.ec_dimensions_width' ).each( function( ){ if( Number( jQuery( this ).attr( 'data-product-id' ) ) == Number( product_id ) && Number( jQuery( this ).attr( 'data-rand-id' ) == rand_id ) ){ has_sq_footage = true; var product_option_id = jQuery( this ).attr( 'data-product-option-id' ); var width = jQuery( document.getElementById( 'ec_option_adv_' + product_option_id + '_' + product_id + '_' + rand_id + '_width' ) ).val( ); var sub_width = 0; var is_metric = ( '1' == jQuery( this ).attr( 'data-is-metric' ) ) ? 1 : 0; if( jQuery( document.getElementById( 'ec_option_adv_' + product_option_id + '_' + product_id + '_' + rand_id + '_sub_width' ) ).length ) { var sub_width = jQuery( document.getElementById( 'ec_option_adv_' + product_option_id + '_' + product_id + '_' + rand_id + '_sub_width' ) ).val( ); } var height = jQuery( document.getElementById( 'ec_option_adv_' + product_option_id + '_' + product_id + '_' + rand_id + '_height' ) ).val( ); var sub_height = 0; if( jQuery( document.getElementById( 'ec_option_adv_' + product_option_id + '_' + product_id + '_' + rand_id + '_sub_height' ) ).length ) { var sub_height = jQuery( document.getElementById( 'ec_option_adv_' + product_option_id + '_' + product_id + '_' + rand_id + '_sub_height' ) ).val( ); } if( '' != width && '' != height ) { 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( ) ); } } } ); if( grid_quantity > 0 ) { base_price = base_price * grid_quantity; } 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 ) ); var new_price_sqft = new_price * sq_footage; 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 ); var override_price_sqft = override_price_final * sq_footage; 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 ); if( override_price > -1 ){ jQuery( document.getElementById( 'ec_final_price_' + product_id + '_' + rand_id ) ).html( ec_details_format_money_v2( product_id, rand_id, override_price_sqft ) ); 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 ) ); } ); 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_final ) ); } ); if ( '1' == vat_added ) { jQuery( '.ec_details_price.ec_details_no_vat_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 ) ); } ); jQuery( '.ec_details_price.ec_details_vat_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 * vat_rate_multiplier ) ); } ); jQuery( '.ec_details_price.ec_details_no_vat_price > .ec_product_price_' + product_id + '_' + rand_id ).each( function() { jQuery( this ).html( ec_details_format_money_v2( product_id, rand_id, override_price_final ) ); } ); jQuery( '.ec_details_price.ec_details_vat_price > .ec_product_price_' + product_id + '_' + rand_id ).each( function() { jQuery( this ).html( ec_details_format_money_v2( product_id, rand_id, override_price_final * vat_rate_multiplier ) ); } ); } else { jQuery( '.ec_details_price.ec_details_no_vat_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 / vat_rate_multiplier ) ); } ); jQuery( '.ec_details_price.ec_details_vat_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 ) ); } ); jQuery( '.ec_details_price.ec_details_no_vat_price > .ec_product_price_' + product_id + '_' + rand_id ).each( function() { jQuery( this ).html( ec_details_format_money_v2( product_id, rand_id, override_price_final / vat_rate_multiplier ) ); } ); jQuery( '.ec_details_price.ec_details_vat_price > .ec_product_price_' + product_id + '_' + rand_id ).each( function() { jQuery( this ).html( ec_details_format_money_v2( product_id, rand_id, override_price_final ) ); } ); } } else { jQuery( document.getElementById( 'ec_final_price_' + product_id + '_' + rand_id ) ).html( ec_details_format_money_v2( product_id, rand_id, new_price_sqft ) ); 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, new_price ) ); } ); 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, new_price ) ); } ); if ( '1' == vat_added ) { jQuery( '.ec_details_price.ec_details_no_vat_price > .ec_product_sale_price_' + product_id + '_' + rand_id ).each( function( ){ jQuery( this ).html( ec_details_format_money_v2( product_id, rand_id, new_price ) ); } ); jQuery( '.ec_details_price.ec_details_vat_price > .ec_product_sale_price_' + product_id + '_' + rand_id ).each( function( ){ jQuery( this ).html( ec_details_format_money_v2( product_id, rand_id, new_price * vat_rate_multiplier ) ); } ); jQuery( '.ec_details_price.ec_details_no_vat_price > .ec_product_price_' + product_id + '_' + rand_id ).each( function( ){ jQuery( this ).html( ec_details_format_money_v2( product_id, rand_id, new_price ) ); } ); jQuery( '.ec_details_price.ec_details_vat_price > .ec_product_price_' + product_id + '_' + rand_id ).each( function( ){ jQuery( this ).html( ec_details_format_money_v2( product_id, rand_id, new_price * vat_rate_multiplier ) ); } ); } else { jQuery( '.ec_details_price.ec_details_no_vat_price > .ec_product_sale_price_' + product_id + '_' + rand_id ).each( function( ){ jQuery( this ).html( ec_details_format_money_v2( product_id, rand_id, new_price / vat_rate_multiplier ) ); } ); jQuery( '.ec_details_price.ec_details_vat_price > .ec_product_sale_price_' + product_id + '_' + rand_id ).each( function( ){ jQuery( this ).html( ec_details_format_money_v2( product_id, rand_id, new_price ) ); } ); jQuery( '.ec_details_price.ec_details_no_vat_price > .ec_product_price_' + product_id + '_' + rand_id ).each( function( ){ jQuery( this ).html( ec_details_format_money_v2( product_id, rand_id, new_price / vat_rate_multiplier ) ); } ); jQuery( '.ec_details_price.ec_details_vat_price > .ec_product_price_' + product_id + '_' + rand_id ).each( function( ){ jQuery( this ).html( ec_details_format_money_v2( product_id, rand_id, new_price ) ); } ); } } if ( price_multiplier != 1 && override_price > -1 ) { 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 ) ) ); 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 * Number( price_multiplier ) ) ); } ); 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_final * Number( price_multiplier ) ) ); } ); if ( '1' == vat_added ) { jQuery( '.ec_details_price.ec_details_no_vat_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 * Number( price_multiplier ) ) ); } ); jQuery( '.ec_details_price.ec_details_vat_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 * Number( price_multiplier ) * vat_rate_multiplier ) ); } ); jQuery( '.ec_details_price.ec_details_no_vat_price > .ec_product_price_' + product_id + '_' + rand_id ).each( function( ){ jQuery( this ).html( ec_details_format_money_v2( product_id, rand_id, override_price_final * Number( price_multiplier ) ) ); } ); jQuery( '.ec_details_price.ec_details_vat_price > .ec_product_price_' + product_id + '_' + rand_id ).each( function( ){ jQuery( this ).html( ec_details_format_money_v2( product_id, rand_id, override_price_final * Number( price_multiplier ) * vat_rate_multiplier ) ); } ); } else { jQuery( '.ec_details_price.ec_details_no_vat_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 * Number( price_multiplier ) / vat_rate_multiplier ) ); } ); jQuery( '.ec_details_price.ec_details_vat_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 * Number( price_multiplier ) ) ); } ); jQuery( '.ec_details_price.ec_details_no_vat_price > .ec_product_price_' + product_id + '_' + rand_id ).each( function( ){ jQuery( this ).html( ec_details_format_money_v2( product_id, rand_id, override_price_final * Number( price_multiplier ) / vat_rate_multiplier ) ); } ); jQuery( '.ec_details_price.ec_details_vat_price > .ec_product_price_' + product_id + '_' + rand_id ).each( function( ){ jQuery( this ).html( ec_details_format_money_v2( product_id, rand_id, override_price_final * Number( price_multiplier ) ) ); } ); } } else if( price_multiplier != 1 ){ 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 ) ) ); 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, new_price * Number( price_multiplier ) ) ); } ); 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, new_price * Number( price_multiplier ) ) ); } ); if( '1' == vat_added ){ jQuery( '.ec_details_price.ec_details_no_vat_price > .ec_product_sale_price_' + product_id + '_' + rand_id ).each( function( ){ jQuery( this ).html( ec_details_format_money_v2( product_id, rand_id, new_price * Number( price_multiplier ) ) ); } ); jQuery( '.ec_details_price.ec_details_vat_price > .ec_product_sale_price_' + product_id + '_' + rand_id ).each( function( ){ jQuery( this ).html( ec_details_format_money_v2( product_id, rand_id, new_price * Number( price_multiplier ) * vat_rate_multiplier ) ); } ); jQuery( '.ec_details_price.ec_details_no_vat_price > .ec_product_price_' + product_id + '_' + rand_id ).each( function( ){ jQuery( this ).html( ec_details_format_money_v2( product_id, rand_id, new_price * Number( price_multiplier ) ) ); } ); jQuery( '.ec_details_price.ec_details_vat_price > .ec_product_price_' + product_id + '_' + rand_id ).each( function( ){ jQuery( this ).html( ec_details_format_money_v2( product_id, rand_id, new_price * Number( price_multiplier ) * vat_rate_multiplier ) ); } ); } else { jQuery( '.ec_details_price.ec_details_no_vat_price > .ec_product_sale_price_' + product_id + '_' + rand_id ).each( function( ){ jQuery( this ).html( ec_details_format_money_v2( product_id, rand_id, new_price * Number( price_multiplier ) / vat_rate_multiplier ) ); } ); jQuery( '.ec_details_price.ec_details_vat_price > .ec_product_sale_price_' + product_id + '_' + rand_id ).each( function( ){ jQuery( this ).html( ec_details_format_money_v2( product_id, rand_id, new_price * Number( price_multiplier ) ) ); } ); jQuery( '.ec_details_price.ec_details_no_vat_price > .ec_product_price_' + product_id + '_' + rand_id ).each( function( ){ jQuery( this ).html( ec_details_format_money_v2( product_id, rand_id, new_price * Number( price_multiplier ) / vat_rate_multiplier ) ); } ); jQuery( '.ec_details_price.ec_details_vat_price > .ec_product_price_' + product_id + '_' + rand_id ).each( function( ){ jQuery( this ).html( ec_details_format_money_v2( product_id, rand_id, new_price * Number( price_multiplier ) ) ); } ); } } if( order_price != 0 ){ jQuery( '.ec_details_added_price_' + product_id + '_' + rand_id ).show( ); jQuery( document.getElementById( 'ec_added_price_' + product_id + '_' + rand_id ) ).html( ec_details_format_money_v2( product_id, rand_id, order_price ) ); }else{ jQuery( '.ec_details_added_price_' + product_id + '_' + rand_id ).hide( ); } } function ec_details_base_adjust_price( product_id, rand_id ) { if( jQuery( document.getElementById( 'ec_default_price_' + product_id + '_' + rand_id ) ).length == 0 ) { return; } var base_price = Number( jQuery( document.getElementById( 'ec_default_price_' + product_id + '_' + rand_id ) ).val() ); if( jQuery( document.getElementById( 'ec_donation_amount_' + product_id + '_' + rand_id ) ).length ) { base_price = Number( jQuery( document.getElementById( 'ec_donation_amount_' + product_id + '_' + rand_id ) ).val() ); } var current_quantity = jQuery( document.getElementById( 'ec_quantity_' + product_id + '_' + rand_id ) ).val( ); var tier_quantities = window['tier_quantities_' + product_id + '_' + rand_id]; var tier_prices = window['tier_prices_' + product_id + '_' + rand_id]; if ( tier_quantities ) { for ( var i=0; i li.ec_option1_' + product_id + '_' + rand_id + '.ec_selected' ).length ) { basic_options_selected++; basic_options_string += jQuery( '#ec_option1_' + product_id + '_' + rand_id ).val(); } 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') { basic_options_selected++; basic_options_string += jQuery( '.ec_details_combo.ec_option1_' + product_id + '_' + rand_id ).val(); } else { basic_options_string += '0'; } if ( jQuery( '.ec_details_swatches > li.ec_option2_' + product_id + '_' + rand_id + '.ec_selected' ).length ) { basic_options_selected++; basic_options_string += jQuery( '#ec_option2_' + product_id + '_' + rand_id ).val(); } 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') { basic_options_selected++; basic_options_string += jQuery( '.ec_details_combo.ec_option2_' + product_id + '_' + rand_id ).val(); } else { basic_options_string += '0'; } if ( jQuery( '.ec_details_swatches > li.ec_option3_' + product_id + '_' + rand_id + '.ec_selected' ).length ) { basic_options_selected++; basic_options_string += jQuery( '#ec_option3_' + product_id + '_' + rand_id ).val(); } 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') { basic_options_selected++; basic_options_string += jQuery( '.ec_details_combo.ec_option3_' + product_id + '_' + rand_id ).val(); } else { basic_options_string += '0'; } if ( jQuery( '.ec_details_swatches > li.ec_option4_' + product_id + '_' + rand_id + '.ec_selected' ).length ) { basic_options_selected++; basic_options_string += jQuery( '#ec_option4_' + product_id + '_' + rand_id ).val(); } 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') { basic_options_selected++; basic_options_string += jQuery( '.ec_details_combo.ec_option4_' + product_id + '_' + rand_id ).val(); } else { basic_options_string += '0'; } if ( jQuery( '.ec_details_swatches > li.ec_option5_' + product_id + '_' + rand_id + '.ec_selected' ).length ) { basic_options_selected++; basic_options_string += jQuery( '#ec_option5_' + product_id + '_' + rand_id ).val(); } 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') { basic_options_selected++; basic_options_string += jQuery( '.ec_details_combo.ec_option5_' + product_id + '_' + rand_id ).val(); } else { basic_options_string += '0'; } 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 != '' ) { jQuery( '.ec_details_model_number_sku_' + product_id + '_' + rand_id ).html( window['varitation_data_' + product_id + '_' + rand_id][basic_options_string].sku ); } else { jQuery( '.ec_details_model_number_sku_' + product_id + '_' + rand_id ).html( jQuery( document.getElementById( 'ec_default_sku_' + product_id + '_' + rand_id ) ).val() ); } 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 ) { base_price = window['varitation_data_' + product_id + '_' + rand_id][basic_options_string].price; Number( jQuery( document.getElementById( 'ec_base_price_' + product_id + '_' + rand_id ) ).html( base_price ) ); } else { // Option 1 Price Adjustment 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 ){ 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' ); 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' ); 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' ) ); 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' ) ); }else if( jQuery( '.ec_details_combo.ec_option1_' + product_id + '_' + rand_id ).length ){ option1_price_adj = jQuery( '.ec_details_combo.ec_option1_' + product_id + '_' + rand_id + ' option:selected' ).attr( 'data-optionitem-price' ); option1_price_add = jQuery( '.ec_details_combo.ec_option1_' + product_id + '_' + rand_id + ' option:selected' ).attr( 'data-optionitem-price-onetime' ); option1_price_override = Number( jQuery( '.ec_details_combo.ec_option1_' + product_id + '_' + rand_id + ' option:selected' ).attr( 'data-optionitem-price-override' ) ); option1_price_multiplier = Number( jQuery( '.ec_details_combo.ec_option1_' + product_id + '_' + rand_id + ' option:selected' ).attr( 'data-optionitem-price-multiplier' ) ); } // Option 2 Price Adjustment 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 ){ 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' ); 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' ); 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' ) ); 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' ) ); }else if( jQuery( '.ec_details_combo.ec_option2_' + product_id + '_' + rand_id ).length ){ option2_price_adj = jQuery( '.ec_details_combo.ec_option2_' + product_id + '_' + rand_id + ' option:selected' ).attr( 'data-optionitem-price' ); option2_price_add = jQuery( '.ec_details_combo.ec_option2_' + product_id + '_' + rand_id + ' option:selected' ).attr( 'data-optionitem-price-onetime' ); option2_price_override = Number( jQuery( '.ec_details_combo.ec_option2_' + product_id + '_' + rand_id + ' option:selected' ).attr( 'data-optionitem-price-override' ) ); option2_price_multiplier = Number( jQuery( '.ec_details_combo.ec_option2_' + product_id + '_' + rand_id + ' option:selected' ).attr( 'data-optionitem-price-multiplier' ) ); } // Option 3 Price Adjustment 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 ){ 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' ); 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' ); 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' ) ); 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' ) ); }else if( jQuery( '.ec_details_combo.ec_option3_' + product_id + '_' + rand_id ).length ){ option3_price_adj = jQuery( '.ec_details_combo.ec_option3_' + product_id + '_' + rand_id + ' option:selected' ).attr( 'data-optionitem-price' ); option3_price_add = jQuery( '.ec_details_combo.ec_option3_' + product_id + '_' + rand_id + ' option:selected' ).attr( 'data-optionitem-price-onetime' ); option3_price_override = Number( jQuery( '.ec_details_combo.ec_option3_' + product_id + '_' + rand_id + ' option:selected' ).attr( 'data-optionitem-price-override' ) ); option3_price_multiplier = Number( jQuery( '.ec_details_combo.ec_option3_' + product_id + '_' + rand_id + ' option:selected' ).attr( 'data-optionitem-price-multiplier' ) ); } // Option 4 Price Adjustment 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 ){ 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' ); 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' ); 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' ) ); 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' ) ); }else if( jQuery( '.ec_details_combo.ec_option4_' + product_id + '_' + rand_id ).length ){ option4_price_adj = jQuery( '.ec_details_combo.ec_option4_' + product_id + '_' + rand_id + ' option:selected' ).attr( 'data-optionitem-price' ); option4_price_add = jQuery( '.ec_details_combo.ec_option4_' + product_id + '_' + rand_id + ' option:selected' ).attr( 'data-optionitem-price-onetime' ); option4_price_override = Number( jQuery( '.ec_details_combo.ec_option4_' + product_id + '_' + rand_id + ' option:selected' ).attr( 'data-optionitem-price-override' ) ); option4_price_multiplier = Number( jQuery( '.ec_details_combo.ec_option4_' + product_id + '_' + rand_id + ' option:selected' ).attr( 'data-optionitem-price-multiplier' ) ); } // Option 5 Price Adjustment 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 ){ 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' ); 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' ); 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' ) ); 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' ) ); }else if( jQuery( '.ec_details_combo.ec_option5_' + product_id + '_' + rand_id ).length ){ option5_price_adj = jQuery( '.ec_details_combo.ec_option5_' + product_id + '_' + rand_id + ' option:selected' ).attr( 'data-optionitem-price' ); option5_price_add = jQuery( '.ec_details_combo.ec_option5_' + product_id + '_' + rand_id + ' option:selected' ).attr( 'data-optionitem-price-onetime' ); option5_price_override = Number( jQuery( '.ec_details_combo.ec_option5_' + product_id + '_' + rand_id + ' option:selected' ).attr( 'data-optionitem-price-override' ) ); option5_price_multiplier = Number( jQuery( '.ec_details_combo.ec_option5_' + product_id + '_' + rand_id + ' option:selected' ).attr( 'data-optionitem-price-multiplier' ) ); } } var num_decimals = jQuery( document.getElementById( 'num_decimals_' + product_id + '_' + rand_id ) ).val(); var decimal_symbol = jQuery( document.getElementById( 'decimal_symbol_' + product_id + '_' + rand_id ) ).val(); var grouping_symbol = jQuery( document.getElementById( 'grouping_symbol_' + product_id + '_' + rand_id ) ).val(); 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 ); var order_price = Number( option1_price_add ) + Number( option2_price_add ) + Number( option3_price_add ) + Number( option4_price_add ) + Number( option5_price_add ); var override_price = -1; if( option1_price_override > -1 ) { override_price = option1_price_override; } else if( option2_price_override > -1 ) { override_price = option2_price_override; } else if( option3_price_override > -1 ) { override_price = option3_price_override; } else if( option4_price_override > -1 ) { override_price = option4_price_override; } else if( option5_price_override > -1 ) { override_price = option5_price_override; } if( override_price > -1 ){ jQuery( document.getElementById( 'ec_final_price_' + product_id + '_' + rand_id ) ).html( ec_details_format_money_v2( product_id, rand_id, override_price ) ); jQuery( document.getElementById( 'ec_base_option_price_' + product_id + '_' + rand_id ) ).val( override_price ); 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 ) ); } ); 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 ) ); } ); if ( '1' == vat_added ) { jQuery( '.ec_details_price.ec_details_no_vat_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 ) ); } ); jQuery( '.ec_details_price.ec_details_vat_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 * vat_rate_multiplier ) ); } ); jQuery( '.ec_details_price.ec_details_no_vat_price > .ec_product_price_' + product_id + '_' + rand_id ).each( function( ){ jQuery( this ).html( ec_details_format_money_v2( product_id, rand_id, override_price ) ); } ); jQuery( '.ec_details_price.ec_details_vat_price > .ec_product_price_' + product_id + '_' + rand_id ).each( function( ){ jQuery( this ).html( ec_details_format_money_v2( product_id, rand_id, override_price * vat_rate_multiplier ) ); } ); } else { jQuery( '.ec_details_price.ec_details_no_vat_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 / vat_rate_multiplier ) ); } ); jQuery( '.ec_details_price.ec_details_vat_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 ) ); } ); jQuery( '.ec_details_price.ec_details_no_vat_price > .ec_product_price_' + product_id + '_' + rand_id ).each( function( ){ jQuery( this ).html( ec_details_format_money_v2( product_id, rand_id, override_price / vat_rate_multiplier ) ); } ); jQuery( '.ec_details_price.ec_details_vat_price > .ec_product_price_' + product_id + '_' + rand_id ).each( function( ){ jQuery( this ).html( ec_details_format_money_v2( product_id, rand_id, override_price ) ); } ); } }else{ jQuery( document.getElementById( 'ec_final_price_' + product_id + '_' + rand_id ) ).html( ec_details_format_money_v2( product_id, rand_id, new_price ) ); jQuery( document.getElementById( 'ec_base_option_price_' + product_id + '_' + rand_id ) ).val( new_price ); 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, new_price ) ); } ); 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, new_price ) ); } ); if ( '1' == vat_added ) { jQuery( '.ec_details_price.ec_details_no_vat_price > .ec_product_sale_price_' + product_id + '_' + rand_id ).each( function( ){ jQuery( this ).html( ec_details_format_money_v2( product_id, rand_id, new_price ) ); } ); jQuery( '.ec_details_price.ec_details_vat_price > .ec_product_sale_price_' + product_id + '_' + rand_id ).each( function( ){ jQuery( this ).html( ec_details_format_money_v2( product_id, rand_id, new_price * vat_rate_multiplier ) ); } ); jQuery( '.ec_details_price.ec_details_no_vat_price > .ec_product_price_' + product_id + '_' + rand_id ).each( function( ){ jQuery( this ).html( ec_details_format_money_v2( product_id, rand_id, new_price ) ); } ); jQuery( '.ec_details_price.ec_details_vat_price > .ec_product_price_' + product_id + '_' + rand_id ).each( function( ){ jQuery( this ).html( ec_details_format_money_v2( product_id, rand_id, new_price * vat_rate_multiplier ) ); } ); } else { jQuery( '.ec_details_price.ec_details_no_vat_price > .ec_product_sale_price_' + product_id + '_' + rand_id ).each( function( ){ jQuery( this ).html( ec_details_format_money_v2( product_id, rand_id, new_price / vat_rate_multiplier ) ); } ); jQuery( '.ec_details_price.ec_details_vat_price > .ec_product_sale_price_' + product_id + '_' + rand_id ).each( function( ){ jQuery( this ).html( ec_details_format_money_v2( product_id, rand_id, new_price ) ); } ); jQuery( '.ec_details_price.ec_details_no_vat_price > .ec_product_price_' + product_id + '_' + rand_id ).each( function( ){ jQuery( this ).html( ec_details_format_money_v2( product_id, rand_id, new_price / vat_rate_multiplier ) ); } ); jQuery( '.ec_details_price.ec_details_vat_price > .ec_product_price_' + product_id + '_' + rand_id ).each( function( ){ jQuery( this ).html( ec_details_format_money_v2( product_id, rand_id, new_price ) ); } ); } } if( order_price != 0 ){ jQuery( '.ec_details_added_price_' + product_id + '_' + rand_id ).show( ); jQuery( document.getElementById( 'ec_added_price_' + product_id + '_' + rand_id ) ).html( ec_details_format_money_v2( product_id, rand_id, order_price ) ); }else{ jQuery( '.ec_details_added_price_' + product_id + '_' + rand_id ).hide( ); } ec_details_advanced_adjust_price( product_id, rand_id ); } function ec_details_advanced_conditional_logic( product_id, rand_id ) { var ec_advanced_logic_rules = window['ec_advanced_logic_rules_' + product_id + '_' + rand_id]; for( var i=0; i 0 ){ if( ec_advanced_logic_rules[i].show_field ){ jQuery( '.ec_details_option_row[data-product-option-id="' + ec_advanced_logic_rules[i].id + '"]' ).hide( ); }else{ jQuery( '.ec_details_option_row[data-product-option-id="' + ec_advanced_logic_rules[i].id + '"]' ).show( ); } if( ec_advanced_logic_rules[i].and_rules == 'AND' ){ var rules_match = true; for( var j=0; j option' ).each( function() { var optionitem_id_1 = jQuery( this ).attr( 'value' ); if ( window['varitation_data_' + product_id + '_' + rand_id ] && window['varitation_data_' + product_id + '_' + rand_id][optionitem_id_1 + '0000'] ) { var use_optionitem_quantity_tracking = jQuery( document.getElementById( 'use_optionitem_quantity_tracking_' + product_id + '_' + rand_id ) ).val(); if ( jQuery( document.getElementById( 'ec_allow_backorders_' + product_id + '_' + rand_id ) ).length && '1' == jQuery( document.getElementById( 'ec_allow_backorders_' + product_id + '_' + rand_id ) ).val() ) { use_optionitem_quantity_tracking = '0'; } if ( window['varitation_data_' + product_id + '_' + rand_id][optionitem_id_1 + '0000'].enabled && ( '0' == use_optionitem_quantity_tracking || ! window['varitation_data_' + product_id + '_' + rand_id][optionitem_id_1 + '0000'].tracking || window['varitation_data_' + product_id + '_' + rand_id][optionitem_id_1 + '0000'].quantity > 0 ) ) { jQuery( this ).show().attr( 'disabled', false ); } else { jQuery( this ).hide().attr( 'disabled', true ); } } else { jQuery( this ).show().attr( 'disabled', false ); } } ); } } function ec_option1_init_swatches( product_id, rand_id, swatch, optionitem_id_1 ){ if ( ! jQuery( 'select.ec_option2_' + product_id + '_' + rand_id ).length && ! jQuery( 'li.ec_option2_' + product_id + '_' + rand_id ).length ) { if ( window['varitation_data_' + product_id + '_' + rand_id ] && window['varitation_data_' + product_id + '_' + rand_id][optionitem_id_1 + '0000'] ) { var use_optionitem_quantity_tracking = jQuery( document.getElementById( 'use_optionitem_quantity_tracking_' + product_id + '_' + rand_id ) ).val(); if ( jQuery( document.getElementById( 'allow_backorders' ) ).length && '1' == jQuery( document.getElementById( 'allow_backorders' ) ) ) { use_optionitem_quantity_tracking = '0'; } if ( window['varitation_data_' + product_id + '_' + rand_id][optionitem_id_1 + '0000'].enabled && ( '0' == use_optionitem_quantity_tracking || ! window['varitation_data_' + product_id + '_' + rand_id][optionitem_id_1 + '0000'].tracking || window['varitation_data_' + product_id + '_' + rand_id][optionitem_id_1 + '0000'].quantity > 0 ) ) { swatch.addClass( 'ec_active' ).removeClass( 'ec_selected' ); } else if ( ! window['varitation_data_' + product_id + '_' + rand_id][optionitem_id_1 + '0000'].enabled ) { swatch.hide().removeClass( 'ec_active' ).removeClass( 'ec_selected' ); } else { swatch.removeClass( 'ec_active' ).removeClass( 'ec_selected' ); } } else { swatch.addClass( 'ec_active' ).removeClass( 'ec_selected' ); } } } function ec_option1_updated( product_id, rand_id, optionitem_id_1 ) { if ( jQuery( 'select.ec_option2_' + product_id + '_' + rand_id ).length ) { if ( ! jQuery( 'select.ec_option2_' + product_id + '_' + rand_id + '_backup' ).length ) { jQuery( '' ).insertBefore( 'select.ec_option2_' + product_id + '_' + rand_id ); var options_copy = jQuery( 'select.ec_option2_' + product_id + '_' + rand_id + ' > option' ).clone(); jQuery( 'select.ec_option2_' + product_id + '_' + rand_id + '_backup' ).append( options_copy ); } else { jQuery ( 'select.ec_option2_' + product_id + '_' + rand_id + ' > option' ).remove(); var options_backup_copy = jQuery ( 'select.ec_option2_' + product_id + '_' + rand_id + '_backup > option' ).clone(); jQuery ( 'select.ec_option2_' + product_id + '_' + rand_id ).append( options_backup_copy ); } jQuery ( 'select.ec_option2_' + product_id + '_' + rand_id + ' > option' ).each( function() { if ( window['varitation_data_' + product_id + '_' + rand_id ] && window['varitation_data_' + product_id + '_' + rand_id][optionitem_id_1 + jQuery( this ).attr( 'value' ) + '000'] ) { if ( window['varitation_data_' + product_id + '_' + rand_id ] && window['varitation_data_' + product_id + '_' + rand_id][optionitem_id_1 + jQuery( this ).attr( 'value' ) + '000'].enabled ) { jQuery( this ).show().attr( 'disabled', false ); } else { jQuery( this ).remove(); } } else { jQuery( this ).show().attr( 'disabled', false ); } } ); } else if ( jQuery( 'li.ec_option2_' + product_id + '_' + rand_id ).length ) { jQuery ( 'li.ec_option2_' + product_id + '_' + rand_id ).each( function() { 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'] ) { 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 ) { jQuery( this ).addClass( 'ec_active' ); } else { if ( jQuery( this ).hasClass( 'ec_selected' ) ) { jQuery( '.ec_details_option_label_selected_2' ).html( '' ); } jQuery( this ).removeClass( 'ec_active' ).removeClass( 'ec_selected' ); } } else { jQuery( this ).addClass( 'ec_active' ); } } ); } } function ec_option1_selected( product_id, rand_id, optionitem_id_1, quantity ){ var variation = false; if ( window['varitation_data_' + product_id + '_' + rand_id ] && window['varitation_data_' + product_id + '_' + rand_id][optionitem_id_1 + '0000'] ) { variation = window['varitation_data_' + product_id + '_' + rand_id][optionitem_id_1 + '0000']; } if( variation ) { quantity = ( variation.tracking ) ? variation.quantity : 'inf'; quantity = ( variation.enabled ) ? quantity : 0; } var use_optionitem_images = jQuery( document.getElementById( 'use_optionitem_images_' + product_id + '_' + rand_id ) ).val(); if( '1' == use_optionitem_images ){ jQuery( '.ec_details_thumbnails_' + product_id + '_' + rand_id ).addClass( 'ec_inactive' ); jQuery( '.ec_details_large_popup_thumbnails_' + product_id + '_' + rand_id ).addClass( 'ec_inactive' ); jQuery( document.getElementById( 'ec_details_thumbnails_' + optionitem_id_1 + '_' + product_id + '_' + rand_id ) ).find( '.ec_details_thumbnail' ).first( ).trigger( 'click' ); if( !jQuery( document.getElementById( 'ec_details_thumbnails_' + optionitem_id_1 + '_' + product_id + '_' + rand_id ) ).hasClass( 'ec_no_thumbnails' ) ){ jQuery( document.getElementById( 'ec_details_thumbnails_' + optionitem_id_1 + '_' + product_id + '_' + rand_id ) ).removeClass( 'ec_inactive' ); jQuery( document.getElementById( 'ec_details_large_popup_thumbnails_' + optionitem_id_1 + '_' + product_id + '_' + rand_id ) ).removeClass( 'ec_inactive' ); } } 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' ); 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' ); 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' ); 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' ); jQuery( '.ec_details_combo.ec_option2_' + product_id + '_' + rand_id ).val( '0' ).prop( 'disabled', true ).addClass( 'ec_inactive' ); jQuery( '.ec_details_combo.ec_option3_' + product_id + '_' + rand_id ).val( '0' ).prop( 'disabled', true ).addClass( 'ec_inactive' ); jQuery( '.ec_details_combo.ec_option4_' + product_id + '_' + rand_id ).val( '0' ).prop( 'disabled', true ).addClass( 'ec_inactive' ); jQuery( '.ec_details_combo.ec_option5_' + product_id + '_' + rand_id ).val( '0' ).prop( 'disabled', true ).addClass( 'ec_inactive' ); 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( '' ); jQuery( document.getElementById( 'ec_details_stock_quantity_' + product_id + '_' + rand_id ) ).html( quantity ); if ( 'inf' != quantity ) { jQuery( '.ec_details_stock_total' ).show(); } else { jQuery( '.ec_details_stock_total' ).hide(); } jQuery( document.getElementById('ec_quantity_' + product_id + '_' + rand_id ) ).attr( 'max', quantity ); if( Number( jQuery( document.getElementById('ec_quantity_' + product_id + '_' + rand_id ) ).val( ) ) > Number( quantity ) ){ jQuery( document.getElementById('ec_quantity_' + product_id + '_' + rand_id ) ).val( quantity ); } jQuery( document.getElementById( 'ec_option_loading_2_' + product_id + '_' + rand_id ) ).show( ); 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 ); if( next_options.length ){ next_options.each( function( ){ jQuery( this ).show().removeClass( 'ec_active' ).removeClass( 'ec_disabled_variant' ).addClass( 'ec_no_data_variant' ); } ); var data = { action: 'ec_ajax_get_optionitem_quantities', optionitem_id_1: optionitem_id_1, product_id: product_id, nonce: jQuery( document.getElementById( 'product_details_nonce_' + product_id + '_' + rand_id ) ).val() }; jQuery.ajax( { url: wpeasycart_ajax_object.ajax_url, type: 'post', data: data, success: function( data ){ var json_data = JSON.parse( data ); jQuery( document.getElementById( 'ec_option_loading_2_' + product_id + '_' + rand_id ) ).hide( ); var found_i = -1; next_options.each( function( ){ for ( var i = 0; i < json_data.length && -1 == found_i; i++ ) { if ( jQuery( this ).attr( 'data-optionitem-id' ) == json_data[i].optionitem_id ) { found_i = i; } } if ( -1 != found_i && found_i < json_data.length ) { jQuery( this ).attr( 'data-optionitem-quantity', json_data[ found_i ].quantity ); if ( ! json_data[ found_i ].is_enabled ) { jQuery( this ).show().addClass( 'ec_disabled_variant' ).removeClass( 'ec_no_data_variant' ); } else if( json_data[ found_i ].quantity > 0 || '0' == json_data[ found_i ].tracking ){ jQuery( this ).show().addClass( 'ec_active' ).removeClass( 'ec_no_data_variant' ); } var subitem_variation = false; 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'] ) { subitem_variation = window['varitation_data_' + product_id + '_' + rand_id][optionitem_id_1 + jQuery( this ).attr( 'data-optionitem-id' ) + '000']; } if( subitem_variation ) { if ( ! subitem_variation.enabled ) { jQuery( this ).hide(); } } } found_i = -1; } ); } } ); }else{ next_options = jQuery( '.ec_details_combo.ec_option2_' + product_id + '_' + rand_id + ' option' ); next_options.each( function( ){ jQuery( this ).removeClass( 'ec_active' ); } ); var data = { action: 'ec_ajax_get_optionitem_quantities', optionitem_id_1: optionitem_id_1, product_id: product_id, nonce: jQuery( document.getElementById( 'product_details_nonce_' + product_id + '_' + rand_id ) ).val() }; jQuery.ajax( { url: wpeasycart_ajax_object.ajax_url, type: 'post', data: data, success: function( data ){ jQuery( '.ec_details_combo.ec_option2_' + product_id + '_' + rand_id ).prop( 'disabled', false ).removeClass( 'ec_inactive' ); var json_data = JSON.parse( data ); jQuery( document.getElementById( 'ec_option_loading_2_' + product_id + '_' + rand_id ) ).hide( ); var found_i = -1; next_options.each( function( ){ for ( var i = 0; i < json_data.length && -1 == found_i; i++ ) { if ( jQuery( this ).val( ) == json_data[i].optionitem_id ) { found_i = i; } } if ( -1 != found_i && found_i < json_data.length ) { jQuery( this ).attr( 'data-optionitem-quantity', ( ( '1' == json_data[ found_i ].tracking ) ? json_data[ found_i ].quantity : 'inf' ) ); if( json_data[ found_i ].quantity > 0 || '0' == json_data[ found_i ].tracking ){ jQuery( this ).show().attr( 'disabled', false ); } else { jQuery( this ).hide().attr( 'disabled', true ); } var subitem_variation = false; if ( window['varitation_data_' + product_id + '_' + rand_id ] && window['varitation_data_' + product_id + '_' + rand_id][optionitem_id_1 + jQuery( this ).val() + '000'] ) { subitem_variation = window['varitation_data_' + product_id + '_' + rand_id][optionitem_id_1 + jQuery( this ).val() + '000']; } if( subitem_variation ) { if ( ! subitem_variation.enabled ) { jQuery( this ).hide().prop( 'disabled', true ); } } } else { jQuery( this ).attr( 'data-optionitem-quantity', 0 ).hide().attr( 'disabled', true ); } found_i = -1; } ); } } ); } } function ec_option2_updated( product_id, rand_id, optionitem_id_1, optionitem_id_2 ) { if ( jQuery( 'select.ec_option3_' + product_id + '_' + rand_id ).length ) { if ( ! jQuery( 'select.ec_option3_' + product_id + '_' + rand_id + '_backup' ).length ) { jQuery( '' ).insertBefore( 'select.ec_option3_' + product_id + '_' + rand_id ); var options_copy = jQuery( 'select.ec_option3_' + product_id + '_' + rand_id + ' > option' ).clone(); jQuery( 'select.ec_option3_' + product_id + '_' + rand_id + '_backup' ).append( options_copy ); } else { jQuery ( 'select.ec_option3_' + product_id + '_' + rand_id + ' > option' ).remove(); var options_backup_copy = jQuery ( 'select.ec_option3_' + product_id + '_' + rand_id + '_backup > option' ).clone(); jQuery ( 'select.ec_option3_' + product_id + '_' + rand_id ).append( options_backup_copy ); } jQuery ( 'select.ec_option3_' + product_id + '_' + rand_id + ' > option' ).each( function() { 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'] ) { 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 ) { jQuery( this ).show().attr( 'disabled', false ); } else { jQuery( this ).remove(); } } else { jQuery( this ).show().attr( 'disabled', false ); } } ); } else if ( jQuery( 'li.ec_option3_' + product_id + '_' + rand_id ).length ) { jQuery ( 'li.ec_option3_' + product_id + '_' + rand_id ).each( function() { 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'] ) { 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 ) { jQuery( this ).addClass( 'ec_active' ); } else { if ( jQuery( this ).hasClass( 'ec_selected' ) ) { jQuery( '.ec_details_option_label_selected_3' ).html( '' ); } jQuery( this ).removeClass( 'ec_active' ).removeClass( 'ec_selected' ); } } else { jQuery( this ).addClass( 'ec_active' ); } } ); } } function option2_selected( product_id, rand_id, optionitem_id_1, optionitem_id_2, quantity ){ var variation = false; if ( window['varitation_data_' + product_id + '_' + rand_id ] && window['varitation_data_' + product_id + '_' + rand_id][optionitem_id_1 + optionitem_id_2 + '000'] ) { variation = window['varitation_data_' + product_id + '_' + rand_id][optionitem_id_1 + optionitem_id_2 + '000']; } if( variation ) { quantity = ( variation.tracking ) ? variation.quantity : 'inf'; quantity = ( variation.enabled ) ? quantity : 0; } 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' ); 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' ); 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' ); jQuery( '.ec_details_combo.ec_option3_' + product_id + '_' + rand_id ).val( '0' ).prop( 'disabled', true ).addClass( 'ec_inactive' ); jQuery( '.ec_details_combo.ec_option4_' + product_id + '_' + rand_id ).val( '0' ).prop( 'disabled', true ).addClass( 'ec_inactive' ); jQuery( '.ec_details_combo.ec_option5_' + product_id + '_' + rand_id ).val( '0' ).prop( 'disabled', true ).addClass( 'ec_inactive' ); jQuery( '.ec_details_option_label_selected_3, .ec_details_option_label_selected_4, .ec_details_option_label_selected_5' ).html( '' ); jQuery( '.ec_option2_' + product_id + '_' + rand_id + '.ec_details_option_row_error' ).hide( ); jQuery( document.getElementById( 'ec_details_stock_quantity_' + product_id + '_' + rand_id ) ).html( quantity ); if ( 'inf' != quantity ) { jQuery( '.ec_details_stock_total' ).show(); } else { jQuery( '.ec_details_stock_total' ).hide(); } jQuery( document.getElementById('ec_quantity_' + product_id + '_' + rand_id ) ).attr( 'max', quantity ); if( Number( jQuery( document.getElementById('ec_quantity_' + product_id + '_' + rand_id ) ).val( ) ) > Number( quantity ) ){ jQuery( document.getElementById('ec_quantity_' + product_id + '_' + rand_id ) ).val( quantity ); } 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 ); jQuery( document.getElementById( 'ec_option_loading_3_' + product_id + '_' + rand_id ) ).show( ); if( next_options.length ){ next_options.each( function( ){ jQuery( this ).show().removeClass( 'ec_active' ).removeClass( 'ec_disabled_variant' ).addClass( 'ec_no_data_variant' ); } ); var data = { action: 'ec_ajax_get_optionitem_quantities', optionitem_id_1: optionitem_id_1, optionitem_id_2: optionitem_id_2, product_id: product_id, nonce: jQuery( document.getElementById( 'product_details_nonce_' + product_id + '_' + rand_id ) ).val() }; jQuery.ajax( { url: wpeasycart_ajax_object.ajax_url, type: 'post', data: data, success: function( data ){ var json_data = JSON.parse( data ); jQuery( document.getElementById( 'ec_option_loading_3_' + product_id + '_' + rand_id ) ).hide( ); var found_i = -1; next_options.each( function( ){ for ( var i = 0; i < json_data.length && -1 == found_i; i++ ) { if ( jQuery( this ).attr( 'data-optionitem-id' ) == json_data[i].optionitem_id ) { found_i = i; } } if ( -1 != found_i && found_i < json_data.length ){ jQuery( this ).attr( 'data-optionitem-quantity', json_data[ found_i ].quantity ); if ( ! json_data[ found_i ].is_enabled ) { jQuery( this ).show().addClass( 'ec_disabled_variant' ).removeClass( 'ec_no_data_variant' ); } else if( json_data[ found_i ].quantity > 0 || '0' == json_data[ found_i ].tracking ){ jQuery( this ).show().addClass( 'ec_active' ).removeClass( 'ec_no_data_variant' ); } var subitem_variation = false; 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'] ) { subitem_variation = window['varitation_data_' + product_id + '_' + rand_id][optionitem_id_1 + optionitem_id_2 + jQuery( this ).attr( 'data-optionitem-id' ) + '00']; } if( subitem_variation ) { if ( ! subitem_variation.enabled ) { jQuery( this ).hide(); } } } found_i = -1; } ); } } ); }else{ next_options = jQuery( '.ec_details_combo.ec_option3_' + product_id + '_' + rand_id + ' option' ); next_options.each( function( ){ jQuery( this ).removeClass( 'ec_active' ); } ); var data = { action: 'ec_ajax_get_optionitem_quantities', optionitem_id_1: optionitem_id_1, optionitem_id_2: optionitem_id_2, product_id: product_id, nonce: jQuery( document.getElementById( 'product_details_nonce_' + product_id + '_' + rand_id ) ).val() }; jQuery.ajax( { url: wpeasycart_ajax_object.ajax_url, type: 'post', data: data, success: function( data ){ jQuery( '.ec_details_combo.ec_option3_' + product_id + '_' + rand_id ).prop( 'disabled', false ).removeClass( 'ec_inactive' ); var json_data = JSON.parse( data ); jQuery( document.getElementById( 'ec_option_loading_3_' + product_id + '_' + rand_id ) ).hide( ); var found_i = -1; next_options.each( function( ){ for ( var i = 0; i < json_data.length && -1 == found_i; i++ ) { if ( jQuery( this ).val() == json_data[i].optionitem_id ) { found_i = i; } } if ( -1 != found_i && found_i < json_data.length ) { jQuery( this ).attr( 'data-optionitem-quantity', ( ( '1' == json_data[ found_i ].tracking ) ? json_data[ found_i ].quantity : 'inf' ) ); if( json_data[ found_i ].quantity > 0 || '0' == json_data[ found_i ].tracking ){ jQuery( this ).show().attr( 'disabled', false ); } else { jQuery( this ).hide().attr( 'disabled', true ); } var subitem_variation = false; 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'] ) { subitem_variation = window['varitation_data_' + product_id + '_' + rand_id][optionitem_id_1 + optionitem_id_2 + jQuery( this ).val() + '00']; } if( subitem_variation ) { if ( ! subitem_variation.enabled ) { jQuery( this ).hide().prop( 'disabled', true ); } } } else { jQuery( this ).attr( 'data-optionitem-quantity', 0 ).hide().attr( 'disabled', true ); } found_i = -1; } ); } } ); } } function ec_option3_updated( product_id, rand_id, optionitem_id_1, optionitem_id_2, optionitem_id_3 ) { if ( jQuery( 'select.ec_option4_' + product_id + '_' + rand_id ).length ) { if ( ! jQuery( 'select.ec_option4_' + product_id + '_' + rand_id + '_backup' ).length ) { jQuery( '' ).insertBefore( 'select.ec_option4_' + product_id + '_' + rand_id ); var options_copy = jQuery( 'select.ec_option4_' + product_id + '_' + rand_id + ' > option' ).clone(); jQuery( 'select.ec_option4_' + product_id + '_' + rand_id + '_backup' ).append( options_copy ); } else { jQuery ( 'select.ec_option4_' + product_id + '_' + rand_id + ' > option' ).remove(); var options_backup_copy = jQuery ( 'select.ec_option4_' + product_id + '_' + rand_id + '_backup > option' ).clone(); jQuery ( 'select.ec_option4_' + product_id + '_' + rand_id ).append( options_backup_copy ); } jQuery ( 'select.ec_option4_' + product_id + '_' + rand_id + ' > option' ).each( function() { 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'] ) { 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 ) { jQuery( this ).show().attr( 'disabled', false ); } else { jQuery( this ).remove(); } } else { jQuery( this ).show().attr( 'disabled', false ); } } ); } else if ( jQuery( 'li.ec_option4_' + product_id + '_' + rand_id ).length ) { jQuery ( 'li.ec_option4_' + product_id + '_' + rand_id ).each( function() { 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'] ) { 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 ) { jQuery( this ).addClass( 'ec_active' ); } else { if ( jQuery( this ).hasClass( 'ec_selected' ) ) { jQuery( '.ec_details_option_label_selected_4' ).html( '' ); } jQuery( this ).removeClass( 'ec_active' ).removeClass( 'ec_selected' ); } } else { jQuery( this ).addClass( 'ec_active' ); } } ); } } function option3_selected( product_id, rand_id, optionitem_id_1, optionitem_id_2, optionitem_id_3, quantity ){ var variation = false; 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'] ) { variation = window['varitation_data_' + product_id + '_' + rand_id][optionitem_id_1 + optionitem_id_2 + optionitem_id_3 + '00']; } if( variation ) { quantity = ( variation.tracking ) ? variation.quantity : 'inf'; quantity = ( variation.enabled ) ? quantity : 0; } 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' ); 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' ); jQuery( '.ec_details_combo.ec_option4_' + product_id + '_' + rand_id ).val( '0' ).prop( 'disabled', true ).addClass( 'ec_inactive' ); jQuery( '.ec_details_combo.ec_option5_' + product_id + '_' + rand_id ).val( '0' ).prop( 'disabled', true ).addClass( 'ec_inactive' ); jQuery( '.ec_details_option_label_selected_4, .ec_details_option_label_selected_5' ).html( '' ); jQuery( '.ec_option3_' + product_id + '_' + rand_id + '.ec_details_option_row_error' ).hide( ); jQuery( document.getElementById( 'ec_details_stock_quantity_' + product_id + '_' + rand_id ) ).html( quantity ); if ( 'inf' != quantity ) { jQuery( '.ec_details_stock_total' ).show(); } else { jQuery( '.ec_details_stock_total' ).hide(); } jQuery( document.getElementById('ec_quantity_' + product_id + '_' + rand_id ) ).attr( 'max', quantity ); if( Number( jQuery( document.getElementById('ec_quantity_' + product_id + '_' + rand_id ) ).val( ) ) > Number( quantity ) ){ jQuery( document.getElementById('ec_quantity_' + product_id + '_' + rand_id ) ).val( quantity ); } 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 ); jQuery( document.getElementById( 'ec_option_loading_4_' + product_id + '_' + rand_id ) ).show( ); if( next_options.length ){ next_options.each( function( ){ jQuery( this ).show().removeClass( 'ec_active' ).removeClass( 'ec_disabled_variant' ).addClass( 'ec_no_data_variant' ); } ); var data = { action: 'ec_ajax_get_optionitem_quantities', optionitem_id_1: optionitem_id_1, optionitem_id_2: optionitem_id_2, optionitem_id_3: optionitem_id_3, product_id: product_id, nonce: jQuery( document.getElementById( 'product_details_nonce_' + product_id + '_' + rand_id ) ).val() }; jQuery.ajax( { url: wpeasycart_ajax_object.ajax_url, type: 'post', data: data, success: function( data ){ var json_data = JSON.parse( data ); jQuery( document.getElementById( 'ec_option_loading_4_' + product_id + '_' + rand_id ) ).hide( ); var found_i = -1; next_options.each( function( ){ for ( var i = 0; i < json_data.length && -1 == found_i; i++ ) { if ( jQuery( this ).attr( 'data-optionitem-id' ) == json_data[i].optionitem_id ) { found_i = i; } } if ( -1 != found_i && found_i < json_data.length > found_i ){ jQuery( this ).attr( 'data-optionitem-quantity', json_data[ found_i ].quantity ); if ( ! json_data[ found_i ].is_enabled ) { jQuery( this ).show().addClass( 'ec_disabled_variant' ).removeClass( 'ec_no_data_variant' ); } else if( json_data[ found_i ].quantity > 0 || '0' == json_data[ found_i ].tracking ){ jQuery( this ).show().addClass( 'ec_active' ).removeClass( 'ec_no_data_variant' ); } var subitem_variation = false; 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'] ) { 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']; } if( subitem_variation ) { if ( ! subitem_variation.enabled ) { jQuery( this ).hide(); } } } found_i = -1; } ); } } ); }else{ next_options = jQuery( '.ec_details_combo.ec_option4_' + product_id + '_' + rand_id + ' option' ); next_options.each( function( ){ jQuery( this ).removeClass( 'ec_active' ); } ); var data = { action: 'ec_ajax_get_optionitem_quantities', optionitem_id_1: optionitem_id_1, optionitem_id_2: optionitem_id_2, optionitem_id_3: optionitem_id_3, product_id: product_id, nonce: jQuery( document.getElementById( 'product_details_nonce_' + product_id + '_' + rand_id ) ).val() }; jQuery.ajax( { url: wpeasycart_ajax_object.ajax_url, type: 'post', data: data, success: function( data ){ jQuery( '.ec_details_combo.ec_option4_' + product_id + '_' + rand_id ).prop( 'disabled', false ).removeClass( 'ec_inactive' ); var json_data = JSON.parse( data ); jQuery( document.getElementById( 'ec_option_loading_4_' + product_id + '_' + rand_id ) ).hide( ); var found_i = -1; next_options.each( function( ){ for ( var i = 0; i < json_data.length && -1 == found_i; i++ ) { if ( jQuery( this ).val() == json_data[i].optionitem_id ) { found_i = i; } } if ( -1 != found_i && found_i < json_data.length ) { jQuery( this ).attr( 'data-optionitem-quantity', ( ( '1' == json_data[ found_i ].tracking ) ? json_data[ found_i ].quantity : 'inf' ) ); if( json_data[ found_i ].quantity > 0 || '0' == json_data[ found_i ].tracking ){ jQuery( this ).show().attr( 'disabled', false ); } else { jQuery( this ).hide().attr( 'disabled', true ); } var subitem_variation = false; 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'] ) { subitem_variation = window['varitation_data_' + product_id + '_' + rand_id][optionitem_id_1 + optionitem_id_2 + optionitem_id_3 + jQuery( this ).val() + '0']; } if( subitem_variation ) { if ( ! subitem_variation.enabled ) { jQuery( this ).hide().prop( 'disabled', true ); } } }else{ jQuery( this ).attr( 'data-optionitem-quantity', 0 ).hide().attr( 'disabled', true ); } found_i = -1; } ); } } ); } } function ec_option4_updated( product_id, rand_id, optionitem_id_1, optionitem_id_2, optionitem_id_3, optionitem_id_4 ) { if ( jQuery( 'select.ec_option5_' + product_id + '_' + rand_id ).length ) { if ( ! jQuery( 'select.ec_option5_' + product_id + '_' + rand_id + '_backup' ).length ) { jQuery( '' ).insertBefore( 'select.ec_option5_' + product_id + '_' + rand_id ); var options_copy = jQuery( 'select.ec_option5_' + product_id + '_' + rand_id + ' > option' ).clone(); jQuery( 'select.ec_option5_' + product_id + '_' + rand_id + '_backup' ).append( options_copy ); } else { jQuery ( 'select.ec_option5_' + product_id + '_' + rand_id + ' > option' ).remove(); var options_backup_copy = jQuery ( 'select.ec_option5_' + product_id + '_' + rand_id + '_backup > option' ).clone(); jQuery ( 'select.ec_option5_' + product_id + '_' + rand_id ).append( options_backup_copy ); } jQuery ( 'select.ec_option5_' + product_id + '_' + rand_id + ' > option' ).each( function() { 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' )] ) { 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 ) { jQuery( this ).show().attr( 'disabled', false ); } else { jQuery( this ).remove(); } } else { jQuery( this ).show().attr( 'disabled', false ); } } ); } else if ( jQuery( 'li.ec_option5_' + product_id + '_' + rand_id ).length ) { jQuery ( 'li.ec_option5_' + product_id + '_' + rand_id ).each( function() { 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' )] ) { 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 ) { jQuery( this ).addClass( 'ec_active' ); } else { if ( jQuery( this ).hasClass( 'ec_selected' ) ) { jQuery( '.ec_details_option_label_selected_5' ).html( '' ); } jQuery( this ).removeClass( 'ec_active' ).removeClass( 'ec_selected' ); } } else { jQuery( this ).addClass( 'ec_active' ); } } ); } } function option4_selected( product_id, rand_id, optionitem_id_1, optionitem_id_2, optionitem_id_3, optionitem_id_4, quantity ){ var variation = false; 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'] ) { variation = window['varitation_data_' + product_id + '_' + rand_id][optionitem_id_1 + optionitem_id_2 + optionitem_id_3 + optionitem_id_4 + '0']; } if( variation ) { quantity = ( variation.tracking ) ? variation.quantity : 'inf'; quantity = ( variation.enabled ) ? quantity : 0; } 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' ); jQuery( '.ec_details_combo.ec_option5_' + product_id + '_' + rand_id ).val( '0' ).prop( 'disabled', true ).addClass( 'ec_inactive' ); jQuery( '.ec_details_option_label_selected_5' ).html( '' ); jQuery( '.ec_option4.ec_details_option_row_error' ).hide( ); jQuery( document.getElementById( 'ec_details_stock_quantity_' + product_id + '_' + rand_id ) ).html( quantity ); if ( 'inf' != quantity ) { jQuery( '.ec_details_stock_total' ).show(); } else { jQuery( '.ec_details_stock_total' ).hide(); } jQuery( document.getElementById('ec_quantity_' + product_id + '_' + rand_id ) ).attr( 'max', quantity ); if( Number( jQuery( document.getElementById('ec_quantity_' + product_id + '_' + rand_id ) ).val( ) ) > Number( quantity ) ){ jQuery( document.getElementById('ec_quantity_' + product_id + '_' + rand_id ) ).val( quantity ); } 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 ); jQuery( document.getElementById( 'ec_option_loading_5_' + product_id + '_' + rand_id ) ).show( ); if( next_options.length ){ next_options.each( function( ){ jQuery( this ).show().removeClass( 'ec_active' ).removeClass( 'ec_disabled_variant' ).addClass( 'ec_no_data_variant' ) } ); var data = { action: 'ec_ajax_get_optionitem_quantities', optionitem_id_1: optionitem_id_1, optionitem_id_2: optionitem_id_2, optionitem_id_3: optionitem_id_3, optionitem_id_4: optionitem_id_4, product_id: product_id, nonce: jQuery( document.getElementById( 'product_details_nonce_' + product_id + '_' + rand_id ) ).val() }; jQuery.ajax( { url: wpeasycart_ajax_object.ajax_url, type: 'post', data: data, success: function( data ){ var json_data = JSON.parse( data ); jQuery( document.getElementById( 'ec_option_loading_5_' + product_id + '_' + rand_id ) ).hide( ); var found_i = -1; next_options.each( function( ){ for ( var i = 0; i < json_data.length && -1 == found_i; i++ ) { if ( jQuery( this ).attr( 'data-optionitem-id' ) == json_data[i].optionitem_id ) { found_i = i; } } if ( -1 != found_i && found_i < json_data.length > found_i ){ jQuery( this ).attr( 'data-optionitem-quantity', json_data[i].quantity ); if ( ! json_data[ found_i ].is_enabled ) { jQuery( this ).show().addClass( 'ec_disabled_variant' ).removeClass( 'ec_no_data_variant' ); } else if( json_data[i].quantity > 0 || '0' == json_data[i].tracking ){ jQuery( this ).show().addClass( 'ec_active' ).removeClass( 'ec_no_data_variant' ); } i++; var subitem_variation = false; 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' ) ] ) { 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' ) ]; } if( subitem_variation ) { if ( ! subitem_variation.enabled ) { jQuery( this ).hide(); } } } found_i = -1; } ); } } ); }else{ next_options = jQuery( '.ec_details_combo.ec_option5_' + product_id + '_' + rand_id + ' option' ); next_options.each( function( ){ jQuery( this ).removeClass( 'ec_active' ); } ); var data = { action: 'ec_ajax_get_optionitem_quantities', optionitem_id_1: optionitem_id_1, optionitem_id_2: optionitem_id_2, optionitem_id_3: optionitem_id_3, optionitem_id_4: optionitem_id_4, product_id: product_id, nonce: jQuery( document.getElementById( 'product_details_nonce_' + product_id + '_' + rand_id ) ).val() }; jQuery.ajax( { url: wpeasycart_ajax_object.ajax_url, type: 'post', data: data, success: function( data ){ jQuery( '.ec_details_combo.ec_option5_' + product_id + '_' + rand_id ).prop( 'disabled', false ).removeClass( 'ec_inactive' ); var json_data = JSON.parse( data ); jQuery( document.getElementById( 'ec_option_loading_5_' + product_id + '_' + rand_id ) ).hide( ); var found_i = -1; next_options.each( function( ){ for ( var i = 0; i < json_data.length && -1 == found_i; i++ ) { if ( jQuery( this ).val() == json_data[i].optionitem_id ) { found_i = i; } } if ( -1 != found_i && found_i < json_data.length ) { jQuery( this ).attr( 'data-optionitem-quantity', ( ( '1' == json_data[ found_i ].tracking ) ? json_data[ found_i ].quantity : 'inf' ) ); if( json_data[ found_i ].quantity > 0 || '0' == json_data[ found_i ].tracking ){ jQuery( this ).show().attr( 'disabled', false ); } else { jQuery( this ).hide().attr( 'disabled', true ); } i++; var subitem_variation = false; 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() ] ) { subitem_variation = window['varitation_data_' + product_id + '_' + rand_id][optionitem_id_1 + optionitem_id_2 + optionitem_id_3 + optionitem_id_4 + jQuery( this ).val() ]; } if( subitem_variation ) { if ( ! subitem_variation.enabled ) { jQuery( this ).hide().prop( 'disabled', true ); } } } else { jQuery( this ).attr( 'data-optionitem-quantity', 0 ).hide().attr( 'disabled', true ); } found_i = -1; } ); } } ); } } function ec_details_submit_inquiry( product_id, rand_id ){ var errors = 0; if( document.getElementById( 'ec_inquiry_name_' + product_id + '_' + rand_id ) ){ 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( ) == "" ){ jQuery( document.getElementById( 'ec_details_inquiry_error_' + product_id + '_' + rand_id ) ).show( ); errors++; }else{ jQuery( document.getElementById( 'ec_details_inquiry_error_' + product_id + '_' + rand_id ) ).hide( ); } } if( jQuery( document.getElementById( 'ec_grecaptcha_response_inquiry' ) ).length ){ var recaptcha_response = jQuery( document.getElementById( 'ec_grecaptcha_response_inquiry' ) ).val( ); if( !recaptcha_response.length ){ jQuery( '#ec_product_details_inquiry_recaptcha > div' ).css( 'border', '1px solid red' ); errors++; }else{ jQuery( '#ec_product_details_inquiry_recaptcha > div' ).css( 'border', 'none' ); } } if( ! ec_details_add_to_cart( product_id, rand_id ) ){ errors++; } if( errors > 0 ) { return false; } else { jQuery( document.getElementById( 'ec_inquiry_loader_' + product_id + '_' + rand_id ) ).show( ); jQuery( document.getElementById( 'ec_inquiry_loader_bg_' + product_id + '_' + rand_id ) ).show( ); return true; } } function ec_details_add_to_cart( product_id, rand_id ) { var errors = 0; // Basic Option 1 Error Check 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' ) ){ jQuery( '.ec_option1_' + product_id + '_' + rand_id + '.ec_details_option_row_error' ).show( ); errors++; }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' ) ){ jQuery( '.ec_option1_' + product_id + '_' + rand_id + '.ec_details_option_row_error' ).show( ); errors++; }else{ jQuery( '.ec_option1_' + product_id + '_' + rand_id + '.ec_details_option_row_error' ).hide( ); } // Basic Option 2 Error Check 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' ) ){ jQuery( '.ec_option2_' + product_id + '_' + rand_id + '.ec_details_option_row_error' ).show( ); errors++; }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' ) ){ jQuery( '.ec_option2_' + product_id + '_' + rand_id + '.ec_details_option_row_error' ).show( ); errors++; }else{ jQuery( '.ec_option2_' + product_id + '_' + rand_id + '.ec_details_option_row_error' ).hide( ); } // Basic Option 3 Error Check 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' ) ){ jQuery( '.ec_option3_' + product_id + '_' + rand_id + '.ec_details_option_row_error' ).show( ); errors++; }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' ) ){ jQuery( '.ec_option3_' + product_id + '_' + rand_id + '.ec_details_option_row_error' ).show( ); errors++; }else{ jQuery( '.ec_option3_' + product_id + '_' + rand_id + '.ec_details_option_row_error' ).hide( ); } // Basic Option 4 Error Check 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' ) ){ jQuery( '.ec_option4_' + product_id + '_' + rand_id + '.ec_details_option_row_error' ).show( ); errors++; }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' ) ){ jQuery( '.ec_option4_' + product_id + '_' + rand_id + '.ec_details_option_row_error' ).show( ); errors++; }else{ jQuery( '.ec_option4_' + product_id + '_' + rand_id + '.ec_details_option_row_error' ).hide( ); } // Basic Option 5 Error Check 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' ) ){ jQuery( '.ec_option5_' + product_id + '_' + rand_id + '.ec_details_option_row_error' ).show( ); errors++; }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' ) ){ jQuery( '.ec_option5_' + product_id + '_' + rand_id + '.ec_details_option_row_error' ).show( ); errors++; }else{ jQuery( '.ec_option5_' + product_id + '_' + rand_id + '.ec_details_option_row_error' ).hide( ); } // --------Advanced Option Checks---------- // // Select Box Check var advanced_select_rows = jQuery( '.ec_details_option_row.ec_option_type_combo:visible' ); advanced_select_rows.each( function( ){ if( jQuery( this ).attr( 'data-product-id' ) == product_id && jQuery( this ).attr( 'data-option-required' ) == '1' ){ // Option is Required if( jQuery( document.getElementById( 'ec_option_adv_' + jQuery( this ).attr( 'data-product-option-id' ) + '_' + product_id + '_' + rand_id ) ).val( ) == '0' ){ jQuery( document.getElementById( 'ec_details_adv_option_row_error_' + jQuery( this ).attr( 'data-product-option-id' ) + '_' + product_id + '_' + rand_id ) ).show( ); errors++; }else{ jQuery( document.getElementById( 'ec_details_adv_option_row_error_' + jQuery( this ).attr( 'data-product-option-id' ) + '_' + product_id + '_' + rand_id ) ).hide( ); } } } ); // Check Box Check var advanced_checkbox_rows = jQuery( '.ec_details_option_row.ec_option_type_checkbox:visible' ); advanced_checkbox_rows.each( function( ){ if( jQuery( this ).attr( 'data-product-id' ) == product_id && jQuery( this ).attr( 'data-option-required' ) == '1' ){ // Option is Required var selected_checkboxes = jQuery( "input.ec_option_adv_" + jQuery( this ).attr( 'data-product-option-id' ) + ":checked" ); if( selected_checkboxes.length ){ jQuery( document.getElementById( 'ec_details_adv_option_row_error_' + jQuery( this ).attr( 'data-product-option-id' ) + '_' + product_id + '_' + rand_id ) ).hide( ); }else{ jQuery( document.getElementById( 'ec_details_adv_option_row_error_' + jQuery( this ).attr( 'data-product-option-id' ) + '_' + product_id + '_' + rand_id ) ).show( ); errors++; } } } ); // Date Box Check var advanced_date_rows = jQuery( '.ec_details_option_row.ec_option_type_date:visible' ); advanced_date_rows.each( function( ){ if( jQuery( this ).attr( 'data-product-id' ) == product_id && jQuery( this ).attr( 'data-option-required' ) == '1' ){ // Option is Required if( jQuery( document.getElementById( 'ec_option_adv_' + jQuery( this ).attr( 'data-product-option-id' ) + '_' + product_id + '_' + rand_id ) ).val( ) == "" ){ jQuery( document.getElementById( 'ec_details_adv_option_row_error_' + jQuery( this ).attr( 'data-product-option-id' ) + '_' + product_id + '_' + rand_id ) ).show( ); errors++; }else{ jQuery( document.getElementById( 'ec_details_adv_option_row_error_' + jQuery( this ).attr( 'data-product-option-id' ) + '_' + product_id + '_' + rand_id ) ).hide( ); } } } ); // File Upload Check var advanced_file_rows = jQuery( '.ec_details_option_row.ec_option_type_file:visible' ); advanced_file_rows.each( function( ){ if( jQuery( this ).attr( 'data-product-id' ) == product_id && jQuery( this ).attr( 'data-option-required' ) == '1' ){ // Option is Required if( jQuery( document.getElementById( 'ec_option_adv_' + jQuery( this ).attr( 'data-product-option-id' ) + '_' + product_id + '_' + rand_id ) ).val( ) ){ jQuery( document.getElementById( 'ec_details_adv_option_row_error_' + jQuery( this ).attr( 'data-product-option-id' ) + '_' + product_id + '_' + rand_id ) ).hide( ); }else{ jQuery( document.getElementById( 'ec_details_adv_option_row_error_' + jQuery( this ).attr( 'data-product-option-id' ) + '_' + product_id + '_' + rand_id ) ).show( ); errors++; } } } ); // Swatch Check var advanced_swatch_rows = jQuery( '.ec_details_option_row.ec_option_type_swatch:visible' ); advanced_swatch_rows.each( function( ){ if( jQuery( this ).attr( 'data-product-id' ) == product_id && jQuery( this ).attr( 'data-option-required' ) == '1' ){ // Option is Required 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" ); if( advanced_selected_swatches.length ){ jQuery( document.getElementById( 'ec_details_adv_option_row_error_' + jQuery( this ).attr( 'data-product-option-id' ) + '_' + product_id + '_' + rand_id ) ).hide( ); }else{ jQuery( document.getElementById( 'ec_details_adv_option_row_error_' + jQuery( this ).attr( 'data-product-option-id' ) + '_' + product_id + '_' + rand_id ) ).show( ); errors++; } } } ); // Radio Button Check var advanced_radio_rows = jQuery( '.ec_details_option_row.ec_option_type_radio:visible' ); advanced_radio_rows.each( function( ){ if( jQuery( this ).attr( 'data-product-id' ) == product_id && jQuery( this ).attr( 'data-option-required' ) == '1' ){ // Option is Required var selected_radios = jQuery( "input[name='ec_option_adv_" + jQuery( this ).attr( 'data-product-option-id' ) + "']:checked" ); if( selected_radios.length ){ jQuery( document.getElementById( 'ec_details_adv_option_row_error_' + jQuery( this ).attr( 'data-product-option-id' ) + '_' + product_id + '_' + rand_id ) ).hide( ); }else{ jQuery( document.getElementById( 'ec_details_adv_option_row_error_' + jQuery( this ).attr( 'data-product-option-id' ) + '_' + product_id + '_' + rand_id ) ).show( ); errors++; } } } ); // Text Box Check var advanced_text_rows = jQuery( '.ec_details_option_row.ec_option_type_text:visible' ); advanced_text_rows.each( function( ){ if( jQuery( this ).attr( 'data-product-id' ) == product_id && jQuery( this ).attr( 'data-option-required' ) == '1' ){ // Option is Required if( jQuery( document.getElementById( 'ec_option_adv_' + jQuery( this ).attr( 'data-product-option-id' ) + '_' + product_id + '_' + rand_id ) ).val( ) != "" ){ jQuery( document.getElementById( 'ec_details_adv_option_row_error_' + jQuery( this ).attr( 'data-product-option-id' ) + '_' + product_id + '_' + rand_id ) ).hide( ); }else{ jQuery( document.getElementById( 'ec_details_adv_option_row_error_' + jQuery( this ).attr( 'data-product-option-id' ) + '_' + product_id + '_' + rand_id ) ).show( ); errors++; } } } ); // Text Area Check var advanced_textarea_rows = jQuery( '.ec_details_option_row.ec_option_type_textarea:visible' ); advanced_textarea_rows.each( function( ){ if( jQuery( this ).attr( 'data-product-id' ) == product_id && jQuery( this ).attr( 'data-option-required' ) == '1' ){ // Option is Required if( jQuery( document.getElementById( 'ec_option_adv_' + jQuery( this ).attr( 'data-product-option-id' ) + '_' + product_id + '_' + rand_id ) ).val( ) != "" && jQuery( document.getElementById( 'ec_option_adv_' + jQuery( this ).attr( 'data-product-option-id' ) + '_' + product_id + '_' + rand_id ) ).val( ) != 0 ){ jQuery( document.getElementById( 'ec_details_adv_option_row_error_' + jQuery( this ).attr( 'data-product-option-id' ) + '_' + product_id + '_' + rand_id ) ).hide( ); }else{ jQuery( document.getElementById( 'ec_details_adv_option_row_error_' + jQuery( this ).attr( 'data-product-option-id' ) + '_' + product_id + '_' + rand_id ) ).show( ); errors++; } } } ); // Number Box Check var advanced_text_rows = jQuery( '.ec_details_option_row.ec_option_type_number:visible' ); advanced_text_rows.each( function( ){ if( jQuery( this ).attr( 'data-product-id' ) == product_id && jQuery( this ).attr( 'data-option-required' ) == '1' ){ // Option is Required if( jQuery( document.getElementById( 'ec_option_adv_' + jQuery( this ).attr( 'data-product-option-id' ) + '_' + product_id + '_' + rand_id ) ).val( ) != "" ){ jQuery( document.getElementById( 'ec_details_adv_option_row_error_' + jQuery( this ).attr( 'data-product-option-id' ) + '_' + product_id + '_' + rand_id ) ).hide( ); }else{ jQuery( document.getElementById( 'ec_details_adv_option_row_error_' + jQuery( this ).attr( 'data-product-option-id' ) + '_' + product_id + '_' + rand_id ) ).show( ); errors++; } } } ); // Quantity Grid Check var advanced_grid_rows = jQuery( '.ec_details_option_row.ec_option_type_grid:visible' ); advanced_grid_rows.each( function( ){ if( jQuery( this ).attr( 'data-product-id' ) == product_id && jQuery( this ).attr( 'data-option-required' ) == '1' ){ // Option is Required var grid_items = jQuery( this ).find( ".ec_details_option_data > .ec_details_grid_row > input" ); var total_grid_quantity = 0; grid_items.each( function( ){ total_grid_quantity += jQuery( this ).val( ); } ); if( total_grid_quantity > 0 ){ jQuery( document.getElementById( 'ec_details_adv_option_row_error_' + jQuery( this ).attr( 'data-product-option-id' ) + '_' + product_id + '_' + rand_id ) ).hide( ); }else{ jQuery( document.getElementById( 'ec_details_adv_option_row_error_' + jQuery( this ).attr( 'data-product-option-id' ) + '_' + product_id + '_' + rand_id ) ).show( ); errors++; } } } ); // Dimensions Type 1 Check var advanced_dimensions_rows = jQuery( '.ec_details_option_row.ec_option_type_dimensions1:visible' ); advanced_dimensions_rows.each( function( ){ if( jQuery( this ).attr( 'data-product-id' ) == product_id && jQuery( this ).attr( 'data-option-required' ) == '1' ){ // Option is Required // Test Width + Height 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( ) != "" ){ jQuery( document.getElementById( 'ec_details_adv_option_row_error_' + jQuery( this ).attr( 'data-product-option-id' ) + '_' + product_id + '_' + rand_id ) ).hide( ); }else{ jQuery( document.getElementById( 'ec_details_adv_option_row_error_' + jQuery( this ).attr( 'data-product-option-id' ) + '_' + product_id + '_' + rand_id ) ).show( ); errors++; } } } ); // Dimensions Type 2 Check var advanced_dimensions_rows = jQuery( '.ec_details_option_row.ec_option_type_dimensions2:visible' ); advanced_dimensions_rows.each( function( ){ if( jQuery( this ).attr( 'data-product-id' ) == product_id && jQuery( this ).attr( 'data-option-required' ) == '1' ){ // Option is Required // Test Width + Height 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( ) != "" ){ jQuery( document.getElementById( 'ec_details_adv_option_row_error_' + jQuery( this ).attr( 'data-product-option-id' ) + '_' + product_id + '_' + rand_id ) ).hide( ); }else{ jQuery( document.getElementById( 'ec_details_adv_option_row_error_' + jQuery( this ).attr( 'data-product-option-id' ) + '_' + product_id + '_' + rand_id ) ).show( ); errors++; } } } ); // -------END Advanced Option Checks------- // // -------START GIFT CARD CHECK ----------- // var gift_card_errors = 0; if( document.getElementById( 'ec_giftcard_to_name_' + product_id + '_' + rand_id ) && jQuery( document.getElementById( 'ec_giftcard_to_name_' + product_id + '_' + rand_id ) ).val( ) == "" ){ errors++; gift_card_errors++; } if( document.getElementById( 'ec_giftcard_to_email_' + product_id + '_' + rand_id ) && jQuery( document.getElementById( 'ec_giftcard_to_email_' + product_id + '_' + rand_id ) ).val( ) == "" ){ errors++; gift_card_errors++; } if( document.getElementById( 'ec_giftcard_from_name_' + product_id + '_' + rand_id ) && jQuery( document.getElementById( 'ec_giftcard_from_name_' + product_id + '_' + rand_id ) ).val( ) == "" ){ errors++; gift_card_errors++; } if( document.getElementById( 'ec_giftcard_message_' + product_id + '_' + rand_id ) && jQuery( document.getElementById( 'ec_giftcard_message_' + product_id + '_' + rand_id ) ).val( ) == "" ){ errors++; gift_card_errors++; } if( gift_card_errors ){ jQuery( document.getElementById( 'ec_details_giftcard_error_' + product_id + '_' + rand_id ) ).show( ); }else{ jQuery( document.getElementById( 'ec_details_giftcard_error_' + product_id + '_' + rand_id ) ).hide( ); } // -------END GIFT CARD CHECK ----------- // // -------START DONATION CHECK ----------- // if( document.getElementById( 'ec_donation_amount_' + product_id + '_' + rand_id ) ){ var price = jQuery( document.getElementById( 'price_' + product_id + '_' + rand_id ) ).val(); 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 ){ jQuery( document.getElementById( 'ec_details_donation_error_' + product_id + '_' + rand_id ) ).show( ); errors++; }else{ jQuery( document.getElementById( 'ec_details_donation_error_' + product_id + '_' + rand_id ) ).hide( ); } } // -------END DONATION CHECK ----------- // // -------START INQUIRY CHECK ----------- // if( document.getElementById( 'ec_inquiry_name' ) ){ if( jQuery( document.getElementById( 'ec_inquiry_name' ) ).val( ) == "" || jQuery( document.getElementById( 'ec_inquiry_email' ) ).val( ) == "" || jQuery( document.getElementById( 'ec_inquiry_message' ) ).val( ) == "" ){ jQuery( document.getElementById( 'ec_details_inquiry_error' ) ).show( ); errors++; }else{ jQuery( document.getElementById( 'ec_details_inquiry_error' ) ).hide( ); } } // -------END INQUIRY CHECK ----------- // // Stock Quantity Check var entered_quantity = Number( jQuery( document.getElementById( 'ec_quantity_' + product_id + '_' + rand_id ) ).val( ) ); var allowed_quantity = 9999999999999; if( jQuery( document.getElementById( 'ec_details_stock_quantity' ) ).length ){ allowed_quantity = Number( jQuery( document.getElementById( 'ec_details_stock_quantity' ) ).html( ) ); } // Backorder Check if( allowed_quantity <= 0 && jQuery( document.getElementById( 'ec_back_order_info_' + product_id + '_' + rand_id ) ).length ){ allowed_quantity = 1000000; } // Check Stock Quantity if( entered_quantity > allowed_quantity ){ jQuery( document.getElementById( 'ec_addtocart_quantity_exceeded_error_' + product_id + '_' + rand_id ) ).show( ); errors++; }else{ jQuery( document.getElementById( 'ec_addtocart_quantity_exceeded_error_' + product_id + '_' + rand_id ) ).hide( ); } // Minimum Quantity Check var min_quantity = jQuery( document.getElementById( 'min_quantity_' + product_id + '_' + rand_id ) ).val(); if( entered_quantity < min_quantity ){ jQuery( document.getElementById( 'ec_addtocart_quantity_minimum_error_' + product_id + '_' + rand_id ) ).show( ); errors++; }else{ jQuery( document.getElementById( 'ec_addtocart_quantity_minimum_error_' + product_id + '_' + rand_id ) ).hide( ); } // Maximum Quantity Check var max_quantity = jQuery( document.getElementById( 'max_quantity_' + product_id + '_' + rand_id ) ).val(); if( max_quantity > 0 && entered_quantity > max_quantity ){ jQuery( document.getElementById( 'ec_addtocart_quantity_maximum_error_' + product_id + '_' + rand_id ) ).show( ); errors++; }else{ jQuery( document.getElementById( 'ec_addtocart_quantity_maximum_error_' + product_id + '_' + rand_id ) ).hide( ); } errors = window['wp_easycart_add_to_cart_js_validation_end_' + product_id + '_' + rand_id]( errors ); if( errors > 0 ) { return false; } else { if ( typeof gtag !== "undefined" ) { var final_price = ''; if ( jQuery( document.getElementById( 'ec_final_price_' + product_id + '_' + rand_id ) ).length ) { final_price = jQuery( document.getElementById( 'ec_final_price_' + product_id + '_' + rand_id ) ).html().replace( /[^\d\.\,]/g, '' ); } 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() ); } return true; } } function ec_submit_product_review( product_id, rand_id, nonce ){ var review_title = jQuery( document.getElementById( 'ec_review_title_' + product_id + '_' + rand_id ) ).val( ); var review_score = 0; for( var i=1; i<=5; i++ ){ if( jQuery( document.getElementById( 'ec_details_review_star' + i + '_' + product_id + '_' + rand_id ) ).hasClass( 'ec_product_details_star_on' ) ){ review_score++; } } var review_message = jQuery( document.getElementById( 'ec_review_message_' + product_id + '_' + rand_id ) ).val( ); if( review_title != "" && review_score != 0 && review_message != "" ){ // Submit a filled out review jQuery( document.getElementById( 'ec_details_customer_review_loader_' + product_id + '_' + rand_id ) ).show( ); jQuery( document.getElementById( 'ec_details_review_error_' + product_id + '_' + rand_id ) ).hide( ); var data = { action: 'ec_ajax_insert_customer_review', review_title: review_title, review_score: review_score, review_message: review_message, product_id: product_id, nonce: nonce }; jQuery.ajax( { url: wpeasycart_ajax_object.ajax_url, type: 'post', data: data, success: function( data ){ jQuery( document.getElementById( 'ec_details_customer_review_loader_' + product_id + '_' + rand_id ) ).hide( ); jQuery( document.getElementById( 'ec_details_submit_review_button_row_' + product_id + '_' + rand_id ) ).hide( ); jQuery( document.getElementById( 'ec_details_review_submitted_button_row_' + product_id + '_' + rand_id ) ).show( ); jQuery( document.getElementById( 'ec_details_customer_review_success_' + product_id + '_' + rand_id ) ).show( ).delay( 1500 ).fadeOut( 'slow' ); } } ); }else{ // Something is missing, display error. jQuery( document.getElementById( 'ec_details_review_error_' + product_id + '_' + rand_id ) ).show( ); } } function ec_details_get_sq_footage( is_metric, width, sub_width, height, sub_height ){ var sub_width_decimal = ec_details_get_sub_dimension_decimal( sub_width ); var sub_height_decimal = ec_details_get_sub_dimension_decimal( sub_height ); if( '1' == is_metric ) { width = Number( Number( width ) + sub_width_decimal ) / 1000; height = Number( Number( height ) + sub_height_decimal ) / 1000; } else { width = Number( Number( width ) + sub_width_decimal ) / 12; height = Number( Number( height ) + sub_height_decimal ) / 12; } return width * height; } function ec_details_get_sub_dimension_decimal( sub_dimension ) { if( sub_dimension == "0" ){ return 0; }else if( sub_dimension == "1/16" ){ return .0625; }else if( sub_dimension == "1/8" ){ return .1250; }else if( sub_dimension == "3/16" ){ return .1875; }else if( sub_dimension == "1/4" ){ return .2500; }else if( sub_dimension == "5/16" ){ return .3125; }else if( sub_dimension == "3/8" ){ return .3750; }else if( sub_dimension == "7/16" ){ return .4375; }else if( sub_dimension == "1/2" ){ return .5000; }else if( sub_dimension == "9/16" ){ return .5625; }else if( sub_dimension == "5/8" ){ return .6250; }else if( sub_dimension == "11/16" ){ return .6875; }else if( sub_dimension == "3/4" ){ return .7500; }else if( sub_dimension == "13/16" ){ return .8125; }else if( sub_dimension == "7/8" ){ return .8750; }else if( sub_dimension == "15/16" ){ return .9375; }else{ return 0; } } function ec_details_format_money_v2( product_id, rand_id, price ) { var currency_symbol = jQuery( document.getElementById( 'currency_symbol_' + product_id + '_' + rand_id ) ).val(); var num_decimals = Number( jQuery( document.getElementById( 'num_decimals_' + product_id + '_' + rand_id ) ).val() ); var decimal_symbol = jQuery( document.getElementById( 'decimal_symbol_' + product_id + '_' + rand_id ) ).val(); var grouping_symbol = jQuery( document.getElementById( 'grouping_symbol_' + product_id + '_' + rand_id ) ).val(); var conversion_rate = Number( jQuery( document.getElementById( 'conversion_rate_' + product_id + '_' + rand_id ) ).val() ); var symbol_location = Number( jQuery( document.getElementById( 'symbol_location_' + product_id + '_' + rand_id ) ).val() ); var currency_code = jQuery( document.getElementById( 'currency_code_' + product_id + '_' + rand_id ) ).val(); var show_currency_code = Number( jQuery( document.getElementById( 'show_currency_code_' + product_id + '_' + rand_id ) ).val() ); price = ec_pricing_round( price * Number( conversion_rate ), num_decimals ); var n = price, num_decimals = isNaN(num_decimals = Math.abs(num_decimals)) ? 2 : num_decimals, decimal_symbol = decimal_symbol == undefined ? "." : decimal_symbol, grouping_symbol = grouping_symbol == undefined ? "," : grouping_symbol, i = parseInt(n = price.toFixed( num_decimals ) ) + "", j = (j = i.length) > 3 ? j % 3 : 0; 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) : ""); if( symbol_location ){ formatted = currency_symbol + formatted; }else{ formatted = formatted + currency_symbol; } if( show_currency_code == '1' ){ formatted = currency_code + ' ' + formatted; } return formatted; } function ec_pricing_round( number, places ) { var multiplier = Math.pow(10, places+2); // get two extra digits var fixed = Math.floor(number*multiplier); // convert to integer fixed += 50; // round down on anything less than x.xxx50 fixed = Math.floor(fixed/100); // chop off last 2 digits return fixed/Math.pow(10, places); } function ec_admin_save_product_details_options( ){ jQuery( "#ec_admin_page_updated_loader" ).show( ); jQuery( "#ec_admin_loader_bg" ).show( ); var data = { action: 'ec_ajax_save_product_details_options', ec_option_details_main_color: jQuery( document.getElementById( 'ec_option_details_main_color' ) ).val( ), ec_option_details_second_color: jQuery( document.getElementById( 'ec_option_details_second_color' ) ).val( ), ec_option_details_columns_desktop: jQuery( document.getElementById( 'ec_option_details_columns_desktop' ) ).val( ), ec_option_details_columns_laptop: jQuery( document.getElementById( 'ec_option_details_columns_laptop' ) ).val( ), ec_option_details_columns_tablet_wide: jQuery( document.getElementById( 'ec_option_details_columns_tablet_wide' ) ).val( ), ec_option_details_columns_tablet: jQuery( document.getElementById( 'ec_option_details_columns_tablet' ) ).val( ), ec_option_details_columns_smartphone: jQuery( document.getElementById( 'ec_option_details_columns_smartphone' ) ).val( ), ec_option_use_dark_bg: jQuery( document.getElementById( 'ec_option_use_dark_bg' ) ).val( ), nonce: jQuery( '#product_details_save_options_nonce' ).val() } jQuery.ajax({url: wpeasycart_ajax_object.ajax_url, type: 'post', data: data, success: function(data){ jQuery( document.getElementById( 'ec_admin_page_updated_loader' ) ).hide( ); jQuery( document.getElementById( 'ec_admin_page_updated' ) ).show( ); jQuery( document.getElementById( 'ec_admin_loader_bg' ) ).fadeOut( 'slow' ); location.reload( ); } } ); jQuery( document.getElementById( 'ec_page_editor' ) ).animate( { left:'-290px' }, {queue:false, duration:220} ).removeClass( 'ec_display_editor_true' ).addClass( 'ec_display_editor_false' ); } function ec_admin_show_description_editor( product_id, rand_id ) { jQuery( '.ec_details_description_content_' + product_id + '_' + rand_id ).hide( ); jQuery( '.ec_details_description_editor_' + product_id + '_' + rand_id ).show( ); } function ec_admin_save_description_editor( model_number, product_id, rand_id ) { var new_html = ( jQuery( document.getElementById( 'desc_' + model_number ) ).is( ':visible' ) ) ? jQuery( document.getElementById( 'desc_' + model_number ) ).val() : tinymce.get( 'desc_' + model_number ).getContent(); jQuery( '.ec_details_description_editor_' + product_id + '_' + rand_id ).hide( ); jQuery( '.ec_details_description_content_' + product_id + '_' + rand_id ).html( new_html ).show( ); var data = { action: 'ec_ajax_ec_update_product_description', description: new_html, product_id: product_id, nonce: jQuery( document.getElementById( 'product_details_update_product_description_nonce_' + product_id + '_' + rand_id ) ).val() }; jQuery.ajax( { url: wpeasycart_ajax_object.ajax_url, type: 'post', data: data } ); } function ec_admin_show_specifications_editor( product_id, rand_id ) { jQuery( '.ec_details_specifications_content_' + product_id + '_' + rand_id ).hide( ); jQuery( '.ec_details_specifications_editor_' + product_id + '_' + rand_id ).show( ); } function ec_admin_save_specifications_editor( model_number, product_id, rand_id ){ var new_html = ( jQuery( document.getElementById( 'specs_' + model_number ) ).is( ':visible' ) ) ? jQuery( document.getElementById( 'specs_' + model_number ) ).val() : tinymce.get( 'specs_' + model_number ).getContent(); jQuery( '.ec_details_specifications_editor_' + product_id + '_' + rand_id ).hide( ); jQuery( '.ec_details_specifications_content_' + product_id + '_' + rand_id ).html( new_html ).show( ); var data = { action: 'ec_ajax_ec_update_product_specifications', specifications: new_html, product_id: product_id, nonce: jQuery( document.getElementById( 'product_details_update_product_specs_nonce_' + product_id + '_' + rand_id ) ).val() }; jQuery.ajax( { url: wpeasycart_ajax_object.ajax_url, type: 'post', data: data } ); } if ( '' != wpeasycart_ajax_object.ga4_id || '' != wpeasycart_ajax_object.ga4_conv_id ) { var newScript = document.createElement( 'script' ); newScript.type = 'text/javascript'; newScript.setAttribute( 'async', 'true' ); if ( '' != wpeasycart_ajax_object.ga4_id ) { newScript.setAttribute( 'src', 'https://www.googletagmanager.com/gtag/js?id=' + wpeasycart_ajax_object.ga4_id ); } else { newScript.setAttribute( 'src', 'https://www.googletagmanager.com/gtag/js?id=' + wpeasycart_ajax_object.ga4_conv_id ); } jQuery( 'head' ).append( newScript ); window.dataLayer = window.dataLayer || []; function gtag(){ dataLayer.push( arguments ); } gtag( 'js', new Date() ); if ( '' != wpeasycart_ajax_object.ga4_id ) { gtag( 'config', wpeasycart_ajax_object.ga4_id ); // , {'debug_mode': false} ); } if ( '' != wpeasycart_ajax_object.ga4_conv_id ) { gtag( 'config', wpeasycart_ajax_object.ga4_conv_id ); // , {'debug_mode': false} ); } } function ec_ga4_remove_from_cart( model_number, title, quantity, price, currency, manufacturer_name, is_tag_manager = false ) { if ( is_tag_manager ) { dataLayer.push( { ecommerce: null } ); // Clear the previous ecommerce object. dataLayer.push( { event: 'remove_from_cart', ecommerce: { currency: currency, value: Number( price ) * Number( quantity ), items: [ { item_id: model_number, item_name: title, index: 0, price: price, item_brand: manufacturer_name, quantity: quantity } ] } } ); } else { gtag( 'event', 'remove_from_cart', { currency: currency, value: Number( price ) * Number( quantity ), items: [ { item_id: model_number, item_name: title, index: 0, price: price, item_brand: manufacturer_name, quantity: quantity } ] } ); } } function ec_ga4_add_to_cart( model_number, title, quantity, price, currency, manufacturer_name, is_tag_manager = false ) { if ( is_tag_manager ) { dataLayer.push( { ecommerce: null } ); // Clear the previous ecommerce object. dataLayer.push( { event: 'add_to_cart', ecommerce: { currency: currency, value: Number( price ) * Number( quantity ), items: [ { item_id: model_number, item_name: title, index: 0, price: price, item_brand: manufacturer_name, quantity: quantity } ] } } ); } else { gtag( 'event', 'add_to_cart', { currency: currency, value: Number( price ) * Number( quantity ), items: [ { item_id: model_number, item_name: title, index: 0, price: price, item_brand: manufacturer_name, quantity: quantity } ] } ); } } function wp_easycart_cart_checkout_click() { jQuery( '.ec_cart_button_checkout' ).addClass( 'wp-easycart-running' ); } function wp_easycart_cart_shipping_next() { jQuery( '.ec_cart_button_shipping_next' ).parent().addClass( 'wp-easycart-running' ); } function wpeasycart_mobile_summary() { if ( jQuery( '.ec_cart_mobile_summary_content' ).is( ':visible' ) ) { jQuery( '.ec_cart_mobile_summary_content' ).hide(); jQuery( '.dashicons-arrow-down-alt2' ).show(); jQuery( '.dashicons-arrow-up-alt2' ).hide(); } else { jQuery( '.ec_cart_mobile_summary_content' ).show(); jQuery( '.dashicons-arrow-down-alt2' ).hide(); jQuery( '.dashicons-arrow-up-alt2' ).show(); } } ; /** * Owl Carousel v2.3.4 * Copyright 2013-2018 David Deutsch * Licensed under: SEE LICENSE IN https://github.com/OwlCarousel2/OwlCarousel2/blob/master/LICENSE */ !function(a,b,c,d){function e(b,c){this.settings=null,this.options=a.extend({},e.Defaults,c),this.$element=a(b),this._handlers={},this._plugins={},this._supress={},this._current=null,this._speed=null,this._coordinates=[],this._breakpoint=null,this._width=null,this._items=[],this._clones=[],this._mergers=[],this._widths=[],this._invalidated={},this._pipe=[],this._drag={time:null,target:null,pointer:null,stage:{start:null,current:null},direction:null},this._states={current:{},tags:{initializing:["busy"],animating:["busy"],dragging:["interacting"]}},a.each(["onResize","onThrottledResize"],a.proxy(function(b,c){this._handlers[c]=a.proxy(this[c],this)},this)),a.each(e.Plugins,a.proxy(function(a,b){this._plugins[a.charAt(0).toLowerCase()+a.slice(1)]=new b(this)},this)),a.each(e.Workers,a.proxy(function(b,c){this._pipe.push({filter:c.filter,run:a.proxy(c.run,this)})},this)),this.setup(),this.initialize()}e.Defaults={items:3,loop:!1,center:!1,rewind:!1,checkVisibility:!0,mouseDrag:!0,touchDrag:!0,pullDrag:!0,freeDrag:!1,margin:0,stagePadding:0,merge:!1,mergeFit:!0,autoWidth:!1,startPosition:0,rtl:!1,smartSpeed:250,fluidSpeed:!1,dragEndSpeed:!1,responsive:{},responsiveRefreshRate:200,responsiveBaseElement:b,fallbackEasing:"swing",slideTransition:"",info:!1,nestedItemSelector:!1,itemElement:"div",stageElement:"div",refreshClass:"owl-refresh",loadedClass:"owl-loaded",loadingClass:"owl-loading",rtlClass:"owl-rtl",responsiveClass:"owl-responsive",dragClass:"owl-drag",itemClass:"owl-item",stageClass:"owl-stage",stageOuterClass:"owl-stage-outer",grabClass:"owl-grab"},e.Width={Default:"default",Inner:"inner",Outer:"outer"},e.Type={Event:"event",State:"state"},e.Plugins={},e.Workers=[{filter:["width","settings"],run:function(){this._width=this.$element.width()}},{filter:["width","items","settings"],run:function(a){a.current=this._items&&this._items[this.relative(this._current)]}},{filter:["items","settings"],run:function(){this.$stage.children(".cloned").remove()}},{filter:["width","items","settings"],run:function(a){var b=this.settings.margin||"",c=!this.settings.autoWidth,d=this.settings.rtl,e={width:"auto","margin-left":d?b:"","margin-right":d?"":b};!c&&this.$stage.children().css(e),a.css=e}},{filter:["width","items","settings"],run:function(a){var b=(this.width()/this.settings.items).toFixed(3)-this.settings.margin,c=null,d=this._items.length,e=!this.settings.autoWidth,f=[];for(a.items={merge:!1,width:b};d--;)c=this._mergers[d],c=this.settings.mergeFit&&Math.min(c,this.settings.items)||c,a.items.merge=c>1||a.items.merge,f[d]=e?b*c:this._items[d].width();this._widths=f}},{filter:["items","settings"],run:function(){var b=[],c=this._items,d=this.settings,e=Math.max(2*d.items,4),f=2*Math.ceil(c.length/2),g=d.loop&&c.length?d.rewind?e:Math.max(e,f):0,h="",i="";for(g/=2;g>0;)b.push(this.normalize(b.length/2,!0)),h+=c[b[b.length-1]][0].outerHTML,b.push(this.normalize(c.length-1-(b.length-1)/2,!0)),i=c[b[b.length-1]][0].outerHTML+i,g-=1;this._clones=b,a(h).addClass("cloned").appendTo(this.$stage),a(i).addClass("cloned").prependTo(this.$stage)}},{filter:["width","items","settings"],run:function(){for(var a=this.settings.rtl?1:-1,b=this._clones.length+this._items.length,c=-1,d=0,e=0,f=[];++c",h)||this.op(b,"<",g)&&this.op(b,">",h))&&i.push(c);this.$stage.children(".active").removeClass("active"),this.$stage.children(":eq("+i.join("), :eq(")+")").addClass("active"),this.$stage.children(".center").removeClass("center"),this.settings.center&&this.$stage.children().eq(this.current()).addClass("center")}}],e.prototype.initializeStage=function(){this.$stage=this.$element.find("."+this.settings.stageClass),this.$stage.length||(this.$element.addClass(this.options.loadingClass),this.$stage=a("<"+this.settings.stageElement+">",{class:this.settings.stageClass}).wrap(a("
",{class:this.settings.stageOuterClass})),this.$element.append(this.$stage.parent()))},e.prototype.initializeItems=function(){var b=this.$element.find(".owl-item");if(b.length)return this._items=b.get().map(function(b){return a(b)}),this._mergers=this._items.map(function(){return 1}),void this.refresh();this.replace(this.$element.children().not(this.$stage.parent())),this.isVisible()?this.refresh():this.invalidate("width"),this.$element.removeClass(this.options.loadingClass).addClass(this.options.loadedClass)},e.prototype.initialize=function(){if(this.enter("initializing"),this.trigger("initialize"),this.$element.toggleClass(this.settings.rtlClass,this.settings.rtl),this.settings.autoWidth&&!this.is("pre-loading")){var a,b,c;a=this.$element.find("img"),b=this.settings.nestedItemSelector?"."+this.settings.nestedItemSelector:d,c=this.$element.children(b).width(),a.length&&c<=0&&this.preloadAutoWidthImages(a)}this.initializeStage(),this.initializeItems(),this.registerEventHandlers(),this.leave("initializing"),this.trigger("initialized")},e.prototype.isVisible=function(){return!this.settings.checkVisibility||this.$element.is(":visible")},e.prototype.setup=function(){var b=this.viewport(),c=this.options.responsive,d=-1,e=null;c?(a.each(c,function(a){a<=b&&a>d&&(d=Number(a))}),e=a.extend({},this.options,c[d]),"function"==typeof e.stagePadding&&(e.stagePadding=e.stagePadding()),delete e.responsive,e.responsiveClass&&this.$element.attr("class",this.$element.attr("class").replace(new RegExp("("+this.options.responsiveClass+"-)\\S+\\s","g"),"$1"+d))):e=a.extend({},this.options),this.trigger("change",{property:{name:"settings",value:e}}),this._breakpoint=d,this.settings=e,this.invalidate("settings"),this.trigger("changed",{property:{name:"settings",value:this.settings}})},e.prototype.optionsLogic=function(){this.settings.autoWidth&&(this.settings.stagePadding=!1,this.settings.merge=!1)},e.prototype.prepare=function(b){var c=this.trigger("prepare",{content:b});return c.data||(c.data=a("<"+this.settings.itemElement+"/>").addClass(this.options.itemClass).append(b)),this.trigger("prepared",{content:c.data}),c.data},e.prototype.update=function(){for(var b=0,c=this._pipe.length,d=a.proxy(function(a){return this[a]},this._invalidated),e={};b0)&&this._pipe[b].run(e),b++;this._invalidated={},!this.is("valid")&&this.enter("valid")},e.prototype.width=function(a){switch(a=a||e.Width.Default){case e.Width.Inner:case e.Width.Outer:return this._width;default:return this._width-2*this.settings.stagePadding+this.settings.margin}},e.prototype.refresh=function(){this.enter("refreshing"),this.trigger("refresh"),this.setup(),this.optionsLogic(),this.$element.addClass(this.options.refreshClass),this.update(),this.$element.removeClass(this.options.refreshClass),this.leave("refreshing"),this.trigger("refreshed")},e.prototype.onThrottledResize=function(){b.clearTimeout(this.resizeTimer),this.resizeTimer=b.setTimeout(this._handlers.onResize,this.settings.responsiveRefreshRate)},e.prototype.onResize=function(){return!!this._items.length&&(this._width!==this.$element.width()&&(!!this.isVisible()&&(this.enter("resizing"),this.trigger("resize").isDefaultPrevented()?(this.leave("resizing"),!1):(this.invalidate("width"),this.refresh(),this.leave("resizing"),void this.trigger("resized")))))},e.prototype.registerEventHandlers=function(){a.support.transition&&this.$stage.on(a.support.transition.end+".owl.core",a.proxy(this.onTransitionEnd,this)),!1!==this.settings.responsive&&this.on(b,"resize",this._handlers.onThrottledResize),this.settings.mouseDrag&&(this.$element.addClass(this.options.dragClass),this.$stage.on("mousedown.owl.core",a.proxy(this.onDragStart,this)),this.$stage.on("dragstart.owl.core selectstart.owl.core",function(){return!1})),this.settings.touchDrag&&(this.$stage.on("touchstart.owl.core",a.proxy(this.onDragStart,this)),this.$stage.on("touchcancel.owl.core",a.proxy(this.onDragEnd,this)))},e.prototype.onDragStart=function(b){var d=null;3!==b.which&&(a.support.transform?(d=this.$stage.css("transform").replace(/.*\(|\)| /g,"").split(","),d={x:d[16===d.length?12:4],y:d[16===d.length?13:5]}):(d=this.$stage.position(),d={x:this.settings.rtl?d.left+this.$stage.width()-this.width()+this.settings.margin:d.left,y:d.top}),this.is("animating")&&(a.support.transform?this.animate(d.x):this.$stage.stop(),this.invalidate("position")),this.$element.toggleClass(this.options.grabClass,"mousedown"===b.type),this.speed(0),this._drag.time=(new Date).getTime(),this._drag.target=a(b.target),this._drag.stage.start=d,this._drag.stage.current=d,this._drag.pointer=this.pointer(b),a(c).on("mouseup.owl.core touchend.owl.core",a.proxy(this.onDragEnd,this)),a(c).one("mousemove.owl.core touchmove.owl.core",a.proxy(function(b){var d=this.difference(this._drag.pointer,this.pointer(b));a(c).on("mousemove.owl.core touchmove.owl.core",a.proxy(this.onDragMove,this)),Math.abs(d.x)0^this.settings.rtl?"left":"right";a(c).off(".owl.core"),this.$element.removeClass(this.options.grabClass),(0!==d.x&&this.is("dragging")||!this.is("valid"))&&(this.speed(this.settings.dragEndSpeed||this.settings.smartSpeed),this.current(this.closest(e.x,0!==d.x?f:this._drag.direction)),this.invalidate("position"),this.update(),this._drag.direction=f,(Math.abs(d.x)>3||(new Date).getTime()-this._drag.time>300)&&this._drag.target.one("click.owl.core",function(){return!1})),this.is("dragging")&&(this.leave("dragging"),this.trigger("dragged"))},e.prototype.closest=function(b,c){var e=-1,f=30,g=this.width(),h=this.coordinates();return this.settings.freeDrag||a.each(h,a.proxy(function(a,i){return"left"===c&&b>i-f&&bi-g-f&&b",h[a+1]!==d?h[a+1]:i-g)&&(e="left"===c?a+1:a),-1===e},this)),this.settings.loop||(this.op(b,">",h[this.minimum()])?e=b=this.minimum():this.op(b,"<",h[this.maximum()])&&(e=b=this.maximum())),e},e.prototype.animate=function(b){var c=this.speed()>0;this.is("animating")&&this.onTransitionEnd(),c&&(this.enter("animating"),this.trigger("translate")),a.support.transform3d&&a.support.transition?this.$stage.css({transform:"translate3d("+b+"px,0px,0px)",transition:this.speed()/1e3+"s"+(this.settings.slideTransition?" "+this.settings.slideTransition:"")}):c?this.$stage.animate({left:b+"px"},this.speed(),this.settings.fallbackEasing,a.proxy(this.onTransitionEnd,this)):this.$stage.css({left:b+"px"})},e.prototype.is=function(a){return this._states.current[a]&&this._states.current[a]>0},e.prototype.current=function(a){if(a===d)return this._current;if(0===this._items.length)return d;if(a=this.normalize(a),this._current!==a){var b=this.trigger("change",{property:{name:"position",value:a}});b.data!==d&&(a=this.normalize(b.data)),this._current=a,this.invalidate("position"),this.trigger("changed",{property:{name:"position",value:this._current}})}return this._current},e.prototype.invalidate=function(b){return"string"===a.type(b)&&(this._invalidated[b]=!0,this.is("valid")&&this.leave("valid")),a.map(this._invalidated,function(a,b){return b})},e.prototype.reset=function(a){(a=this.normalize(a))!==d&&(this._speed=0,this._current=a,this.suppress(["translate","translated"]),this.animate(this.coordinates(a)),this.release(["translate","translated"]))},e.prototype.normalize=function(a,b){var c=this._items.length,e=b?0:this._clones.length;return!this.isNumeric(a)||c<1?a=d:(a<0||a>=c+e)&&(a=((a-e/2)%c+c)%c+e/2),a},e.prototype.relative=function(a){return a-=this._clones.length/2,this.normalize(a,!0)},e.prototype.maximum=function(a){var b,c,d,e=this.settings,f=this._coordinates.length;if(e.loop)f=this._clones.length/2+this._items.length-1;else if(e.autoWidth||e.merge){if(b=this._items.length)for(c=this._items[--b].width(),d=this.$element.width();b--&&!((c+=this._items[b].width()+this.settings.margin)>d););f=b+1}else f=e.center?this._items.length-1:this._items.length-e.items;return a&&(f-=this._clones.length/2),Math.max(f,0)},e.prototype.minimum=function(a){return a?0:this._clones.length/2},e.prototype.items=function(a){return a===d?this._items.slice():(a=this.normalize(a,!0),this._items[a])},e.prototype.mergers=function(a){return a===d?this._mergers.slice():(a=this.normalize(a,!0),this._mergers[a])},e.prototype.clones=function(b){var c=this._clones.length/2,e=c+this._items.length,f=function(a){return a%2==0?e+a/2:c-(a+1)/2};return b===d?a.map(this._clones,function(a,b){return f(b)}):a.map(this._clones,function(a,c){return a===b?f(c):null})},e.prototype.speed=function(a){return a!==d&&(this._speed=a),this._speed},e.prototype.coordinates=function(b){var c,e=1,f=b-1;return b===d?a.map(this._coordinates,a.proxy(function(a,b){return this.coordinates(b)},this)):(this.settings.center?(this.settings.rtl&&(e=-1,f=b+1),c=this._coordinates[b],c+=(this.width()-c+(this._coordinates[f]||0))/2*e):c=this._coordinates[f]||0,c=Math.ceil(c))},e.prototype.duration=function(a,b,c){return 0===c?0:Math.min(Math.max(Math.abs(b-a),1),6)*Math.abs(c||this.settings.smartSpeed)},e.prototype.to=function(a,b){var c=this.current(),d=null,e=a-this.relative(c),f=(e>0)-(e<0),g=this._items.length,h=this.minimum(),i=this.maximum();this.settings.loop?(!this.settings.rewind&&Math.abs(e)>g/2&&(e+=-1*f*g),a=c+e,(d=((a-h)%g+g)%g+h)!==a&&d-e<=i&&d-e>0&&(c=d-e,a=d,this.reset(c))):this.settings.rewind?(i+=1,a=(a%i+i)%i):a=Math.max(h,Math.min(i,a)),this.speed(this.duration(c,a,b)),this.current(a),this.isVisible()&&this.update()},e.prototype.next=function(a){a=a||!1,this.to(this.relative(this.current())+1,a)},e.prototype.prev=function(a){a=a||!1,this.to(this.relative(this.current())-1,a)},e.prototype.onTransitionEnd=function(a){if(a!==d&&(a.stopPropagation(),(a.target||a.srcElement||a.originalTarget)!==this.$stage.get(0)))return!1;this.leave("animating"),this.trigger("translated")},e.prototype.viewport=function(){var d;return this.options.responsiveBaseElement!==b?d=a(this.options.responsiveBaseElement).width():b.innerWidth?d=b.innerWidth:c.documentElement&&c.documentElement.clientWidth?d=c.documentElement.clientWidth:console.warn("Can not detect viewport width."),d},e.prototype.replace=function(b){this.$stage.empty(),this._items=[],b&&(b=b instanceof jQuery?b:a(b)),this.settings.nestedItemSelector&&(b=b.find("."+this.settings.nestedItemSelector)),b.filter(function(){return 1===this.nodeType}).each(a.proxy(function(a,b){b=this.prepare(b),this.$stage.append(b),this._items.push(b),this._mergers.push(1*b.find("[data-merge]").addBack("[data-merge]").attr("data-merge")||1)},this)),this.reset(this.isNumeric(this.settings.startPosition)?this.settings.startPosition:0),this.invalidate("items")},e.prototype.add=function(b,c){var e=this.relative(this._current);c=c===d?this._items.length:this.normalize(c,!0),b=b instanceof jQuery?b:a(b),this.trigger("add",{content:b,position:c}),b=this.prepare(b),0===this._items.length||c===this._items.length?(0===this._items.length&&this.$stage.append(b),0!==this._items.length&&this._items[c-1].after(b),this._items.push(b),this._mergers.push(1*b.find("[data-merge]").addBack("[data-merge]").attr("data-merge")||1)):(this._items[c].before(b),this._items.splice(c,0,b),this._mergers.splice(c,0,1*b.find("[data-merge]").addBack("[data-merge]").attr("data-merge")||1)),this._items[e]&&this.reset(this._items[e].index()),this.invalidate("items"),this.trigger("added",{content:b,position:c})},e.prototype.remove=function(a){(a=this.normalize(a,!0))!==d&&(this.trigger("remove",{content:this._items[a],position:a}),this._items[a].remove(),this._items.splice(a,1),this._mergers.splice(a,1),this.invalidate("items"),this.trigger("removed",{content:null,position:a}))},e.prototype.preloadAutoWidthImages=function(b){b.each(a.proxy(function(b,c){this.enter("pre-loading"),c=a(c),a(new Image).one("load",a.proxy(function(a){c.attr("src",a.target.src),c.css("opacity",1),this.leave("pre-loading"),!this.is("pre-loading")&&!this.is("initializing")&&this.refresh()},this)).attr("src",c.attr("src")||c.attr("data-src")||c.attr("data-src-retina"))},this))},e.prototype.destroy=function(){this.$element.off(".owl.core"),this.$stage.off(".owl.core"),a(c).off(".owl.core"),!1!==this.settings.responsive&&(b.clearTimeout(this.resizeTimer),this.off(b,"resize",this._handlers.onThrottledResize));for(var d in this._plugins)this._plugins[d].destroy();this.$stage.children(".cloned").remove(),this.$stage.unwrap(),this.$stage.children().contents().unwrap(),this.$stage.children().unwrap(),this.$stage.remove(),this.$element.removeClass(this.options.refreshClass).removeClass(this.options.loadingClass).removeClass(this.options.loadedClass).removeClass(this.options.rtlClass).removeClass(this.options.dragClass).removeClass(this.options.grabClass).attr("class",this.$element.attr("class").replace(new RegExp(this.options.responsiveClass+"-\\S+\\s","g"),"")).removeData("owl.carousel")},e.prototype.op=function(a,b,c){var d=this.settings.rtl;switch(b){case"<":return d?a>c:a":return d?ac;case">=":return d?a<=c:a>=c;case"<=":return d?a>=c:a<=c}},e.prototype.on=function(a,b,c,d){a.addEventListener?a.addEventListener(b,c,d):a.attachEvent&&a.attachEvent("on"+b,c)},e.prototype.off=function(a,b,c,d){a.removeEventListener?a.removeEventListener(b,c,d):a.detachEvent&&a.detachEvent("on"+b,c)},e.prototype.trigger=function(b,c,d,f,g){var h={item:{count:this._items.length,index:this.current()}},i=a.camelCase(a.grep(["on",b,d],function(a){return a}).join("-").toLowerCase()),j=a.Event([b,"owl",d||"carousel"].join(".").toLowerCase(),a.extend({relatedTarget:this},h,c));return this._supress[b]||(a.each(this._plugins,function(a,b){b.onTrigger&&b.onTrigger(j)}),this.register({type:e.Type.Event,name:b}),this.$element.trigger(j),this.settings&&"function"==typeof this.settings[i]&&this.settings[i].call(this,j)),j},e.prototype.enter=function(b){a.each([b].concat(this._states.tags[b]||[]),a.proxy(function(a,b){this._states.current[b]===d&&(this._states.current[b]=0),this._states.current[b]++},this))},e.prototype.leave=function(b){a.each([b].concat(this._states.tags[b]||[]),a.proxy(function(a,b){this._states.current[b]--},this))},e.prototype.register=function(b){if(b.type===e.Type.Event){if(a.event.special[b.name]||(a.event.special[b.name]={}),!a.event.special[b.name].owl){var c=a.event.special[b.name]._default;a.event.special[b.name]._default=function(a){return!c||!c.apply||a.namespace&&-1!==a.namespace.indexOf("owl")?a.namespace&&a.namespace.indexOf("owl")>-1:c.apply(this,arguments)},a.event.special[b.name].owl=!0}}else b.type===e.Type.State&&(this._states.tags[b.name]?this._states.tags[b.name]=this._states.tags[b.name].concat(b.tags):this._states.tags[b.name]=b.tags,this._states.tags[b.name]=a.grep(this._states.tags[b.name],a.proxy(function(c,d){return a.inArray(c,this._states.tags[b.name])===d},this)))},e.prototype.suppress=function(b){a.each(b,a.proxy(function(a,b){this._supress[b]=!0},this))},e.prototype.release=function(b){a.each(b,a.proxy(function(a,b){delete this._supress[b]},this))},e.prototype.pointer=function(a){var c={x:null,y:null};return a=a.originalEvent||a||b.event,a=a.touches&&a.touches.length?a.touches[0]:a.changedTouches&&a.changedTouches.length?a.changedTouches[0]:a,a.pageX?(c.x=a.pageX,c.y=a.pageY):(c.x=a.clientX,c.y=a.clientY),c},e.prototype.isNumeric=function(a){return!isNaN(parseFloat(a))},e.prototype.difference=function(a,b){return{x:a.x-b.x,y:a.y-b.y}},a.fn.owlCarousel=function(b){var c=Array.prototype.slice.call(arguments,1);return this.each(function(){var d=a(this),f=d.data("owl.carousel");f||(f=new e(this,"object"==typeof b&&b),d.data("owl.carousel",f),a.each(["next","prev","to","destroy","refresh","replace","add","remove"],function(b,c){f.register({type:e.Type.Event,name:c}),f.$element.on(c+".owl.carousel.core",a.proxy(function(a){a.namespace&&a.relatedTarget!==this&&(this.suppress([c]),f[c].apply(this,[].slice.call(arguments,1)),this.release([c]))},f))})),"string"==typeof b&&"_"!==b.charAt(0)&&f[b].apply(f,c)})},a.fn.owlCarousel.Constructor=e}(window.Zepto||window.jQuery,window,document),function(a,b,c,d){var e=function(b){this._core=b,this._interval=null,this._visible=null,this._handlers={"initialized.owl.carousel":a.proxy(function(a){a.namespace&&this._core.settings.autoRefresh&&this.watch()},this)},this._core.options=a.extend({},e.Defaults,this._core.options),this._core.$element.on(this._handlers)};e.Defaults={autoRefresh:!0,autoRefreshInterval:500},e.prototype.watch=function(){this._interval||(this._visible=this._core.isVisible(),this._interval=b.setInterval(a.proxy(this.refresh,this),this._core.settings.autoRefreshInterval))},e.prototype.refresh=function(){this._core.isVisible()!==this._visible&&(this._visible=!this._visible,this._core.$element.toggleClass("owl-hidden",!this._visible),this._visible&&this._core.invalidate("width")&&this._core.refresh())},e.prototype.destroy=function(){var a,c;b.clearInterval(this._interval);for(a in this._handlers)this._core.$element.off(a,this._handlers[a]);for(c in Object.getOwnPropertyNames(this))"function"!=typeof this[c]&&(this[c]=null)},a.fn.owlCarousel.Constructor.Plugins.AutoRefresh=e}(window.Zepto||window.jQuery,window,document),function(a,b,c,d){var e=function(b){this._core=b,this._loaded=[],this._handlers={"initialized.owl.carousel change.owl.carousel resized.owl.carousel":a.proxy(function(b){if(b.namespace&&this._core.settings&&this._core.settings.lazyLoad&&(b.property&&"position"==b.property.name||"initialized"==b.type)){var c=this._core.settings,e=c.center&&Math.ceil(c.items/2)||c.items,f=c.center&&-1*e||0,g=(b.property&&b.property.value!==d?b.property.value:this._core.current())+f,h=this._core.clones().length,i=a.proxy(function(a,b){this.load(b)},this);for(c.lazyLoadEager>0&&(e+=c.lazyLoadEager,c.loop&&(g-=c.lazyLoadEager,e++));f++-1||(e.each(a.proxy(function(c,d){var e,f=a(d),g=b.devicePixelRatio>1&&f.attr("data-src-retina")||f.attr("data-src")||f.attr("data-srcset");this._core.trigger("load",{element:f,url:g},"lazy"),f.is("img")?f.one("load.owl.lazy",a.proxy(function(){f.css("opacity",1),this._core.trigger("loaded",{element:f,url:g},"lazy")},this)).attr("src",g):f.is("source")?f.one("load.owl.lazy",a.proxy(function(){this._core.trigger("loaded",{element:f,url:g},"lazy")},this)).attr("srcset",g):(e=new Image,e.onload=a.proxy(function(){f.css({"background-image":'url("'+g+'")',opacity:"1"}),this._core.trigger("loaded",{element:f,url:g},"lazy")},this),e.src=g)},this)),this._loaded.push(d.get(0)))},e.prototype.destroy=function(){var a,b;for(a in this.handlers)this._core.$element.off(a,this.handlers[a]);for(b in Object.getOwnPropertyNames(this))"function"!=typeof this[b]&&(this[b]=null)},a.fn.owlCarousel.Constructor.Plugins.Lazy=e}(window.Zepto||window.jQuery,window,document),function(a,b,c,d){var e=function(c){this._core=c,this._previousHeight=null,this._handlers={"initialized.owl.carousel refreshed.owl.carousel":a.proxy(function(a){a.namespace&&this._core.settings.autoHeight&&this.update()},this),"changed.owl.carousel":a.proxy(function(a){a.namespace&&this._core.settings.autoHeight&&"position"===a.property.name&&this.update()},this),"loaded.owl.lazy":a.proxy(function(a){a.namespace&&this._core.settings.autoHeight&&a.element.closest("."+this._core.settings.itemClass).index()===this._core.current()&&this.update()},this)},this._core.options=a.extend({},e.Defaults,this._core.options),this._core.$element.on(this._handlers),this._intervalId=null;var d=this;a(b).on("load",function(){d._core.settings.autoHeight&&d.update()}),a(b).resize(function(){d._core.settings.autoHeight&&(null!=d._intervalId&&clearTimeout(d._intervalId),d._intervalId=setTimeout(function(){d.update()},250))})};e.Defaults={autoHeight:!1,autoHeightClass:"owl-height"},e.prototype.update=function(){var b=this._core._current,c=b+this._core.settings.items,d=this._core.settings.lazyLoad,e=this._core.$stage.children().toArray().slice(b,c),f=[],g=0;a.each(e,function(b,c){f.push(a(c).height())}),g=Math.max.apply(null,f),g<=1&&d&&this._previousHeight&&(g=this._previousHeight),this._previousHeight=g,this._core.$stage.parent().height(g).addClass(this._core.settings.autoHeightClass)},e.prototype.destroy=function(){var a,b;for(a in this._handlers)this._core.$element.off(a,this._handlers[a]);for(b in Object.getOwnPropertyNames(this))"function"!=typeof this[b]&&(this[b]=null)},a.fn.owlCarousel.Constructor.Plugins.AutoHeight=e}(window.Zepto||window.jQuery,window,document),function(a,b,c,d){var e=function(b){this._core=b,this._videos={},this._playing=null,this._handlers={"initialized.owl.carousel":a.proxy(function(a){a.namespace&&this._core.register({type:"state",name:"playing",tags:["interacting"]})},this),"resize.owl.carousel":a.proxy(function(a){a.namespace&&this._core.settings.video&&this.isInFullScreen()&&a.preventDefault()},this),"refreshed.owl.carousel":a.proxy(function(a){a.namespace&&this._core.is("resizing")&&this._core.$stage.find(".cloned .owl-video-frame").remove()},this),"changed.owl.carousel":a.proxy(function(a){a.namespace&&"position"===a.property.name&&this._playing&&this.stop()},this),"prepared.owl.carousel":a.proxy(function(b){if(b.namespace){var c=a(b.content).find(".owl-video");c.length&&(c.css("display","none"),this.fetch(c,a(b.content)))}},this)},this._core.options=a.extend({},e.Defaults,this._core.options),this._core.$element.on(this._handlers),this._core.$element.on("click.owl.video",".owl-video-play-icon",a.proxy(function(a){this.play(a)},this))};e.Defaults={video:!1,videoHeight:!1,videoWidth:!1},e.prototype.fetch=function(a,b){var c=function(){return a.attr("data-vimeo-id")?"vimeo":a.attr("data-vzaar-id")?"vzaar":"youtube"}(),d=a.attr("data-vimeo-id")||a.attr("data-youtube-id")||a.attr("data-vzaar-id"),e=a.attr("data-width")||this._core.settings.videoWidth,f=a.attr("data-height")||this._core.settings.videoHeight,g=a.attr("href");if(!g)throw new Error("Missing video URL.");if(d=g.match(/(http:|https:|)\/\/(player.|www.|app.)?(vimeo\.com|youtu(be\.com|\.be|be\.googleapis\.com|be\-nocookie\.com)|vzaar\.com)\/(video\/|videos\/|embed\/|channels\/.+\/|groups\/.+\/|watch\?v=|v\/)?([A-Za-z0-9._%-]*)(\&\S+)?/),d[3].indexOf("youtu")>-1)c="youtube";else if(d[3].indexOf("vimeo")>-1)c="vimeo";else{if(!(d[3].indexOf("vzaar")>-1))throw new Error("Video URL not supported.");c="vzaar"}d=d[6],this._videos[g]={type:c,id:d,width:e,height:f},b.attr("data-video",g),this.thumbnail(a,this._videos[g])},e.prototype.thumbnail=function(b,c){var d,e,f,g=c.width&&c.height?"width:"+c.width+"px;height:"+c.height+"px;":"",h=b.find("img"),i="src",j="",k=this._core.settings,l=function(c){e='
',d=k.lazyLoad?a("
",{class:"owl-video-tn "+j,srcType:c}):a("
",{class:"owl-video-tn",style:"opacity:1;background-image:url("+c+")"}),b.after(d),b.after(e)};if(b.wrap(a("
",{class:"owl-video-wrapper",style:g})),this._core.settings.lazyLoad&&(i="data-src",j="owl-lazy"),h.length)return l(h.attr(i)),h.remove(),!1;"youtube"===c.type?(f="//img.youtube.com/vi/"+c.id+"/hqdefault.jpg",l(f)):"vimeo"===c.type?a.ajax({type:"GET",url:"//vimeo.com/api/v2/video/"+c.id+".json",jsonp:"callback",dataType:"jsonp",success:function(a){f=a[0].thumbnail_large,l(f)}}):"vzaar"===c.type&&a.ajax({type:"GET",url:"//vzaar.com/api/videos/"+c.id+".json",jsonp:"callback",dataType:"jsonp",success:function(a){f=a.framegrab_url,l(f)}})},e.prototype.stop=function(){this._core.trigger("stop",null,"video"),this._playing.find(".owl-video-frame").remove(),this._playing.removeClass("owl-video-playing"),this._playing=null,this._core.leave("playing"),this._core.trigger("stopped",null,"video")},e.prototype.play=function(b){var c,d=a(b.target),e=d.closest("."+this._core.settings.itemClass),f=this._videos[e.attr("data-video")],g=f.width||"100%",h=f.height||this._core.$stage.height();this._playing||(this._core.enter("playing"),this._core.trigger("play",null,"video"),e=this._core.items(this._core.relative(e.index())),this._core.reset(e.index()),c=a(''),c.attr("height",h),c.attr("width",g),"youtube"===f.type?c.attr("src","//www.youtube.com/embed/"+f.id+"?autoplay=1&rel=0&v="+f.id):"vimeo"===f.type?c.attr("src","//player.vimeo.com/video/"+f.id+"?autoplay=1"):"vzaar"===f.type&&c.attr("src","//view.vzaar.com/"+f.id+"/player?autoplay=true"),a(c).wrap('
').insertAfter(e.find(".owl-video")),this._playing=e.addClass("owl-video-playing"))},e.prototype.isInFullScreen=function(){var b=c.fullscreenElement||c.mozFullScreenElement||c.webkitFullscreenElement;return b&&a(b).parent().hasClass("owl-video-frame")},e.prototype.destroy=function(){var a,b;this._core.$element.off("click.owl.video");for(a in this._handlers)this._core.$element.off(a,this._handlers[a]);for(b in Object.getOwnPropertyNames(this))"function"!=typeof this[b]&&(this[b]=null)},a.fn.owlCarousel.Constructor.Plugins.Video=e}(window.Zepto||window.jQuery,window,document),function(a,b,c,d){var e=function(b){this.core=b,this.core.options=a.extend({},e.Defaults,this.core.options),this.swapping=!0,this.previous=d,this.next=d,this.handlers={"change.owl.carousel":a.proxy(function(a){a.namespace&&"position"==a.property.name&&(this.previous=this.core.current(),this.next=a.property.value)},this),"drag.owl.carousel dragged.owl.carousel translated.owl.carousel":a.proxy(function(a){a.namespace&&(this.swapping="translated"==a.type)},this),"translate.owl.carousel":a.proxy(function(a){a.namespace&&this.swapping&&(this.core.options.animateOut||this.core.options.animateIn)&&this.swap()},this)},this.core.$element.on(this.handlers)};e.Defaults={animateOut:!1, animateIn:!1},e.prototype.swap=function(){if(1===this.core.settings.items&&a.support.animation&&a.support.transition){this.core.speed(0);var b,c=a.proxy(this.clear,this),d=this.core.$stage.children().eq(this.previous),e=this.core.$stage.children().eq(this.next),f=this.core.settings.animateIn,g=this.core.settings.animateOut;this.core.current()!==this.previous&&(g&&(b=this.core.coordinates(this.previous)-this.core.coordinates(this.next),d.one(a.support.animation.end,c).css({left:b+"px"}).addClass("animated owl-animated-out").addClass(g)),f&&e.one(a.support.animation.end,c).addClass("animated owl-animated-in").addClass(f))}},e.prototype.clear=function(b){a(b.target).css({left:""}).removeClass("animated owl-animated-out owl-animated-in").removeClass(this.core.settings.animateIn).removeClass(this.core.settings.animateOut),this.core.onTransitionEnd()},e.prototype.destroy=function(){var a,b;for(a in this.handlers)this.core.$element.off(a,this.handlers[a]);for(b in Object.getOwnPropertyNames(this))"function"!=typeof this[b]&&(this[b]=null)},a.fn.owlCarousel.Constructor.Plugins.Animate=e}(window.Zepto||window.jQuery,window,document),function(a,b,c,d){var e=function(b){this._core=b,this._call=null,this._time=0,this._timeout=0,this._paused=!0,this._handlers={"changed.owl.carousel":a.proxy(function(a){a.namespace&&"settings"===a.property.name?this._core.settings.autoplay?this.play():this.stop():a.namespace&&"position"===a.property.name&&this._paused&&(this._time=0)},this),"initialized.owl.carousel":a.proxy(function(a){a.namespace&&this._core.settings.autoplay&&this.play()},this),"play.owl.autoplay":a.proxy(function(a,b,c){a.namespace&&this.play(b,c)},this),"stop.owl.autoplay":a.proxy(function(a){a.namespace&&this.stop()},this),"mouseover.owl.autoplay":a.proxy(function(){this._core.settings.autoplayHoverPause&&this._core.is("rotating")&&this.pause()},this),"mouseleave.owl.autoplay":a.proxy(function(){this._core.settings.autoplayHoverPause&&this._core.is("rotating")&&this.play()},this),"touchstart.owl.core":a.proxy(function(){this._core.settings.autoplayHoverPause&&this._core.is("rotating")&&this.pause()},this),"touchend.owl.core":a.proxy(function(){this._core.settings.autoplayHoverPause&&this.play()},this)},this._core.$element.on(this._handlers),this._core.options=a.extend({},e.Defaults,this._core.options)};e.Defaults={autoplay:!1,autoplayTimeout:5e3,autoplayHoverPause:!1,autoplaySpeed:!1},e.prototype._next=function(d){this._call=b.setTimeout(a.proxy(this._next,this,d),this._timeout*(Math.round(this.read()/this._timeout)+1)-this.read()),this._core.is("interacting")||c.hidden||this._core.next(d||this._core.settings.autoplaySpeed)},e.prototype.read=function(){return(new Date).getTime()-this._time},e.prototype.play=function(c,d){var e;this._core.is("rotating")||this._core.enter("rotating"),c=c||this._core.settings.autoplayTimeout,e=Math.min(this._time%(this._timeout||c),c),this._paused?(this._time=this.read(),this._paused=!1):b.clearTimeout(this._call),this._time+=this.read()%c-e,this._timeout=c,this._call=b.setTimeout(a.proxy(this._next,this,d),c-e)},e.prototype.stop=function(){this._core.is("rotating")&&(this._time=0,this._paused=!0,b.clearTimeout(this._call),this._core.leave("rotating"))},e.prototype.pause=function(){this._core.is("rotating")&&!this._paused&&(this._time=this.read(),this._paused=!0,b.clearTimeout(this._call))},e.prototype.destroy=function(){var a,b;this.stop();for(a in this._handlers)this._core.$element.off(a,this._handlers[a]);for(b in Object.getOwnPropertyNames(this))"function"!=typeof this[b]&&(this[b]=null)},a.fn.owlCarousel.Constructor.Plugins.autoplay=e}(window.Zepto||window.jQuery,window,document),function(a,b,c,d){"use strict";var e=function(b){this._core=b,this._initialized=!1,this._pages=[],this._controls={},this._templates=[],this.$element=this._core.$element,this._overrides={next:this._core.next,prev:this._core.prev,to:this._core.to},this._handlers={"prepared.owl.carousel":a.proxy(function(b){b.namespace&&this._core.settings.dotsData&&this._templates.push('
'+a(b.content).find("[data-dot]").addBack("[data-dot]").attr("data-dot")+"
")},this),"added.owl.carousel":a.proxy(function(a){a.namespace&&this._core.settings.dotsData&&this._templates.splice(a.position,0,this._templates.pop())},this),"remove.owl.carousel":a.proxy(function(a){a.namespace&&this._core.settings.dotsData&&this._templates.splice(a.position,1)},this),"changed.owl.carousel":a.proxy(function(a){a.namespace&&"position"==a.property.name&&this.draw()},this),"initialized.owl.carousel":a.proxy(function(a){a.namespace&&!this._initialized&&(this._core.trigger("initialize",null,"navigation"),this.initialize(),this.update(),this.draw(),this._initialized=!0,this._core.trigger("initialized",null,"navigation"))},this),"refreshed.owl.carousel":a.proxy(function(a){a.namespace&&this._initialized&&(this._core.trigger("refresh",null,"navigation"),this.update(),this.draw(),this._core.trigger("refreshed",null,"navigation"))},this)},this._core.options=a.extend({},e.Defaults,this._core.options),this.$element.on(this._handlers)};e.Defaults={nav:!1,navText:['',''],navSpeed:!1,navElement:'button type="button" role="presentation"',navContainer:!1,navContainerClass:"owl-nav",navClass:["owl-prev","owl-next"],slideBy:1,dotClass:"owl-dot",dotsClass:"owl-dots",dots:!0,dotsEach:!1,dotsData:!1,dotsSpeed:!1,dotsContainer:!1},e.prototype.initialize=function(){var b,c=this._core.settings;this._controls.$relative=(c.navContainer?a(c.navContainer):a("
").addClass(c.navContainerClass).appendTo(this.$element)).addClass("disabled"),this._controls.$previous=a("<"+c.navElement+">").addClass(c.navClass[0]).html(c.navText[0]).prependTo(this._controls.$relative).on("click",a.proxy(function(a){this.prev(c.navSpeed)},this)),this._controls.$next=a("<"+c.navElement+">").addClass(c.navClass[1]).html(c.navText[1]).appendTo(this._controls.$relative).on("click",a.proxy(function(a){this.next(c.navSpeed)},this)),c.dotsData||(this._templates=[a('