Merge pull request #4289 from jaredcobb/master
Make frontend scripts safe to run on non WC pages (check for objects)
This commit is contained in:
commit
bba10ae005
|
@ -1,5 +1,9 @@
|
|||
jQuery(document).ready(function($){
|
||||
|
||||
// woocommerce_params is required to continue, ensure the object exists
|
||||
if (typeof woocommerce_params === "undefined")
|
||||
return false;
|
||||
|
||||
$('#add_payment_method')
|
||||
|
||||
/* Payment option selection */
|
||||
|
@ -24,4 +28,4 @@ jQuery(document).ready(function($){
|
|||
|
||||
$('body').trigger('init_add_payment_method');
|
||||
|
||||
});
|
||||
});
|
||||
|
|
|
@ -415,8 +415,13 @@
|
|||
};
|
||||
|
||||
$(function() {
|
||||
|
||||
// wc_add_to_cart_variation_params is required to continue, ensure the object exists
|
||||
if (typeof wc_add_to_cart_variation_params === "undefined")
|
||||
return false;
|
||||
|
||||
$('.variations_form').wc_variation_form();
|
||||
$('.variations_form .variations select').change();
|
||||
});
|
||||
|
||||
})( jQuery, window, document );
|
||||
})( jQuery, window, document );
|
||||
|
|
|
@ -1,5 +1,9 @@
|
|||
jQuery(document).ready(function($) {
|
||||
|
||||
// wc_add_to_cart_params is required to continue, ensure the object exists
|
||||
if (typeof wc_add_to_cart_params === "undefined")
|
||||
return false;
|
||||
|
||||
// Ajax add to cart
|
||||
$(document).on( 'click', '.add_to_cart_button', function() {
|
||||
|
||||
|
@ -104,4 +108,4 @@ jQuery(document).ready(function($) {
|
|||
return true;
|
||||
});
|
||||
|
||||
});
|
||||
});
|
||||
|
|
|
@ -1,5 +1,9 @@
|
|||
jQuery(document).ready(function($) {
|
||||
|
||||
// wc_cart_fragments_params is required to continue, ensure the object exists
|
||||
if (typeof wc_cart_fragments_params === "undefined")
|
||||
return false;
|
||||
|
||||
/** Cart Handling */
|
||||
$supports_html5_storage = ( 'sessionStorage' in window && window['sessionStorage'] !== null );
|
||||
|
||||
|
@ -72,4 +76,4 @@ jQuery(document).ready(function($) {
|
|||
$('.hide_cart_widget_if_empty').closest('.widget_shopping_cart').show();
|
||||
} );
|
||||
|
||||
});
|
||||
});
|
||||
|
|
|
@ -1,5 +1,9 @@
|
|||
jQuery(document).ready(function($) {
|
||||
|
||||
// wc_cart_params is required to continue, ensure the object exists
|
||||
if (typeof wc_cart_params === "undefined")
|
||||
return false;
|
||||
|
||||
// Shipping calculator
|
||||
$(document).on( 'click', '.shipping-calculator-button', function() {
|
||||
$('.shipping-calculator-form').slideToggle('slow');
|
||||
|
@ -30,4 +34,4 @@ jQuery(document).ready(function($) {
|
|||
|
||||
$('.shipping-calculator-form').hide();
|
||||
|
||||
});
|
||||
});
|
||||
|
|
|
@ -1,5 +1,9 @@
|
|||
jQuery(document).ready(function($) {
|
||||
|
||||
// wc_checkout_params is required to continue, ensure the object exists
|
||||
if (typeof wc_checkout_params === "undefined")
|
||||
return false;
|
||||
|
||||
var updateTimer;
|
||||
var dirtyInput = false;
|
||||
var xhr;
|
||||
|
|
|
@ -1,5 +1,9 @@
|
|||
jQuery(document).ready(function($) {
|
||||
|
||||
// wc_country_select_params is required to continue, ensure the object exists
|
||||
if (typeof wc_country_select_params === "undefined")
|
||||
return false;
|
||||
|
||||
/* State/Country select boxes */
|
||||
var states_json = wc_country_select_params.countries.replace(/"/g, '"');
|
||||
var states = $.parseJSON( states_json );
|
||||
|
@ -66,4 +70,4 @@ jQuery(document).ready(function($) {
|
|||
|
||||
});
|
||||
|
||||
});
|
||||
});
|
||||
|
|
|
@ -1,5 +1,9 @@
|
|||
jQuery(document).ready(function($) {
|
||||
|
||||
// woocommerce_price_slider_params is required to continue, ensure the object exists
|
||||
if (typeof woocommerce_price_slider_params === "undefined")
|
||||
return false;
|
||||
|
||||
// Get markup ready for slider
|
||||
$('input#min_price, input#max_price').hide();
|
||||
$('.price_slider, .price_label').show();
|
||||
|
@ -67,4 +71,4 @@ jQuery(document).ready(function($) {
|
|||
},
|
||||
});
|
||||
|
||||
});
|
||||
});
|
||||
|
|
|
@ -1,5 +1,9 @@
|
|||
jQuery(document).ready(function($) {
|
||||
|
||||
// wc_single_product_params is required to continue, ensure the object exists
|
||||
if (typeof wc_single_product_params === "undefined")
|
||||
return false;
|
||||
|
||||
// Tabs
|
||||
$('.woocommerce-tabs .panel').hide();
|
||||
|
||||
|
|
Loading…
Reference in New Issue