1 2/** 3 * ÐлобалÑнÑе 4 */ 5var nonce_product = 0; 6var mini_loader = '#pm_status'; 7var this_page = window.location.toString(); 8var site_lang = document.documentElement.getAttribute('lang'); 9///// 10 11//пÑи POST Ñо ÑÑÑаниÑÑ ÑоваÑа 12if ( typeof(post_add_to_cart_show_modal) !== 'undefined' && post_add_to_cart_show_modal === 1 ) { 13 dds_show_modal_success( post_add_to_cart_show_modal_price, 500, post_add_to_cart_show_modal_title ); 14} 15 16 17/** 18 * ======= 19 * FUNCTIONS 20 * ======= 21 */ 22 23/** 24 * ÐоказÑваем окно */ 25 26function dds_show_modal_success(t, a, e) { 27 $ = jQuery, "undefined" == typeof a && (a = 0), setTimeout(function () { 28 var $add_message_text = '<div class="modal-product-title"> Ð¢Ð¾Ð²Ð°Ñ <span style="color:#ec907e;">' + e + '</span> на ÑÑÐ¼Ð¼Ñ ' + t + ' добавлен в <span style="color:#ec907e;"> коÑÐ·Ð¸Ð½Ñ </span></div>'; 29 if(site_lang == 'uk') { 30 $add_message_text = '<div class="modal-product-title"> Ð¢Ð¾Ð²Ð°Ñ <span style="color:#ec907e;">' + e + '</span> на ÑÑÐ¼Ñ ' + t + ' доданий до <span style="color:#ec907e;"> коÑика </span></div>'; 31 } 32 $(".message_cart").html($add_message_text); 33 $(".message_cart").css("display", "flex").animate({ 34 opacity: 1, 35 bottom: "0" 36 }, 200), 37 setTimeout(function () { 38 $(".message_cart").animate({ 39 opacity: 0, 40 bottom: "0" 41 }, 300, function () { 42 $(this).css("display", "none"), $("#overlay").fadeOut(400) 43 }) 44 }, 1500) 45 }, a) 46} 47/** 48 * УвелиÑиваем или ÑменÑÑаем кол-во пÑодÑкÑа в мини коÑзине 49 */ 50function dds_send_pm( pm, $thisbutton) { 51 52 $ = jQuery; 53 54 $(mini_loader).show(); 55 56 // var key = $thisbutton.parents('li').attr('data-key'); 57 var key = $thisbutton.attr('data-key'); 58 59 //ÐапÑÐ¾Ñ 60 $.post( 61 woocommerce_params.wc_ajax_url.toString().replace( '%%endpoint%%', 'pm_item_custom' ), 62 { 63 pm_action: pm, 64 cart_item_key: key, 65 _wpnonce: nonce_product 66 }, 67 function( response ) { 68 69 if ( ! response ) { 70 $(mini_loader).hide(); 71 return; 72 } 73 74 if ( response.error && response.product_url ) { 75 window.location = response.product_url; 76 return; 77 } 78 79 //пиÑем новÑе даннÑе в sessionStorage 80 $( 'body' ).trigger( 'added_to_cart', [ response.watatsumi, response.cart_hash ] ); 81 $(mini_loader).hide(); 82 } 83 ); 84} 85 86/** 87 * УбиÑаем пÑодÑÐºÑ Ð¸Ð· коÑÐ·Ð¸Ð½Ñ 88 */ 89function dds_remove_product( $thisbutton ) { 90 $ = jQuery; 91 $(mini_loader).show(); 92 var key = $thisbutton.attr('data-key'); 93 94 //ÐапÑÐ¾Ñ 95 $.post( 96 woocommerce_params.wc_ajax_url.toString().replace( '%%endpoint%%', 'remove_item_custom' ), 97 { 98 remove_item_custom: key, 99 _wpnonce: nonce_product 100 }, 101 function( response ) { 102 103 if ( ! response ) { 104 $(mini_loader).hide(); 105 return; 106 } 107 108 if ( response.error && response.product_url ) { 109 window.location = response.product_url; 110 return; 111 } 112 113 //пиÑем новÑе даннÑе в sessionStorage 114 $( 'body' ).trigger( 'added_to_cart', [ response.watatsumi, response.cart_hash ] ); 115 $(mini_loader).hide(); 116 } 117 ); 118 119} 120 121/** 122 * ======= 123 * DOCUMENT READY 124 * ======= 125 */ 126 127/** 128 * Custom [wc_cart_fragments_params] 129 */ 130jQuery(document).ready( function( $ ) { 131 132 // wc_cart_fragments_params is required to continue, ensure the object exists 133 if ( typeof woocommerce_params === 'undefined' ) { 134 return false; 135 } 136 137 /* Storage Handling */ 138 var $supports_html5_storage; 139 try { 140 $supports_html5_storage = ( 'sessionStorage' in window && window.sessionStorage !== null ); 141 142 window.sessionStorage.setItem( 'wc', 'test' ); 143 window.sessionStorage.removeItem( 'wc' ); 144 } catch( err ) { 145 $supports_html5_storage = false; 146 } 147 148 var $fragment_refresh = { 149 url: woocommerce_params.wc_ajax_url.toString().replace( '%%endpoint%%', 'get_refreshed_fragments_custom' ), 150 type: 'POST', 151 success: function( data ) { 152 if ( data ) { 153 154 if ( $supports_html5_storage ) { 155 sessionStorage.setItem( 'watatsumi', JSON.stringify( data.watatsumi ) ); 156 //hash 157 sessionStorage.setItem( 'wc_cart_hash', data.cart_hash ); 158 } 159 160 $( 'body' ).trigger( 'dds_update_mini_cart' ); 161 } 162 } 163 }; 164 165 /* Cart Handling */
166 if ( $supports_html5_storage ) { 167 168 $('body').on('added_to_cart', function (event, watatsumi, cart_hash) { 169 170 sessionStorage.setItem('watatsumi', JSON.stringify(watatsumi)); 171 //hash 172 sessionStorage.setItem('wc_cart_hash', cart_hash); 173 //обновлÑем мини коÑÐ·Ð¸Ð½Ñ 174 $('body').trigger('dds_update_mini_cart'); 175 }); 176 177 /** 178 * ÐбновлÑем мини коÑÐ·Ð¸Ð½Ñ Ð¸ Ñ.д. 179 */ 180 $( 'body' ).on( 'dds_update_mini_cart', function(){ 181 // var a = sessionStorage.getItem("watatsumi"); 182 // 183 // a = JSON.parse(a); 184 // t(".cart-dropdown").html(a.mini_cart); 185 186 // nonce_product = a.cart_nonce; 187 // count = a.cart_bubble.split(" ÑÑ. - "); 188 // 189 // if (count == 'ÐоÑзина') { 190 // t(".cart-button-total").html('ÐÐÐ ÐÐÐÐ - 0,00 гÑн'), t(".cart-icon .count").html(0); 191 // t(".cart-total").html('<strong>ÐоÑзина</strong> 0 ÑÑ. - <span class="amount">0,00 гÑн.</span>'); 192 // 193 // } else { 194 // t(".cart-button-total").html('ÐÐÐ ÐÐÐÐ - ' + count[1]); 195 // t(".cart-icon .count").html(count[0]); 196 // t(".cart-total").html('<strong>ÐоÑзина</strong> ' + count[0] + ' ÑÑ. - ' + count[1]) 197 // }; 198 199 var watatsumi = sessionStorage.getItem( 'watatsumi' ); 200 watatsumi = JSON.parse( watatsumi ); 201 202 $(".cart-dropdown").html(watatsumi.mini_cart); 203 204 nonce_product = watatsumi.cart_nonce; 205 count = watatsumi.cart_bubble.split(" ÑÑ. - "); 206 207 208 var $cart_lang_name = site_lang == 'uk' ? 'ÐоÑик' : 'ÐоÑзина'; 209 210 if (count == 'ÐоÑзина') { 211 $(".cart-button-total").html('<span>0 <span class="woocommerce-Price-currencySymbol">гÑн.</span></span>'); 212 $(".cart-icon .count").html(0); 213 $(".cart-total").html('0 ÑÑ. - <span class="amount">0,00 гÑн.</span>'); 214 $(".cart-button").addClass('empty'); 215 } else { 216 $(".cart-button-total").html(watatsumi.cart_total); // price 217 $(".cart-icon .count").html(count[0]); //count 218 $(".cart-total").html(count[0] + ' ÑÑ. - ' + count[1]); 219 $(".cart-button").removeClass('empty'); 220 }; 221 222 if (site_lang == "ru-RU") { 223 if (watatsumi.mini_cart.includes("ÐоÑик поÑожнÑй.")) { 224 jQuery('.lpd-shopping-cart .lpd-shopping-cart-list .empty').text('ÐоÑзина пÑÑÑаÑ.'); 225 } 226 } else if (site_lang == "uk") { 227 if (watatsumi.mini_cart.includes("ÐоÑзина пÑÑÑаÑ.")) { 228 jQuery('.lpd-shopping-cart .lpd-shopping-cart-list .empty').text('ÐоÑик поÑожнÑй.'); 229 } 230 } 231 // $('.cartTopDetails').html( watatsumi.mini_cart ); 232 // //nonce 233 // nonce_product = watatsumi.cart_nonce; 234 // //надпиÑÑ 235 // $('.cart-bubble').html( watatsumi.cart_bubble ); 236 }); 237 238 try { 239 var cart_hash = sessionStorage.getItem( 'wc_cart_hash' ), 240 cookie_hash = $.cookie( 'woocommerce_cart_hash' ), 241 watatsumi = sessionStorage.getItem( 'watatsumi' ); 242 243 if ( cart_hash === null || cart_hash === undefined || cart_hash === '' ) { 244 cart_hash = ''; 245 } 246 247 if ( cookie_hash === null || cookie_hash === undefined || cookie_hash === '' ) { 248 cookie_hash = ''; 249 } 250 251 if ( watatsumi && cart_hash === cookie_hash ) { 252 $( document.body ).trigger( 'dds_update_mini_cart' ); 253 } else { 254 throw 'No fragment'; 255 } 256 257 } catch( err ) { 258 $.ajax( $fragment_refresh ); 259 } 260 261 } else { 262 $.ajax( $fragment_refresh ); 263 } 264}); 265 266 267jQuery(document).ready(function($) { 268 269 /** 270 * AJAX Add to Cart 271 */ 272 $(document).on( 'click', '.single_add_to_cart_button, .add_to_cart_button', function() { 273 274 var $thisbutton = $(this); 275 276 if ( $thisbutton.hasClass( 'product_type_simple' ) ) { 277 if ( !$thisbutton.attr('data-product_id') ) { 278 return true; 279 } 280 //ÑбиÑаем галоÑÐºÑ 281 $thisbutton.addClass( 'loading' ); 282 283 //ÐапÑÐ¾Ñ 284 $.post( 285 woocommerce_params.wc_ajax_url.toString().replace( '%%endpoint%%', 'add_simple_custom' ), 286 { 287 product_id: $thisbutton.attr('data-product_id'), 288 quantity: $thisbutton.attr('data-quantity') 289 }, 290 function( response ) { 291 292 if ( ! response ) { 293 return; 294 } 295 296 if ( response.error && response.product_url ) { 297 window.location = response.product_url; 298 return; 299 } 300 301 // var price = $thisbutton 302 // .parents(".product-content") 303 // .find(".amount") 304 // .text(); 305 306 var price = $thisbutton.parents(".product-content").find('.new-price .amount').first().text().trim(); 307 308 if (!price) { 309 price = $thisbutton.parents(".product-content").find('.price > .amount').first().text().trim(); 310 } 311 312 var title = $thisbutton 313 .parents( '.product-content' ) 314 .find( '.product-title' ) 315 .text(); 316 317 if (!title) { 318 title = $thisbutton.parents(".product-content").find('.upsell-item-title').text(); 319 } 320 321 // //added to cart 322 dds_show_modal_success( price, 0, title ); 323 //галоÑка 324 $thisbutton.removeClass( 'loading' ).addClass( 'added' ); 325 //пиÑем новÑе даннÑе в sessionStorage 326 $( 'body' ).trigger( 'added_to_cart', [ response.watatsumi, response.cart_hash ] ); 327 } 328 ); 329 330 return false; 331 332 }else if ( $thisbutton.parents('form').hasClass( 'simple_cart' ) ) { 333 334 if ( !$thisbutton.parents('form').attr('data-product_id') ) { 335 return true; 336 } 337 338 //ÑбиÑаем галоÑÐºÑ 339 $thisbutton.removeClass( 'added' ).addClass( 'loading' ); 340 341 //ÐапÑÐ¾Ñ 342 $.post( 343 woocommerce_params.wc_ajax_url.toString().replace( '%%endpoint%%', 'add_simple_custom' ), 344 { 345 product_id: $thisbutton.parents('form').attr('data-product_id'), 346 quantity: $thisbutton.parents('form').find('[name="quantity"]').val(), 347 ingredients: $thisbutton.parents('form').find('[name="ingredients"]').val() 348 }, 349 function( response ) { 350 351 if ( ! response ) { 352 return; 353 } 354 355 if ( response.error && response.product_url ) { 356 window.location = response.product_url; 357 return; 358 } 359 360 var price = $thisbutton 361 .parents("form") 362 .find(".amount") 363 .text(); 364 365 var title = $thisbutton 366 .parents( '.summary' ) 367 .find( '.product_title' ) 368 .text(); 369 370 // //added to cart 371 dds_show_modal_success( price, 0, title ); 372 //галоÑка 373 $thisbutton.removeClass( 'loading' ).addClass( 'added' ); 374 //пиÑем новÑе даннÑе в sessionStorage 375 $( 'body' ).trigger( 'added_to_cart', [ response.watatsumi, response.cart_hash ] ); 376 } 377 ); 378 379 return false; 380 //ваÑиаÑивнÑй (пиÑÑа) 381 } else if ( $thisbutton.hasClass( 'product_type_variable' ) ) {
382 if ( ! $thisbutton.attr( 'data-product_id' ) ) { 383 return true; 384 } 385 386 // if ( ! $thisbutton.attr( 'data-product_variation' ) ) { 387 // return true; 388 // } 389 if ( ! $thisbutton.parents('.product-content').find('input:checked').attr( 'data-variation_id' ) ) { 390 return true; 391 } 392 393 //ÑбиÑаем галоÑÐºÑ 394 $thisbutton.removeClass( 'added' ).addClass( 'loading' ); 395 396 //даннÑе Ð´Ð»Ñ Ð¾ÑпÑавки 397 var json_data = { 398 product_id: $thisbutton.attr( 'data-product_id' ), 399 quantity: 1, 400 variation_id: $thisbutton.parents('.product-content').find('input:checked').attr( 'data-variation_id' ), 401 variation: $thisbutton.parents('.product-content').find('input:checked').attr('data-product_variation') 402 } 403 404 //ÐапÑÐ¾Ñ 405 $.post( 406 woocommerce_params.wc_ajax_url.toString().replace( '%%endpoint%%', 'add_variable_pizza' ), 407 { 408 pizza_to_cart: JSON.stringify( json_data ) 409 }, 410 function( response ) { 411 412 if ( ! response ) { 413 return; 414 } 415 416 if ( response.error && response.product_url ) { 417 window.location = response.product_url; 418 return; 419 } 420 421 var price = $thisbutton 422 .parents('.product-content').find('input:checked') 423 .attr('data-price'); 424 425 var title = $thisbutton 426 .parents( '.product-content' ) 427 .find( '.product-title' ) 428 .text(); 429 430 //added to cart 431 432 dds_show_modal_success( price, 0, title ); 433 //галоÑка 434 $thisbutton.removeClass( 'loading' ).addClass( 'added' ); 435 //пиÑем новÑе даннÑе в sessionStorage 436 $( 'body' ).trigger( 'added_to_cart', [ response.watatsumi, response.cart_hash ] ); 437 } 438 ); 439 return false; 440 } else if ( $thisbutton.parents('form').hasClass( 'variations_form' ) ) { 441 if ( ! $thisbutton.parents('form').attr( 'data-product_id' ) ) { 442 return true; 443 } 444 445 // if ( ! $thisbutton.attr( 'data-product_variation' ) ) { 446 // return true; 447 // } 448 if ( ! $thisbutton.parents('form').find('.variations input:checked').attr( 'data-variation_id' ) ) { 449 return true; 450 } 451 452 //ÑбиÑаем галоÑÐºÑ 453 $thisbutton.removeClass( 'added' ).addClass( 'loading' ); 454 455 //даннÑе Ð´Ð»Ñ Ð¾ÑпÑавки 456 var json_data = { 457 product_id: $thisbutton.parents('form').attr( 'data-product_id' ), 458 quantity: $thisbutton.parents('form').find('[name="quantity"]').val(), 459 variation_id: $thisbutton.parents('form').find('.variations input:checked').attr( 'data-variation_id' ), 460 variation: $thisbutton.parents('form').find('.variations input:checked').val(), 461 ingredients: $thisbutton.parents('form').find('[name="ingredients"]').val() 462 } 463 464 //ÐапÑÐ¾Ñ 465 $.post( 466 woocommerce_params.wc_ajax_url.toString().replace( '%%endpoint%%', 'add_variable_pizza' ), 467 { 468 pizza_to_cart: JSON.stringify( json_data ) 469 }, 470 function( response ) { 471 472 if ( ! response ) { 473 return; 474 } 475 476 if ( response.error && response.product_url ) { 477 window.location = response.product_url; 478 return; 479 } 480 481 var price = $thisbutton 482 .parents("form") 483 .find(".woocommerce-variation-price .amount") 484 .text(); 485 486 var title = $thisbutton 487 .parents( '.summary' ) 488 .find( '.product_title' ) 489 .text(); 490 491 //added to cart 492 493 dds_show_modal_success( price, 0, title ); 494 //галоÑка 495 $thisbutton.removeClass( 'loading' ).addClass( 'added' ); 496 //пиÑем новÑе даннÑе в sessionStorage 497 $( 'body' ).trigger( 'added_to_cart', [ response.watatsumi, response.cart_hash ] ); 498 } 499 ); 500 return false; 501 } else { 502 return true; 503 } 504 }); 505 506 507 /** 508 * УвелиÑиÑÑ ÐºÐ¾Ð»Ð¸ÑеÑÑво ÑоваÑа в мини коÑзине 509 */ 510 $(document).on( 'click', '.pl_product', function() { 511 dds_send_pm( 'plus', $(this) ); 512 }); 513 514 /** 515 * УменÑÑиÑÑ ÐºÐ¾Ð»Ð¸ÑеÑÑво ÑоваÑа в мини коÑзине 516 */ 517 $(document).on( 'click', '.min_product', function() { 518 dds_send_pm( 'minus', $(this) ); 519 }); 520 521 /**
522 * УбÑаÑÑ ÑÐ¾Ð²Ð°Ñ Ð¸Ð· коÑÐ·Ð¸Ð½Ñ 523 */ 524 $(document).on( 'click', '.item-remove', function() { 525 dds_remove_product( $(this) ); 526 return false; 527 }); 528 529 /** 530 * ÐенÑем кол-во в козине (на ÑÑÑанÑе оÑоÑÐ¼Ð»ÐµÐ½Ð¸Ñ Ð·Ð°ÐºÐ°Ð·Ð°) 531 */ 532 $(document).on( 'change', '.shop_table .qty', function() { 533 534 // jQuery('body').trigger('update_checkout'); 535 536 var $input = $(this); 537 // var $form = $('.shop_table'); 538 var $form = $('#cart-table'); 539 var name = $input.attr('name'); 540 var value = $input.attr('value'); 541 542 $form.block({ message: null, overlayCSS: { background: '#fff url(' + wc_checkout_params.ajax_loader_url + ') no-repeat center', backgroundSize: '16px 16px', opacity: 0.6 } }); 543 544 var data = {}; 545 data[name] = value; 546 data.update_cart = 'ÐбновиÑÑ ÐºÐ¾ÑзинÑ'; 547 data._wpnonce = nonce_product; 548 data._wp_http_referer = '/checkout/'; 549 550 551 552 // Ajax action 553 $.post( this_page, data, function( response ) { 554 555 $(document.body).trigger('update_checkout'); 556 /* 557 var reg = /^[\s\S]*<!-- start shop table -->([\s\S]*)<!-- end shop table -->[\s\S]*$/; 558 var myarray = reg.exec(response); 559 560 if ( myarray === null ) { 561 $form.unblock(); 562 return; 563 } 564 565 $('#cart-table').html(myarray[1]); 566 567 $("#order_review").load( this_page + " #order_review", function() { 568 $form.unblock(); 569 }); 570 */ 571 // addQtyPlusMinus(); 572 }); 573 }); 574}); 575 576 577/** 578 * ÐобавиÑÑ Ð¸Ð½Ð³ÑедиенÑÑ 579 */ 580jQuery(document).ready(function($) { 581 $('#add_ingredients_form').tabs(); 582 583 584 585 586 $('.cart .fa-plus').on('click', function(){ 587 $(this).parents('.cart').find('.qty').val(parseInt($(this).parents('.cart').find('.qty').val())+1); 588 $(this).parents('.cart').find('.qty').change(); 589 $(this).parents('.cart').find('.fa-minus').removeClass('hidden'); 590 }); 591 $('.cart .fa-minus').on('click', function(){ 592 if($(this).parents('.cart').find('.qty').val()>1){ 593 $(this).parents('.cart').find('.qty').val(parseInt($(this).parents('.cart').find('.qty').val())-1); 594 $(this).parents('.cart').find('.qty').change(); 595 } 596 if($(this).parents('.cart').find('.qty').val()==1) { 597 $(this).parents('.cart').find('.fa-minus').addClass('hidden'); 598 } 599 }); 600 601 $('#add_ingredients_form .fa-plus').on('click', function(){ 602 $(this).parents('.ingredient').find('.qty').val(parseInt($(this).parents('.ingredient').find('.qty').val())+1); 603 $(this).parents('.ingredient').find('.qty').change(); 604 $(this).parents('.ingredient').find('.fa-minus').removeClass('hidden'); 605 $(this).parents('.ingredient').find('.quantity').show(); 606 }); 607 $('#add_ingredients_form .fa-minus').on('click', function(){ 608 if($(this).parents('.ingredient').find('.qty').val()>0){ 609 $(this).parents('.ingredient').find('.qty').val(parseInt($(this).parents('.ingredient').find('.qty').val())-1); 610 $(this).parents('.ingredient').find('.qty').change(); 611 } 612 if($(this).parents('.ingredient').find('.qty').val()==0) { 613 $(this).parents('.ingredient').find('.fa-minus').addClass('hidden'); 614 $(this).parents('.ingredient').find('.quantity').hide(); 615 } 616 }); 617 $('#add_ingredients .ingredient .quantity').each(function(){ 618 if($(this).val()==0) $(this).hide(); 619 }) 620 621 $('.add-ingredients__btn').on('click',function(){ 622 $(this).toggleClass('active'); 623 $('.add-ingredients').slideToggle().toggleClass('show'); 624 }) 625}); 626 627/** 628 * ÐобавлÑем ваÑиаÑивнÑй ÑÐ¾Ð²Ð°Ñ Ð² коÑÐ·Ð¸Ð½Ñ Ñ ÐºÐ°ÑÑоÑки ÑоваÑа 629 */ 630jQuery(document).ready(function($) { 631 632 // var $form = $('.rightContentSP > .variations_form'), 633 var $form = $('.summary .cart'),
634 $hidden_var_id = $form.find( 'input:hidden[name="variation_id"]' ); 635 636 $(document).on( 'change', '.summary .variations_form input:radio[name="attribute_pa_diam"], .summary .variations_form input:radio[name="attribute_pa_variacii-burgera"]', function(){ 637 $hidden_var_id.val( $(this).attr('data-variation_id') ); 638 }); 639 640 $(document).on( 'change kayup keydown', '#add_ingredients_form input[type="number"]', function(e){ 641 642 if ( $hidden_var_id.val() == '' ) { 643 var $radio = $('.summary .variations_form input:radio[name="attribute_pa_diam"], .summary .variations_form input:radio[name="attribute_pa_variacii-burgera"]').eq(0); 644 $radio.prop('checked', true); 645 $hidden_var_id.val( $('.summary .variations_form input:radio[name="attribute_pa_diam"], .summary .variations_form input:radio[name="attribute_pa_variacii-burgera"]').attr('data-variation_id') ); 646 } 647 648 var ingredients = {}; 649 650 $('#add_ingredients_form input[type="number"]').each(function(){ 651 ingredients[$(this).attr('name')] = $(this).attr('value'); 652 //sleep(5000); 653 }); 654
655 $form.find( 'input:hidden[name="ingredients"]' ).val( JSON.stringify( ingredients ) ); 656 }); 657}); 658 659/** 660 * ÐÑобÑажаем ÑÐµÐ½Ñ Ð´Ð»Ñ Ð¿Ð¸ÑÑÑ 661 */ 662jQuery(document).ready(function($) { 663 664 // if ( $('.product-type-variable').index() === -1 && $('#add_ingredients_form').index() === -1 ) { 665 // if ( $('#add_ingredients_form').index() === -1 ) { 666 // return false; 667 // } 668 669 //пеÑеÑÑиÑÑваем ÑÐµÐ½Ñ Ð½Ð° пиÑÑÑ 670 recount_pizza_price($); 671 672 //диамеÑÑ 673 $(document).on( 'change', 'input:radio[name="attribute_pa_diam"], input:radio[name="attribute_pa_variacii-burgera"]', function(){ 674 recount_pizza_price($); 675 }); 676 677 //колиÑеÑÑво 678 $(document).on( 'change', 'input[name="quantity"]', function(){ 679 recount_pizza_price($); 680 }); 681 682 //ингÑедиенÑÑ 683 $(document).on( 'change', '#add_ingredients_form input[type="number"]', function(){ 684 recount_pizza_price($); 685 }); 686}); 687 688/** 689 * ÐеÑеÑÑиÑÑваем ÑÐµÐ½Ñ Ð½Ð° пиÑÑÑ 690 */ 691function recount_pizza_price($) { 692 693 var $price_container = $( 'div.offers .price .amount' ); 694 var $form = $('.variations_form'); 695 var $ingr_form = $('#add_ingredients_form'); 696
697 var $checked_option = $form.find( 'input:radio[name="attribute_pa_diam"]:checked, input:radio[name="attribute_pa_variacii-burgera"]:checked'); 698 var checked_price = $checked_option.attr('data-price'); 699 var currency_symbol = $form.attr('data-currency'); 700 var quantity = $form.find( 'input[name="quantity"]').val(); 701 var $ingredients = $ingr_form.find('.ingredient'); 702 703 if(!$form.length){ 704 $form = $('.cart'); 705 checked_price=$form.attr('data-price'); 706 currency_symbol = $form.attr('data-currency'); 707 quantity = $form.find( 'input[name="quantity"]').val(); 708 $price_container = $( '.priceSP .amount' ); 709 }else{ 710 if ( $checked_option.index() === -1 ) { 711 return false; 712 } 713 } 714 715 if ( checked_price == 0 || quantity == 0 || typeof checked_price === 'undefined' || typeof quantity === 'undefined' ) { 716 return false; 717 } 718 719 //Ð½Ð¾Ð²Ð°Ñ Ñена 720 var new_price = checked_price * quantity; 721 722 //пеÑеÑÑиÑÑваем ингÑедиенÑÑ 723 $.each( $ingredients, function( k,v ){ 724 725 var price = $(this).attr('data-price'), 726 ingr_quantity = $(this).find( 'input[type="number"]').val(); 727 728 // alert(price); 729 // alert(ingr_quantity); 730 if ( price == 0 || ingr_quantity == 0 || typeof price === 'undefined' || typeof ingr_quantity === 'undefined' ) { 731 return; //continue; 732 } 733 //ÑвелиÑиваем ÑÐµÐ½Ñ 734 new_price += price * ingr_quantity * quantity; 735 }); 736 737 //пиÑем новÑÑ ÑÐµÐ½Ñ 738 $price_container.html( new_price + ' <span class="woocommerce-Price-currencySymbol">' + currency_symbol + '</span>' ); 739}
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.