• Resolved Niresh

    (@niresh12495)


    I’m using the following snippet to change cities into drop down list.

    add_filter( 'woocommerce_checkout_fields' , 'override_checkout_city_fields' );
    function override_checkout_city_fields( $fields ) {
    
        // Define here in the array your desired cities (Here an example of cities)
        $option_cities = array(
             '' => __( 'Select your city' ),
            'Karachi' => 'Karachi',
            'Lahore' => 'Lahore',
            'Faisalabad' => 'Faisalabad',
            'Rawalpindi' => 'Rawalpindi',
            'Gujranwala' => 'Gujranwala',
            'Peshawar' => 'Peshawar',
            'Multan' => 'Multan',
            'Hyderabad' => 'Hyderabad',
            'Islamabad' => 'Islamabad'
        );
    
        $fields['billing']['billing_city']['type'] = 'select';
        $fields['billing']['billing_city']['options'] = $option_cities;
        $fields['shipping']['shipping_city']['type'] = 'select';
        $fields['shipping']['shipping_city']['options'] = $option_cities;
    
        return $fields;
    }

    I need to make some cities unselectable by adding
    disabled=”true” attribute how can i make this happen?

    • This topic was modified 4 years, 11 months ago by Niresh.
    • This topic was modified 4 years, 11 months ago by Niresh.
    • This topic was modified 4 years, 11 months ago by Niresh. Reason: Autocorrect bullshit
Viewing 2 replies - 1 through 2 (of 2 total)
  • Nico

    (@nicolamustone)

    Automattic Happiness Engineer

    Hello there,
    You cannot make them unselectable, but you can remove them from the dropdown entirely using the unset() function.

    Nico

    (@nicolamustone)

    Automattic Happiness Engineer

    We haven’t heard back from you in a while, so I’m going to mark this as resolved – if you have any further questions, you can start a new thread.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Making Some Options Un-Selectable’ is closed to new replies.