https://pacer.kr/wp-content/plugins/woolentor-addons-pro/assets/js/woolentor-quick-cart.js?ver=2.4.5
1;(function($){ 2"use strict"; 3 4 $(document).on( 'click', '.ht-product.quick-cart-enable .product_type_variable.add_to_cart_button', function (e) { 5 e.preventDefault(); 6 7 var $this = $(this), 8 $product = $this.parents('.ht-product').first(), 9 $content = $product.find('.woolentor-quick-cart-form'), 10 id = $product.data('id'), 11 btn_loading_class = 'loading'; 12 13 if ($this.hasClass(btn_loading_class)) return; 14 15 // Show Form 16 if ( $product.hasClass('quick-cart-loaded') ) { 17 $product.addClass('quick-cart-open'); 18 return; 19 } 20 21 var data = { 22 action: 'woolentor_pro_quick_cart', 23 id: id 24 }; 25 $.ajax({ 26 type: 'post', 27 url: woolentor_quick_cart.ajax_url, 28 data: data, 29 beforeSend: function (response) { 30 $this.addClass(btn_loading_class); 31 $product.addClass('loading-quick-cart'); 32 }, 33 success: function (response) { 34 $content.append( response ); 35 woolentor_render_variation_data( $product ); 36 woolentor_variation_data( $product ); 37 woolentor_inser_to_cart(); 38 }, 39 complete: function (response) { 40 setTimeout(function () { 41 $this.removeClass(btn_loading_class); 42 $product.removeClass('loading-quick-cart'); 43 $product.addClass('quick-cart-open quick-cart-loaded'); 44 }, 100); 45 46 $( document ).trigger('woolentor_quick_cart_rendered' ); 47 48 }, 49 }); 50 51 return false; 52 53 }); 54 55 $(document).on('click', '.woolentor-quick-cart-close', function () { 56 var $this = $(this), 57 $product = $this.parents('.ht-product'); 58 $product.removeClass('quick-cart-open'); 59 }); 60 61 $(document.body).on('added_to_cart', function () { 62 $('.ht-product').removeClass('quick-cart-open'); 63 }); 64 65 /** 66 * [woolentor_render_variation_data] show variation data 67 * @param {[selector]} $product 68 * @return {[void]} 69 */ 70 function woolentor_render_variation_data( $product ) { 71 $product.find('.variations_form').wc_variation_form().find('.variations select:eq(0)').change(); 72 $product.find('.variations_form').trigger('wc_variation_form'); 73 } 74 75 /** 76 * [woolentor_variation_data] change image data after variation change 77 * @param {[selector]} $product 78 * @return {[void]} 79 */ 80 function woolentor_variation_data( $product ){ 81 82 var $default_data = { 83 src:'', 84 srcset:'', 85 sizes:'', 86 width:'', 87 height:'', 88 }; 89 90 $( '.single_variation_wrap' ).on( 'show_variation', function ( event, variation ) { 91 92 // Get First image data 93 if( $default_data.src.length === 0 ){ 94 $default_data.src = $product.find('.ht-product-image img').attr('src'); 95 $default_data.srcset = $product.find('.ht-product-image img').attr('srcset'); 96 $default_data.sizes = $product.find('.ht-product-image img').attr('sizes'); 97 $default_data.width = $product.find('.ht-product-image img').attr('width'); 98 $default_data.height = $product.find('.ht-product-image img').attr('height'); 99 } 100 101 // Set variation image 102 $product.find('.ht-product-image img').wc_set_variation_attr('src',variation.image.full_src); 103 $product.find('.ht-product-image img').wc_set_variation_attr('srcset',variation.image.srcset); 104 $product.find('.ht-product-image img').wc_set_variation_attr('sizes',variation.image.sizes); 105 $product.find('.ht-product-image img').wc_set_variation_attr('width',variation.image.full_src_w); 106 $product.find('.ht-product-image img').wc_set_variation_attr('height',variation.image.full_src_h); 107 108 }); 109 110 // Reset data 111 $product.find('.reset_variations').on('click', function(e){
112 woolentor_variation_data_reset( $product, $default_data ); 113 }); 114 115 } 116 117 /** 118 * [woolentor_variation_data_reset] data reset 119 * @param {[type]} $product target product 120 * @param {[type]} $data data 121 * @return {[type]} void 122 */ 123 function woolentor_variation_data_reset( $product, $data ){ 124 $product.find('.ht-product-image img').wc_set_variation_attr('src',$data.src); 125 $product.find('.ht-product-image img').wc_set_variation_attr('srcset',$data.srcset); 126 $product.find('.ht-product-image img').wc_set_variation_attr('sizes',$data.sizes); 127 $product.find('.ht-product-image img').wc_set_variation_attr('width',$data.width); 128 $product.find('.ht-product-image img').wc_set_variation_attr('height',$data.height); 129 } 130 131 /** 132 * [woolentor_inser_to_cart] Add to cart 133 * @return {[void]} 134 */ 135 function woolentor_inser_to_cart(){ 136 137 $(document).on( 'click', '.woolentor-quick-cart-form .single_add_to_cart_button:not(.disabled)', function (e) { 138 e.preventDefault(); 139 140 var $this = $(this), 141 $form = $this.closest('form.cart'), 142 all_data = $form.serialize(), 143 product_qty = $form.find('input[name=quantity]').val() || 1, 144 product_id = $form.find('input[name=product_id]').val() || $this.val(), 145 variation_id = $form.find('input[name=variation_id]').val() || 0; 146 147 /* For Variation product */ 148 var item = {}, 149 variations = $form.find( 'select[name^=attribute]' ); 150 if ( !variations.length) { 151 variations = $form.find( '[name^=attribute]:checked' ); 152 } 153 if ( !variations.length) {
154 variations = $form.find( 'input[name^=attribute]' ); 155 } 156 157 variations.each( function() { 158 var $thisitem = $( this ), 159 attributeName = $thisitem.attr( 'name' ), 160 attributevalue = $thisitem.val(), 161 index, 162 attributeTaxName; 163 $thisitem.removeClass( 'error' ); 164 if ( attributevalue.length === 0 ) { 165 index = attributeName.lastIndexOf( '_' ); 166 attributeTaxName = attributeName.substring( index + 1 ); 167 $thisitem.addClass( 'required error' ); 168 } else { 169 item[attributeName] = attributevalue; 170 } 171 }); 172 173 var data = { 174 // action: 'woolentor_insert_to_cart', 175 product_id: product_id, 176 product_sku: '', 177 quantity: product_qty, 178 variation_id: variation_id, 179 variations: item, 180 all_data: all_data, 181 }; 182 183 var alldata = data.all_data + '&product_id='+ data.product_id + '&product_sku='+ data.product_sku + '&quantity='+ data.quantity + '&variation_id='+ data.variation_id + '&variations='+ JSON.stringify( data.variations ); 184 185 $( document.body ).trigger('adding_to_cart', [$this, data]); 186 187 $.ajax({
188 type: 'POST', 189 url: $form.attr('action') + '/?wc-ajax=woolentor_single_insert_to_cart', 190 data: alldata, 191 192 beforeSend: function (response) { 193 $this.removeClass('added').addClass('loading'); 194 }, 195 196 complete: function (response) { 197 $this.addClass('added').removeClass('loading'); 198 }, 199 200 success: function (response) { 201 if ( response.error & response.product_url ) { 202 window.location = response.product_url; 203 return; 204 } else { 205 $(document.body).trigger('added_to_cart', [response.fragments, response.cart_hash, $this]); 206 } 207 }, 208 209 }); 210 211 return false; 212 }); 213 214 } 215 216})(jQuery);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.