1$(document).ready(function () { 2 3 function setCancelLP(){ 4 var mess = jQuery(".woocommerce-message").html(); 5 if(mess.search('pretplata je otkazana') !== -1){ 6 window.location.href = 'https://vp.sales-snap.com/page/preview/10'; 7 8 clearTimeout(iniTimeout); 9 } 10 } 11 12 if(jQuery(".woocommerce-message").length){ 13 const iniTimeout = setTimeout(setCancelLP, 3000); 14 } 15 16 //single product amount 17 $(document).on('click', '.q-plus', function (e) { 18 e.preventDefault(); 19 let currentValue = $(this).prev().val().trim(); 20 let maxValue = $(this).prev().attr('max').trim(); 21 if (isNaN(currentValue) || currentValue < 0) { 22 $(this).prev().val(1); 23 return; 24 } 25 currentValue = Number(currentValue); 26 if (currentValue < maxValue) { 27 currentValue += 1; 28 } else { 29 $(this).prev().val(maxValue); 30 return; 31 } 32 33 $(this).prev().val(currentValue); 34 }); 35 36 $(document).on('click', '.q-minus', function (e) { 37 e.preventDefault(); 38 let currentValue = $(this).next().val().trim(); 39 if (isNaN(currentValue) || currentValue < 0) { 40 $(this).next().val(1); 41 return; 42 } 43 if (currentValue > 1) { 44 currentValue = Number(currentValue); 45 currentValue -= 1; 46 $(this).next().val(currentValue); 47 } 48 }); 49 50 //Save gift data 51 $(document).on('click', 'button#place_order', function (e) { 52 let gift_billing_email = $("#gift_billing_email").val(); 53 let gift_billing_first_name = $("#gift_billing_first_name").val(); 54 let gift_billing_last_name = $("#gift_billing_last_name").val(); 55 56 let data = { 57 action: 'woocommerce_ajax_save_gift_data', 58 gift_billing_email: gift_billing_email, 59 gift_billing_first_name: gift_billing_first_name, 60 gift_billing_last_name: gift_billing_last_name 61 }; 62 63 $.ajax({ 64 type: 'post', 65 url: '/wp-admin/admin-ajax.php', 66 data: data, 67 beforeSend: function (response) { 68 }, 69 complete: function (response) { 70 }, 71 success: function (response) { 72 }, 73 }); 74 }); 75 76 //Add To Cart Submiter 77 $(document).on('click', 'a.cubestheme-add-to-cart-form', function (e) { 78 e.preventDefault(); 79 80 let product_id = $(this).data("product_id"); 81 let news_id = $(this).data("news_id"); 82 let variation_id = $(this).data("variation_id"); 83 let product_qty = $(this).data("quantity"); product_qty = parseInt(product_qty); 84 let cart_button = $(this).find("p.c-t-a"); 85 let product_sku = $(this).data("sku"); 86 let gift = $(this).data("gift"); 87 var target_href = $(this).attr('href'); 88 89 let product_name = $(this).data("product_name"); 90 let product_img = $(".product-img." + product_id + " img").attr("src"); 91 92 let data = { 93 action: 'woocommerce_ajax_add_to_cart', 94 product_id: product_id, 95 news_id: news_id, 96 product_sku: product_sku, 97 quantity: product_qty, 98 variation_id: variation_id, 99 gift: gift 100 }; 101 102 $.ajax({ 103 type: 'post', 104 //url: wc_add_to_cart_params.ajax_url, 105 url: '/wp-admin/admin-ajax.php', 106 data: data, 107 beforeSend: function (response) { 108 $(".se-pre-con").fadeIn("fast"); 109 }, 110 complete: function (response) { 111 //$(".se-pre-con").fadeIn("show"); 112 }, 113 success: function (response) { 114 if (response.error & response.product_url) { 115 window.location = response.product_url; 116 return; 117 } else { 118 119 if(gift == '1') 120 document.location.href = target_href + "?gift=1"; 121 else 122 document.location.href = target_href; 123 //alert(1); 124 125 /* 126 cart_button.html('Dodato u korpu!'); 127 128 $(".cubestheme-cart-items").html(response.cart_items); 129 $(".cart-icon span").html(response.items_counter); 130 $(".cubestheme-cart-items-counter").html("(" + response.items_counter + ")"); 131 $(".cubestheme-cart-total").html(response.cart_total); 132 133 showCart(); 134 $(".cart-icon.toggle-cart").trigger('click'); */ 135 136 137 } 138 }, 139 }); 140 141 setTimeout(function () { cart_button.html('Dodaj u korpu'); }, 3000); 142 }); 143 //Delete item from cart 144 $(document).on('click', 'a.delete-product', function (e) { 145 e.preventDefault(); 146 147 let item_key = $(this).attr('data-cart-key'); 148 let product_qty = 0; 149 150 $.ajax({ 151 type: 'POST', 152 //url: wc_add_to_cart_params.ajax_url, 153 url: '/wp-admin/admin-ajax.php', 154 data: { 155 action: 'woocommerce_ajax_update_cart_qty', 156 hash: item_key, 157 quantity: product_qty 158 }, 159 success: function (response) { 160 $(".cubestheme-cart-items-counter").html("(" + response.items_counter + ")"); 161 $(".cubestheme-cart-total").html(response.cart_total); 162 $(".product-item." + item_key).remove(); 163 $(".cart-icon span").html(response.items_counter); 164 showCart(); 165 166 //$(document.body).trigger('added_to_cart', [response.fragments, response.cart_hash, $thisbutton]); 167 //$(document.body).trigger('update_checkout'); 168 } 169 }); 170 }); 171 //Update item from cart 172 $(document).on('click', '.update-cart-per-item', function (e) { 173 e.preventDefault(); 174 175 let item_key = $(this).attr('data-cart-key'); 176 let product_qty = $(".quantity." + item_key).val(); 177 178 $.ajax({ 179 type: 'POST', 180 //url: wc_add_to_cart_params.ajax_url, 181 url: '/wp-admin/admin-ajax.php', 182 data: { 183 action: 'woocommerce_ajax_update_cart_qty', 184 hash: item_key, 185 quantity: product_qty 186 }, 187 success: function (response) { 188 $(".cubestheme-cart-items-counter").html("(" + response.items_counter + ")"); 189 $(".cubestheme-cart-total").html(response.cart_total); 190 $(".cart-icon span").html(response.items_counter); 191 //$(document.body).trigger('added_to_cart', [response.fragments, response.cart_hash, $thisbutton]); 192 //$(document.body).trigger('update_checkout'); 193 } 194 }); 195 }); 196 197 //Add To Cart Submiter 198 $(document).on('submit', 'form.variations_form', function (e) { 199 e.preventDefault(); 200 201 let product_id = $(this).find("input[name='product_id']").val(); 202 let variation_id = $(this).find("input[name='variation_id']").val(); 203 let product_qty = $(this).find("input[name='quantity']").val(); product_qty = parseInt(product_qty); 204 let cart_button = $(this).find("button[name='add-to-cart']"); 205 206 let data = { 207 action: 'woocommerce_ajax_add_to_cart', 208 product_id: product_id, 209 quantity: product_qty, 210 variation_id: variation_id, 211 }; 212 213 $.ajax({ 214 type: 'post', 215 url: wc_add_to_cart_params.ajax_url, 216 data: data, 217 beforeSend: function (response) { 218 // $(".se-pre-con").fadeIn("fast"); 219 }, 220 complete: function (response) { 221 // $(".se-pre-con").fadeOut("show"); 222 }, 223 success: function (response) { 224 if (response.error & response.product_url) { 225 window.location = response.product_url; 226 return; 227 } else { 228 cart_button.html('Dodato u korpu!'); 229 /* 230 $(".cubestheme-cart-items").html(response.cart_items); 231 $(".cart-icon span").html(response.items_counter); 232 $(".cubestheme-cart-items-counter").html("(" + response.items_counter + ")"); 233 $(".cubestheme-cart-total").html(response.cart_total); 234 */ 235 showCart(); 236 237 $(".cart-icon.toggle-cart").trigger('click'); 238 } 239 }, 240 }); 241 242 setTimeout(function () { cart_button.html('Dodaj u korpu'); }, 3000); 243 }); 244 245 $(document).on('click', '.save_to_stories', function (e) { 246 247 var obj = $( this ); 248 var post_id = obj.attr("data-post_id"); 249 post_id = parseInt(post_id); 250 251 var target_action = "insert"; 252 if( obj.hasClass("added-to-stories") ){ 253 target_action = "delete"; 254 } 255 256 if(post_id > 0){ 257 var data = { 258 action: 'wordpress_ajax_add_to_saved_stories', 259 post_id: post_id, 260 target_action: target_action, 261 }; 262 263 $.ajax({ 264 type: 'post', 265 url: '/wp-admin/admin-ajax.php', 266 data: data, 267 beforeSend: function (response) { 268 // 269 }, 270 complete: function (response) { 271 // 272 }, 273 success: function (response) { 274 if(response.status == 'done'){ 275 if( obj.hasClass("added-to-stories") ){ 276 obj.removeClass("added-to-stories"); 277 obj.text('SAÄUVAJ ZA ÄITANJE'); 278 279 if( $(".news_" + post_id).length ){ 280 $(".news_" + post_id).remove(); 281 } 282 }else{ 283 obj.addClass("added-to-stories"); 284 obj.text('UKLONI IZ SAÄUVANIH'); 285 } 286 }else{ 287 alert(response.message); 288 } 289 }, 290 }); 291 } 292 }); 293 294 /* 295 //Add To Subscribe 296 $(document).on('click', 'button#place_order', function (e) { 297 298 var subscribe = false;
299 if ($("input[name='newsletter']").prop("checked")) { 300 var email = $("input[name='billing_email']").val(); 301 var gresponse = ""; 302 var checkout = 1; 303 304 var data = { 305 action: 'wordpress_ajax_mailchimp_subcribe', 306 email: email, 307 gresponse: gresponse, 308 checkout: checkout 309 }; 310 311 $.ajax({ 312 type: 'post', 313 url: '/wp-admin/admin-ajax.php', 314 data: data, 315 beforeSend: function (response) { 316 cart_button.removeClass('added').addClass('loading'); 317 }, 318 complete: function (response) { 319 cart_button.addClass('added').removeClass('loading'); 320 }, 321 success: function (response) { 322 if ($("p.feedback-message").length) { 323 if (response.error) { 324 $("p.feedback-message").html(response.message); 325 return; 326 } else { 327 $("p.feedback-message").html(response.message); 328 $(document.body).trigger('added_to_cart', [response.fragments, response.cart_hash, cart_button]); 329 } 330 } 331 }, 332 }); 333 } 334 }); 335 336 //Newsletter Subscription 337 jQuery(document).on('submit', 'form.newsletter-form', function (e) { 338 e.preventDefault(); 339 340 var email = $(this).find("input[name='subscriber_email']").val(); 341 if ($(this).find("input[name='g-recaptcha-response']").length) 342 var gresponse = $(this).find("input[name='g-recaptcha-response']").val(); 343 else 344 var gresponse = ""; 345 var checkout = 1; 346 347 var data = { 348 action: 'wordpress_ajax_mailchimp_subcribe', 349 email: email, 350 gresponse: gresponse, 351 checkout: checkout 352 }; 353 354 $.ajax({ 355 type: 'post', 356 url: '/wp-admin/admin-ajax.php', 357 data: data, 358 beforeSend: function (response) { 359 //cart_button.removeClass('added').addClass('loading'); 360 }, 361 complete: function (response) { 362 //cart_button.addClass('added').removeClass('loading'); 363 }, 364 success: function (response) { 365 if (response.error) { 366 jQuery("p.feedback-message").html(response.message); 367 return; 368 } else { 369 jQuery("p.feedback-message").html(response.message); 370 //$(document.body).trigger('added_to_cart', [response.fragments, response.cart_hash, cart_button]); 371 } 372 }, 373 }); 374 }); 375 */ 376 377}); 378 379function showCart() { 380 //Load cart 381 let data = { 382 action: 'woocommerce_ajax_show_cart', 383 }; 384 385 jQuery.ajax({ 386 type: 'post', 387 url: wc_add_to_cart_params.ajax_url, 388 data: data, 389 beforeSend: function (response) { 390 }, 391 complete: function (response) { 392 }, 393 success: function (response) { 394 if (response.error) { 395 window.location = window.location; 396 return; 397 } else { 398 jQuery(".cart-icon span").html(response.items_counter); 399 400 jQuery(".cubestheme-cart-items").html(response.cart_items); 401 jQuery(".cubestheme-cart-items-counter").html("(" + response.items_counter + ")"); 402 jQuery(".cubestheme-cart-total").html(response.cart_total); 403 } 404 }, 405 }); 406 407} 408jQuery(document).ready(function ($) { 409 if (typeof cubestheme_ajax === 'undefined') { 410 return; 411 } 412 413 $.ajax({ 414 url: cubestheme_ajax.ajax_url, 415 type: 'POST', 416 dataType: 'json', 417 data: { 418 action: 'wordpress_ajax_show_post_content', 419 post_id: cubestheme_ajax.post_id, 420 lang: cubestheme_ajax.lang 421 }, 422 success: function (response) { 423 if (!response || response.status !== 'done') { 424 return; 425 } 426 427 console.log('AJAX response:', response); 428 429 if (response.access) { 430 if (response.content) { 431 $('.main_post_content').html(response.content); 432 } 433 } 434 435 if (response.message) { 436 $('#free_posts_info').html(response.message); 437 } 438 }, 439 error: function (xhr, status, error) { 440 console.log('AJAX error:', error); 441 } 442 }); 443}); 444//showCart();
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.