How to run script after shipping method is selected
-
I’ve installed one shipping plugin for Woocommerce. When I click the shipping method “綠界科技超商取貨” , a ajax “update_order_review” is called and a div id=”order_review” is refreshed. After the refresh is done, a new content is appended into the div id=”order_review”.
I have tried hook “woocommerce_after_checkout_form” and using javascript to append content but the content is removed just right after the div id=”order_review” is refreshed when I change of shipping method.
I’m wondering how I can do javascript after the ajax action of “update_order_review” is called?
add_action( ‘woocommerce_after_checkout_form’, ‘action_woocommerce_checkout_update_order_review’, 10, 2 );
function action_woocommerce_checkout_update_order_review( $array, $int ) {
?>
<script type=”text/javascript”>
jQuery(‘form.checkout’).on(‘change’,’input[name^=”shipping_method”]’,function() {
var val = jQuery( this ).val();
if (val.match(“tyche_method4”)) {
jQuery(“.woocommerce-shipping-totals”).after( “<tr><th>Goshop101超商取貨</th></tr>” );
}
});
</script>
<?php
};
The topic ‘How to run script after shipping method is selected’ is closed to new replies.