#StackBounty: #plugin-development #woocommerce #ajax Show special field when correct shipping is chosen

Bounty: 50

I tried this approach:

add_action( 'woocommerce_review_order_before_payment', array( $this, 'my_custom_checkout_field') );
add_action('updated_checkout',array( $this, 'my_custom_checkout_field'));

public function my_custom_checkout_field(){

    $chosen_methods = WC()->session->get( 'chosen_shipping_methods' );
    $chosen_shipping = $chosen_methods[0];
    if($chosen_shipping == 'zasilkovna'){
        include_once('special-field.php');
    }
}

However, the special field does not appear when user clicks the shipping method. User needs to manually refresh the page, which is not good.

I need to hook myself on the ajax and show the field when correct shipping is clicked.

I know the jqery is firing the action, but am not quite sure how to hook on it…


Get this bounty!!!

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.