'Change Shipping Postcode field to dropdown list in BOTH Woocommerce Checkout page AND Shipping Calculator

I want to make it easier for customers to choose a correct WooCommerce Shipping Address postcode, by replacing the default Postcode "text box" field in (a) the Shipping Address section (but NOT the Billing Address also, that still needs the full list of postcodes) of the WooCommerce Checkout page, and also in (b) the Shipping Calculator on the WooCommerce Cart page ... with a dropdown list of only 3 available postcodes.

I have tried the code provided in the "1) For shipping postcode field only, you will use the following:" section of the thread called "Change postcode shipping field to a dropdown in Woocommerce" and that seemed to work on my Checkout page ... BUT it did not seem to do anything to the Shipping Postcode field in the Shipping Calculator on my WooCommerce Cart page ...

add_filter( 'woocommerce_shipping_fields' , 'customize_shipping_postcode_field' );
function customize_shipping_postcode_field( $shipping_fields ) {

    $shipping_fields['shipping_postcode']['type'] = 'select';
    $shipping_fields['shipping_postcode']['options'] = array(
        ''         => __('Select your postcode', 'woocommerce'),
        'option_1' => 'Choice 1',
        'option_2' => 'Choice 2',
        'option_3' => 'Choice 3'
    );

    return $shipping_fields;
}

Please can anyone provide a version of the above code that will customize both (a) and also (b)?

Or else provide separate code to do the Shipping Calculator? (perhaps code similar to the example in the latest answer (the answer starting with ... "Put the code in your "function.php" file or plugin. No need to manipulate the woocommerce file") in this thread "Edit woocommerce shipping calculator", that I could add to the functions.php file?

The other thing is, of course, I need the postcode that is chosen from the dropdown list to be recognised by WooCommerce Shipping options and matched to my Shipping Zone (and hence trigger/display my configured list of available shipping methods)



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source