2012-07-17 14:09:18 +00:00
|
|
|
jQuery(document).ready(function($) {
|
|
|
|
|
|
|
|
// Shipping calculator
|
2012-12-28 17:33:05 +00:00
|
|
|
$(document).on( 'click', '.shipping-calculator-button', function() {
|
2012-07-17 14:09:18 +00:00
|
|
|
$('.shipping-calculator-form').slideToggle('slow');
|
|
|
|
return false;
|
2012-12-28 17:33:05 +00:00
|
|
|
}).on( 'change', 'select#shipping_method, input[name=shipping_method]', function() {
|
2012-07-17 14:09:18 +00:00
|
|
|
var method = $(this).val();
|
2012-12-28 13:02:12 +00:00
|
|
|
|
2012-12-13 15:53:36 +00:00
|
|
|
$('div.cart_totals').block({message: null, overlayCSS: {background: '#fff url(' + woocommerce_params.ajax_loader_url + ') no-repeat center', backgroundSize: '16px 16px', opacity: 0.6}});
|
2012-12-28 13:02:12 +00:00
|
|
|
|
2012-07-17 14:09:18 +00:00
|
|
|
var data = {
|
|
|
|
action: 'woocommerce_update_shipping_method',
|
|
|
|
security: woocommerce_params.update_shipping_method_nonce,
|
|
|
|
shipping_method: method
|
|
|
|
};
|
2012-12-28 13:02:12 +00:00
|
|
|
|
2012-07-17 14:09:18 +00:00
|
|
|
$.post( woocommerce_params.ajax_url, data, function(response) {
|
2012-12-28 13:02:12 +00:00
|
|
|
|
2012-07-17 14:09:18 +00:00
|
|
|
$('div.cart_totals').replaceWith( response );
|
|
|
|
$('body').trigger('updated_shipping_method');
|
2012-12-28 13:02:12 +00:00
|
|
|
|
2012-07-17 14:09:18 +00:00
|
|
|
});
|
2012-12-28 13:02:12 +00:00
|
|
|
})
|
|
|
|
|
2012-12-28 17:33:05 +00:00
|
|
|
$('.shipping-calculator-form').hide();
|
2012-12-28 13:02:12 +00:00
|
|
|
|
2012-07-17 14:09:18 +00:00
|
|
|
});
|