(function( $ ) {
|
|
'use strict';
|
|
|
|
$(function() {
|
|
$('#shipping_estimate_form input[name="postcode"]').mask('#####-###');
|
|
|
|
$( document.body ).on( 'submit', '#shipping_estimate_form', function(event) {
|
|
event.preventDefault();
|
|
|
|
var submit_button = $(this).find('button[type="submit"]');
|
|
$(submit_button).addClass('loading')
|
|
|
|
var product_id = $(this).find('input[name="product_id"]').val();
|
|
var quantity = $(this).find('input[name="quantity"]').val();
|
|
var postcode = $(this).find('input[name="postcode"]').val();
|
|
|
|
$.ajax({
|
|
type: 'GET',
|
|
url: wc_ajax_url, // eslint-disable-line
|
|
data: {
|
|
'wc-ajax': 'shipping_estimate_postcode',
|
|
'postcode': postcode,
|
|
'product_id': product_id,
|
|
'quantity': quantity,
|
|
},
|
|
success: function( response ) {
|
|
$('#shipping_estimate_response').replaceWith(response);
|
|
$(submit_button).removeClass('loading');
|
|
},
|
|
error: function() {
|
|
$(submit_button).removeClass('loading');
|
|
},
|
|
});
|
|
});
|
|
});
|
|
|
|
})( jQuery );
|