PATH:
home
/
thebhoeo
/
.trash
/
woodmart
/
js
/
scripts
/
wc
/* global woodmart_settings */ (function($) { woodmartThemeModule.frequentlyBoughtTogether = function () { $('form.wd-fbt-form').each( function () { var timeout = ''; var $form = $(this); $form.on('change', '.wd-fbt-product input, .wd-fbt-product select', function () { var $this = $(this); var productsID = getProductsId($form); var mainProduct = $form.find('input[name=wd-fbt-main-product]').val(); var btn = $form.find('.wd-fbt-purchase-btn'); if ( ! productsID || 'undefined' === typeof productsID[mainProduct] ) { return; } if ( 2 > Object.keys(productsID).length ) { btn.addClass('wd-disabled'); } else { btn.removeClass('wd-disabled'); } var $carousel = $form.parents('.wd-fbt').find('.wd-carousel'); var index = $this.parents('.wd-fbt-product').index(); if ( 'undefined' !== typeof $carousel[0].swiper && ! $($carousel.find('.wd-carousel-item')[index]).hasClass('wd-active') ) { if ( 1 === index && 1 < $carousel[0].swiper.slides.length ) { index = 0; } if ( 'undefined' !== typeof $carousel[0].swiper.slideTo ) { $carousel[0].swiper.slideTo(index, 500); } } clearTimeout(timeout); timeout = setTimeout(function () { updatePrice($form, productsID); }, 1000); }); $form.on('change', '.wd-fbt-product select', function () { var $this = $(this); var productID = $this.parents('.wd-fbt-product').data('id'); var productWrapper = $this.parents('.wd-fbt').find('.wd-product[data-id=' + productID + ']'); var $img = productWrapper.find('.product-image-link > img, .product-image-link > picture > img'); var imageSrc = $this.find('option:selected').data('image-src'); var imageSrcset = $this.find('option:selected').data('image-srcset'); if ( $img.attr('srcset') ) { if ( ! imageSrcset ) { imageSrcset = imageSrc; } $img.attr('srcset', imageSrcset); } $img.attr('src', imageSrc); }); $form.on('click', '.wd-fbt-purchase-btn', function (e) { e.preventDefault(); var $this = $(this); if ( $this.hasClass('wd-disabled') ) { return; } var productsID = getProductsId($form); var mainProduct = $form.find('input[name=wd-fbt-main-product]').val(); var bundlesId = $form.find('input[name=wd-fbt-bundle-id]').val(); if ( ! productsID || 'undefined' === typeof productsID[mainProduct] ) { return; } clearTimeout(timeout); $this.addClass('loading'); $.ajax({ url : woodmart_settings.ajaxurl, data : { action : 'woodmart_purchasable_fbt_products', products_id : productsID, main_product : mainProduct, bundle_id : bundlesId, }, method : 'POST', success : function(response) { var $noticeWrapper = $('.woocommerce-notices-wrapper'); $noticeWrapper.empty(); if (response.notices && response.notices.indexOf('error') > 0) { $noticeWrapper.append(response.notices); var scrollTo = $noticeWrapper.offset().top - woodmart_settings.ajax_scroll_offset; $('html, body').stop().animate({ scrollTop: scrollTo }, 400); return; } if ('undefined' !== typeof response.fragments) { if ('undefined' !== typeof $.fn.magnificPopup && woodmart_settings.add_to_cart_action === 'widget') { $.magnificPopup.close(); } $this.addClass('added'); woodmartThemeModule.$body.trigger('added_to_cart', [ response.fragments, response.cart_hash, jQuery() ]); } }, error : function() { console.log('ajax error'); }, complete: function() { $this.removeClass('loading'); } }); }); }); function getProductsId($form) { var productsID = {}; $form.find('.wd-fbt-product').each( function () { var $this = $(this); var $input = $(this).find('input'); var productId = $this.data('id'); var productWrapper = $form.parents('.wd-fbt'); if ( $input.length ) { if ( $input.is(':checked') ) { if ( $this.find('.wd-fbt-product-variation').length ) { productsID[productId] = $this.find('.wd-fbt-product-variation select').val(); } else { productsID[productId] = ''; } productWrapper.find('.product.post-' + productId ).removeClass('wd-disabled-fbt'); } else if ( ! $input.parents('.wd-fbt-form').hasClass('wd-checkbox-uncheck') ) { productWrapper.find('.product.post-' + productId).addClass('wd-disabled-fbt'); } } else { if ( $this.find('.wd-fbt-product-variation').length ) { productsID[productId] = $this.find('.wd-fbt-product-variation select').val(); } else { productsID[productId] = ''; } } }); return productsID; } function updatePrice( $wrapper, productsID ) { var mainProduct = $wrapper.find('input[name=wd-fbt-main-product]').val(); var bundleId = $wrapper.find('input[name=wd-fbt-bundle-id]').val(); $wrapper.find('.wd-loader-overlay').addClass( 'wd-loading' ); $.ajax({ url : woodmart_settings.ajaxurl, data : { action : 'woodmart_update_frequently_bought_price', products_id : productsID, main_product: mainProduct, bundle_id : bundleId, }, method : 'POST', success : function(response) { if (response.fragments) { $.each( response.fragments, function( key, value ) { $( key ).replaceWith(value); }); } }, error : function() { console.log('ajax error'); }, complete: function() { $wrapper.find('.wd-loader-overlay').removeClass('wd-loading'); } }); } } $(document).ready(function() { woodmartThemeModule.frequentlyBoughtTogether(); }); })(jQuery);
[+]
..
[-] filtersArea.min.js
[edit]
[-] quickShop.min.js
[edit]
[-] loginSidebar.js
[edit]
[-] shopLoader.min.js
[edit]
[-] woocommerceWrappTable.min.js
[edit]
[-] abandonedCart.min.js
[edit]
[-] product360Button.min.js
[edit]
[-] swatchesLimit.js
[edit]
[-] frequentlyBoughtTogether.js
[edit]
[-] quickShopVariationForm.min.js
[edit]
[-] trackProductViewed.min.js
[edit]
[-] frequentlyBoughtTogether.min.js
[edit]
[-] sortByWidget.js
[edit]
[-] woocommerceQuantity.min.js
[edit]
[-] stickyDetails.min.js
[edit]
[-] filterDropdowns.min.js
[edit]
[-] commentImage.min.js
[edit]
[-] woocommerceQuantity.js
[edit]
[-] singleProductTabsAccordion.js
[edit]
[-] addToCartAllTypes.min.js
[edit]
[-] swatchesVariations.min.js
[edit]
[-] loginTabs.js
[edit]
[-] categoriesAccordion.min.js
[edit]
[-] checkoutRemoveBtn.min.js
[edit]
[-] productImagesGallery.js
[edit]
[-] singleProductTabsSideHidden.js
[edit]
[-] stickyAddToCart.js
[edit]
[-] swatchesVariations.js
[edit]
[-] imagesGalleryInLoop.min.js
[edit]
[-] quickShop.js
[edit]
[-] product360Button.js
[edit]
[-] initZoom.js
[edit]
[-] emailSubscriptionCheckboxes.min.js
[edit]
[-] headerCategoriesMenu.js
[edit]
[-] headerCategoriesMenu.min.js
[edit]
[-] freeGiftsTable.js
[edit]
[-] wishlist.min.js
[edit]
[-] checkoutQuantity.min.js
[edit]
[-] ptSubscribeForm.min.js
[edit]
[-] productHover.js
[edit]
[-] updateAjaxDeliveryDates.js
[edit]
[-] productMoreDescription.min.js
[edit]
[-] woocommercePriceSlider.min.js
[edit]
[-] productImages.js
[edit]
[-] productReviewsLikes.min.js
[edit]
[-] filterDropdowns.js
[edit]
[-] singleProductTabsAccordion.min.js
[edit]
[-] shopMasonry.min.js
[edit]
[-] woodmartCompare.js
[edit]
[-] searchByFilters.js
[edit]
[-] gridQuantity.min.js
[edit]
[-] swatchesOnGrid.js
[edit]
[-] productsLoadMore.min.js
[edit]
[-] productGalleryVideo.js
[edit]
[-] variationsPrice.min.js
[edit]
[-] productReviewsCriteria.js
[edit]
[-] emailSubscriptionCheckboxes.js
[edit]
[-] freeGiftsTable.min.js
[edit]
[-] dynamicDiscountsTable.min.js
[edit]
[-] waitlistTable.min.js
[edit]
[-] abandonedCart.js
[edit]
[-] shopMasonry.js
[edit]
[-] wishlistGroup.js
[edit]
[-] wishlist.js
[edit]
[-] checkoutFields.js
[edit]
[-] addToCartAllTypes.js
[edit]
[-] imagesGalleryInLoop.js
[edit]
[-] productReviews.js
[edit]
[-] waitlistSubscribeForm.min.js
[edit]
[-] categoriesDropdowns.min.js
[edit]
[-] filtersArea.js
[edit]
[-] cartWidget.min.js
[edit]
[-] estimateDeliveryOnCart.js
[edit]
[-] productRecentlyViewed.min.js
[edit]
[-] woocommerceWrappTable.js
[edit]
[-] waitlistSubscribeForm.js
[edit]
[-] productReviewsLikes.js
[edit]
[-] checkoutRemoveBtn.js
[edit]
[-] cartQuantity.min.js
[edit]
[-] productMoreDescription.js
[edit]
[-] ptSubscribeForm.js
[edit]
[-] shopPageInit.js
[edit]
[-] countProductVisits.min.js
[edit]
[-] loginDropdown.min.js
[edit]
[-] productReviewsCriteria.min.js
[edit]
[-] loginDropdown.js
[edit]
[-] actionAfterAddToCart.min.js
[edit]
[-] miniCartQuantity.js
[edit]
[-] woodmartCompare.min.js
[edit]
[-] searchByFilters.min.js
[edit]
[-] miniCartQuantity.min.js
[edit]
[-] updateCartFragmentsFix.min.js
[edit]
[-] waitlistTable.js
[edit]
[-] woocommerceNotices.min.js
[edit]
[-] onRemoveFromCart.min.js
[edit]
[-] quickShopVariationForm.js
[edit]
[-] categoriesAccordion.js
[edit]
[-] singleProductTabsSideHidden.min.js
[edit]
[-] loginTabs.min.js
[edit]
[-] checkoutFields.min.js
[edit]
[-] estimateDeliveryOnCart.min.js
[edit]
[-] productFilters.js
[edit]
[-] wishlistGroup.min.js
[edit]
[-] productRecentlyViewed.js
[edit]
[-] productFilters.min.js
[edit]
[-] shopLoader.js
[edit]
[-] productHover.min.js
[edit]
[-] quickView.min.js
[edit]
[-] checkoutQuantity.js
[edit]
[-] cartWidget.js
[edit]
[-] onRemoveFromCart.js
[edit]
[-] quickView.js
[edit]
[-] woocommerceComments.js
[edit]
[-] countProductVisits.js
[edit]
[-] dynamicDiscountsTable.js
[edit]
[-] loginSidebar.min.js
[edit]
[-] woocommerceComments.min.js
[edit]
[-] swatchesOnGrid.min.js
[edit]
[-] cartQuantity.js
[edit]
[-] productImagesGallery.min.js
[edit]
[-] updateAjaxDeliveryDates.min.js
[edit]
[-] gridQuantity.js
[edit]
[-] stickySidebarBtn.min.js
[edit]
[-] productVideo.min.js
[edit]
[-] variationsPrice.js
[edit]
[-] productReviews.min.js
[edit]
[-] woocommerceNotices.js
[edit]
[-] ajaxFilters.js
[edit]
[-] productImages.min.js
[edit]
[-] trackProductViewed.js
[edit]
[-] ptTable.min.js
[edit]
[-] actionAfterAddToCart.js
[edit]
[-] stickyAddToCart.min.js
[edit]
[-] ptTable.js
[edit]
[-] swatchesLimit.min.js
[edit]
[-] shopPageInit.min.js
[edit]
[-] productVideo.js
[edit]
[-] productGalleryVideo.min.js
[edit]
[-] ajaxFilters.min.js
[edit]
[-] stickyDetails.js
[edit]
[-] productsLoadMore.js
[edit]
[-] woocommercePriceSlider.js
[edit]
[-] sortByWidget.min.js
[edit]
[-] commentImage.js
[edit]
[-] productsTabs.min.js
[edit]
[-] productsTabs.js
[edit]
[-] categoriesDropdowns.js
[edit]
[-] initZoom.min.js
[edit]
[-] updateCartFragmentsFix.js
[edit]
[-] stickySidebarBtn.js
[edit]