mirror of
https://gh.wpcy.net/https://github.com/mainwp/Code-Snippets-Functions.git
synced 2026-04-29 11:32:21 +08:00
https://stackoverflow.com/questions/64405796/refresh-mini-cart-on-shipping-or-payment-method-change-in-woocommerce-checkout/64406077
14 lines
486 B
Text
14 lines
486 B
Text
add_action('wp_footer', 'minicart_checkout_refresh_script');
|
|
function minicart_checkout_refresh_script(){
|
|
if ( is_checkout() && ! is_wc_endpoint_url() ) :
|
|
?>
|
|
<script type="text/javascript">
|
|
(function($){
|
|
$(document.body).on('change', 'input[name="payment_method"],input[name^="shipping_method"]', function(){
|
|
$(document.body).trigger('update_checkout').trigger('wc_fragment_refresh');
|
|
});
|
|
})(jQuery);
|
|
</script>
|
|
<?php
|
|
endif;
|
|
}
|