1/** 2 * RightPress Product Price Live Update Scripts 3 */ 4 5jQuery(document).ready(function() { 6 7 'use strict'; 8 9 /** 10 * Maybe modify default WooCommerce price element 11 */ 12 if (rightpress_product_price_live_update_vars.replace_wc_price) { 13 jQuery('.product .price').first().addClass('rightpress_product_price_live_update_price'); 14 } 15 16 /** 17 * Initialize live product update 18 */ 19 jQuery('.rightpress_product_price_live_update_price').rightpress_live_product_update({ 20 21 // Params 22 ajax_url: rightpress_product_price_live_update_vars.ajaxurl, 23 action: 'rightpress_product_price_live_update', 24 25 // Before send 26 before_send: function() { 27 28 // Change opacity of the element 29 jQuery(this).closest('.rightpress_product_price_live_update').css('opacity', '0.25'); 30 }, 31 32 // Callback 33 response_handler: function(response) { 34 35 var container = jQuery(this).closest('.rightpress_product_price_live_update'); 36 37 // Check if valid response was received 38 var is_valid_response = (typeof response === 'object' && typeof response.result !== 'undefined' && response.result === 'success'); 39 40 // Maybe hide live price element 41 if (!rightpress_product_price_live_update_vars.replace_wc_price && (!is_valid_response || !response.display)) { 42 43 // Hide our price 44 container.slideUp(); 45 container.find('.rightpress_product_price_live_update_label').html(''); 46 container.find('.price').html(''); 47 48 // Allow default variation price to be displayed 49 jQuery('#rightpress_product_price_live_update_hide_default').remove(); 50 } 51 // Element does not need to be hidden and response is valid 52 else if (is_valid_response) { 53 54 // Update price 55 var price_html = response.price_html; 56 jQuery(this).html(price_html); 57 58 // Separate element is displayed 59 if (!rightpress_product_price_live_update_vars.replace_wc_price) { 60 61 // Update label 62 container.find('span.rightpress_product_price_live_update_label').html(response.label_html); 63 64 // Hide default WooCommerce variation price 65 jQuery('body').append('<div id="rightpress_product_price_live_update_hide_default" style="display: none;"><style>div.single_variation_wrap div.single_variation span.price, .single-product div.product .single_variation .price { display: none; }</style></div>'); 66 67 // Show 68 container.slideDown(); 69 } 70 71 // Trigger event 72 jQuery('body').trigger('rightpress_product_price_live_update_updated', response); 73 jQuery('body').trigger('rightpress_live_product_price_update_updated', response); // Legacy 74 } 75 76 // Change opacity of the element 77 container.css('opacity', '1.0'); 78 } 79 }); 80 81 82 83 84 85});
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.