// source --> https://cvetok.in.ua/wp-content/plugins/woocommerce/assets/js/frontend/add-to-cart.min.js?ver=3.5.3 jQuery(function(e){if("undefined"==typeof wc_add_to_cart_params)return!1;var t=function(){e(document.body).on("click",".add_to_cart_button",this.onAddToCart).on("click",".remove_from_cart_button",this.onRemoveFromCart).on("added_to_cart",this.updateButton).on("added_to_cart",this.updateCartPage).on("added_to_cart removed_from_cart",this.updateFragments)};t.prototype.onAddToCart=function(t){var a=e(this);if(a.is(".ajax_add_to_cart")){if(!a.attr("data-product_id"))return!0;t.preventDefault(),a.removeClass("added"),a.addClass("loading");var o={};e.each(a.data(),function(t,a){o[t]=a}),e(document.body).trigger("adding_to_cart",[a,o]),e.post(wc_add_to_cart_params.wc_ajax_url.toString().replace("%%endpoint%%","add_to_cart"),o,function(t){t&&(t.error&&t.product_url?window.location=t.product_url:"yes"!==wc_add_to_cart_params.cart_redirect_after_add?e(document.body).trigger("added_to_cart",[t.fragments,t.cart_hash,a]):window.location=wc_add_to_cart_params.cart_url)})}},t.prototype.onRemoveFromCart=function(t){var a=e(this),o=a.closest(".woocommerce-mini-cart-item");t.preventDefault(),o.block({message:null,overlayCSS:{opacity:.6}}),e.post(wc_add_to_cart_params.wc_ajax_url.toString().replace("%%endpoint%%","remove_from_cart"),{cart_item_key:a.data("cart_item_key")},function(t){t&&t.fragments?e(document.body).trigger("removed_from_cart",[t.fragments,t.cart_hash,a]):window.location=a.attr("href")}).fail(function(){window.location=a.attr("href")})},t.prototype.updateButton=function(t,a,o,r){(r=void 0!==r&&r)&&(r.removeClass("loading"),r.addClass("added"),wc_add_to_cart_params.is_cart||0!==r.parent().find(".added_to_cart").length||r.after(' '+wc_add_to_cart_params.i18n_view_cart+""),e(document.body).trigger("wc_cart_button_updated",[r]))},t.prototype.updateCartPage=function(){var t=window.location.toString().replace("add-to-cart","added-to-cart");e(".shop_table.cart").load(t+" .shop_table.cart:eq(0) > *",function(){e(".shop_table.cart").stop(!0).css("opacity","1").unblock(),e(document.body).trigger("cart_page_refreshed")}),e(".cart_totals").load(t+" .cart_totals:eq(0) > *",function(){e(".cart_totals").stop(!0).css("opacity","1").unblock(),e(document.body).trigger("cart_totals_refreshed")})},t.prototype.updateFragments=function(t,a){a&&(e.each(a,function(t){e(t).addClass("updating").fadeTo("400","0.6").block({message:null,overlayCSS:{opacity:.6}})}),e.each(a,function(t,a){e(t).replaceWith(a),e(t).stop(!0).css("opacity","1").unblock()}),e(document.body).trigger("wc_fragments_loaded"))},new t}); // source --> https://cvetok.in.ua/wp-content/plugins/wr-custom-attributes/assets/js/front-end.js?ver=5.0.11 /** * @version 1.0 * @package WR_Custom_Attributes * @author WooRockets Team * @copyright Copyright (C) 2014 WooRockets.com. All Rights Reserved. * @license GNU/GPL v2 or later http://www.gnu.org/licenses/gpl-2.0.html * * Websites: http://www.woorockets.com */ ( function( $ ) { $.init_wr_custom_attributes = function() { // Replace default attribute select box with custom attribute selector. $('select[data-attribute_name]').each(function(i, e) { var selector = $('#' + $(e).attr('id') + '_custom_attribute_selector'); if (selector.length) { $(e).before(selector.text()); selector.remove(); } else if ( ! $(e).prev('.wr-custom-attribute').length ) { $(e).addClass('active-attribute-selector'); } }); // Preload data for variation image gallery. var colors = $( '.wr-custom-attribute .has-image-gallery[data-value]' ), selected = $( '.wr-custom-attribute .selected .has-image-gallery[data-value]' ); delete window.wr_custom_attribute_data; if ( selected.length ) { // Load image gallery of the selected variation. switch_image_gallery( selected[0], false, true ); } if ( colors.length ) { // Load default image gallery of the product. switch_image_gallery( colors[0], true, false ); for (var i = 0; i < colors.length; i++) { if ( ! selected.length || colors[i] != selected[0] ) { setTimeout( (function(color) { return function() { switch_image_gallery( color, false, true ); }; })(colors[i]), 200 ); } } } else { // No variation image gallery available, show product image gallery. $( '.woocommerce-product-gallery' ).addClass( 'active-product-gallery' ); } // Initialize once... if (window._wr_custom_attributes_initialized) { return; } // Define function to switch between product image and variation image. window.wr_set_variation_attr = window.wr_set_variation_attr || $.fn.wc_variations_image_update; // Override WooCommerce function to update variation image. $.fn.wc_variations_image_update = function( variation ) { if ( variation && variation.thumb_image_src == null ) { return; } // Store variation data. window.wr_custom_variation = variation; // Update variation image. $( '.variations_form' ).each( function() { window.wr_set_variation_attr.call( $(this), variation ); } ); }; // Define function to switch product image gallery. function switch_image_gallery( elm, reset, preload ) { switch_image_gallery.preloading = switch_image_gallery.preloading || []; if ( $( elm ).hasClass( 'has-image-gallery' ) ) { // Get data from cache first. var cache = window.wr_custom_attribute_data || {}, option = $( elm ).closest( '[data-attribute]' ).attr( 'data-attribute' ), key = option + '::' + ( reset ? 'default' : $( elm ).attr( 'data-value' ) ); if ( cache[ key ] ) { // Switch image gallery. if ( preload ) { if ( $( elm ).parent().hasClass( 'selected' ) ) { $( elm ).trigger('click'); } } else { var html = $( cache[ key ] ), orig = $( '.' + html.attr('class').replace( /\s+/g, '.' ) ); if ( orig.length ) { var html_gallery = $( cache[ key ] ); // Update gallery HTML. orig.parent().html( html_gallery.addClass('active-product-gallery') ); // Update variation image. $( '.variations_form' ).each( function() { window.wr_set_variation_attr.call( $(this), window.wr_custom_variation ); } ); // Init product image gallery. if ( $.fn.wc_product_gallery ) { html_gallery.wc_product_gallery(); } } } } // No cached data found, request server for data once. else if (switch_image_gallery.preloading.indexOf(key) < 0) { var data = {}; if ( ! reset ) { data[ 'attribute_' + option ] = $( elm ).attr( 'data-value' ); } $.ajax( { url: $( elm ).attr( 'data-href' ), type: 'post', data: data, complete: function( response ) { // Update cache. var option = $( this ).closest( '[data-attribute]' ).attr( 'data-attribute' ), key = option + '::' + ( reset ? 'default' : $( this ).attr( 'data-value' ) ); window.wr_custom_attribute_data = window.wr_custom_attribute_data || {}; window.wr_custom_attribute_data[ key ] = response.responseText; // Switch image gallery. switch_image_gallery( this, reset, preload ); }, context: elm } ); switch_image_gallery.preloading.push(key); } } if ( $( '.flex-control-thumbs' ).length > 0 ) { var thumb = $( '.flex-control-thumbs li' ).length; if ( thumb > 5 ) { $( '.flex-control-thumbs' ).scrollbar(); } } } // Setup custom attribute selection. $(document).on( 'click', '.wr-custom-attribute [data-value]', function() { var option = $( this ).closest( '[data-attribute]' ).attr( 'data-attribute' ), select = $( 'select#' + option ); $( this ).parent().addClass( 'selected' ).siblings().removeClass( 'selected' ); // Update hidden option field. select.val( $( this ).attr( 'data-value' ) ).trigger( 'change' ); // Switch image gallery if available. switch_image_gallery( this ); } ); // Setup variation form selection. $( '.variations_form' ).addClass( 'wr_variations_form' ).on( 'change', 'select[data-attribute_name]', function() { // Auto-select option that has only 1 choice available. setTimeout( function() { $( '.variations_form select[data-attribute_name]' ).each( function( i, e ) { if ( $( e ).val() == '' && $( e ).children( '[value!=""]' ).length == 1 ) { $( e ).val( $( e ).children( '[value!=""]' ).attr( 'value' ) ).trigger( 'change' ); } } ); }, 50 ); // Refresh options available. $( '.wr-custom-attribute[data-attribute]' ).each( function( i, e ) { ( function( e ) { setTimeout( function() { var option = $( e ).attr( 'data-attribute' ), select = $( 'select#' + option ); $( e ).children().each( function( i2, e2 ) { if ( !select.children( '[value="' + $( e2 ).find( '[data-value]' ).attr( 'data-value' ) + '"]' ).length ) { $( e2 ).hide(); } else { $( e2 ).show(); } } ); }, 50 ); } )( e ); } ); } ); // Handle reset action. $( document ).on( 'click', 'a.reset_variations', function() { // Reset product image. $.fn.wc_variations_image_update(); // Reset product image gallery. switch_image_gallery( $( '.wr-custom-attribute .selected' ).children( '[data-value]' ), true ); // Reset custom attribute selection. $( '.wr-custom-attribute .selected' ).removeClass( 'selected' ); $( '.wr-custom-attribute .available-option' ).removeClass( 'available-option' ); } ); // Handle action when click to attribute on product list. $( 'body' ).on( 'click', '.product__attr a', function() { // Get variation image var img = $( this ).data( 'image' ); $( this ).parent().parent().parent().parent().find( '.product__image img' ).attr( 'src', img ) } ); window._wr_custom_attributes_initialized = true; }; if ( $.isReady ) { $.init_wr_custom_attributes(); } else { $( document ).ready( $.init_wr_custom_attributes ); } } )( jQuery ); // source --> https://cvetok.in.ua/wp-content/plugins/js_composer/assets/js/vendors/woocommerce-add-to-cart.js?ver=5.4.7 window.jQuery( document ).ready( function ( $ ) { $( 'body' ).on( 'adding_to_cart', function ( event, $button, data ) { $button && $button.hasClass( 'vc_gitem-link' ) && $button .addClass( 'vc-gitem-add-to-cart-loading-btn' ) .parents( '.vc_grid-item-mini' ) .addClass( 'vc-woocommerce-add-to-cart-loading' ) .append( $( '
' ) ); } ).on( 'added_to_cart', function ( event, fragments, cart_hash, $button ) { if ( 'undefined' === typeof($button) ) { $button = $( '.vc-gitem-add-to-cart-loading-btn' ); } $button && $button.hasClass( 'vc_gitem-link' ) && $button .removeClass( 'vc-gitem-add-to-cart-loading-btn' ) .parents( '.vc_grid-item-mini' ) .removeClass( 'vc-woocommerce-add-to-cart-loading' ) .find( '.vc_wc-load-add-to-loader-wrapper' ).remove(); } ); } );