In my WooCommerce plugin, I’m using devbridge autocomplete plugin for shipping city field. And after the city is selected, I want to refresh order review via ajax.
Here’s the JS:
jQuery('input.city-search').autocomplete({
serviceUrl: ajax.url,
paramName: 's',
params: {
action: 'wp_ajax_city_search'
},
transformResult: function(response) {
response = jQuery.parseJSON(response);
return {
suggestions: jQuery.map(response, function(item) {
return {
value: decode_html(item.text),
data: item.data
};
})
};
},
onSelect: function (suggestion) {
jQuery( 'body' ).trigger( 'update_checkout' );
}
});
The problem is that jQuery( 'body' ).trigger( 'update_checkout' )
just does nothing.
I tried $( document.body ).trigger( 'update_checkout' )
as well, but result is the same – nothing. I tried to check if there are any events bound to body – jQuery('body').data('events')
and it has shown that there are none.