+
1 2 2
  1. #1
    Status
    Offline
      Rise Company
    Engineering and Technology
    Apr 2014
    Egypt
    4,077
    10

    WordPress WooCommerce Cities drop down


    WordPress WooCommerce Cities drop down
    3 Level WooCommerce States & Cities drop down - Plugin Development in WordPress
    How to add custom country in WooCommerce - How to add city and districts in WooCommerce
    Replace the city text field by a dropdown of cities for a specific country in Woocommerce
    Add dropdown list of cities in Woocommerce checkout page
    Aramex: ERR52 - Destination Address - City name is invalid (s)




    https://github.com/YTTechiePress/sta...ocoommerce.php
    https://github.com/woocommerce/wooco.../countries.php
    https://github.com/woocommerce/wooco...18n/states.php

    In some specific cases, you might need to change the WooCommerce default country, state or region to better suit your needs. For example, if you are creating a city-specific service that delivers the orders only inside the city boundaries.
    Woocommerce comes with the predefined country list as well as the states and regions. However, this list is not so accurate as you might need to limit the shipping zone to the city districts or municipalities.

    The code need to be added in your theme's function.php file. There is no problems with this answer code as it's fully tested and works. You can also use the Code Snippets plugin that woocommerce recommend. Using the theme editor is not recommended. You should use an external editor linked to your FTP software.


    :
    // Copy from here
    
    /**
     * Change the checkout city field to a dropdown field.
     */
    function jeroen_sormani_change_city_to_dropdown( $fields ) {
    
        $city_args = wp_parse_args( array(
            'type' => 'select',
            'options' => array(
                'alexandria' => 'Alexandria',
                'Awaied-Ras Souda' => 'Awaied-Ras Souda',
                'Borg Al Arab City'   => 'Borg Al Arab City',
                'Sedi Kreir' => 'Sedi Kreir',
                'Atfeah'    => 'Atfeah',
                'Badrashin'  => 'Badrashin',
            ),
            'input_class' => array(
                'wc-enhanced-select',
            )
        ), $fields['shipping']['shipping_city'] );
    
        $fields['shipping']['shipping_city'] = $city_args;
        $fields['billing']['billing_city'] = $city_args; // Also change for billing field
    
        wc_enqueue_js( "
        jQuery( ':input.wc-enhanced-select' ).filter( ':not(.enhanced)' ).each( function() {
            var select2_args = { minimumResultsForSearch: 5 };
            jQuery( this ).select2( select2_args ).addClass( 'enhanced' );
        });" );
    
        return $fields;
    
    }
    add_filter( 'woocommerce_checkout_fields', 'jeroen_sormani_change_city_to_dropdown' );
    functions.php theme child Code Snippets plugin
    city


    :
    shipping
    cities select
    text city aramex
    rate calculate
    Aramex: ERR52 - Destination Address - City name is invalid (s)



    :
    https://silvawebdesigns.com/how-to-c...n-woocommerce/
    https://stackoverflow.com/questions/...-checkout-page
    https://stackoverflow.com/questions/...-country-in-wo
    https://stackoverflow.com/questions/...-plugin-errors
    https://wordathemes.com/add-city-and...n-woocommerce/
    https://aceplugins.com/how-to-make-t...ld-a-dropdown/
    https://xtemos.com/forums/topic/drop...erce-checkout/


    ------------------------------------------------------------------------
    Rise Company for Engineering & Technology
    ------------------------------------------------------------------------
    Web Hosting | Web Designing | E-Marketing

    # 1 Business Services

    Web Hosting - Business Emails

    Web Design - Google Adwords

    www.rise.company | www.rise.company/emails

    :
    ! .



  2. #2
    Status
    Offline
      Rise Company
    Engineering and Technology
    Apr 2014
    Egypt
    4,077
    10

    : WordPress WooCommerce Cities drop down

    :
    /**
     * Change the checkout city field to a dropdown field.
     */
    function jeroen_sormani_change_city_to_dropdown( $fields ) {
    
        $city_args = wp_parse_args( array(
            'type' => 'select',
            'options' => array(
    /*alex*/            
                'Alexandria' => ' Alexandria',
                'Awaied-Ras Souda' => '   Awaied-Ras Souda',
                'Borg Al Arab City'   => '  Borg Al Arab City',
                'Sedi Kreir' => '  Sedi Kreir',
    /*giza*/
                'Giza'  => ' Giza',
                'Abo Rawash'  => '  Abo Rawash',
                'Agouza'  => ' Agouza',
                'Al Haram'  => ' Al Haram',
                'Al Monib'  => ' Al Monib',
                'Wahat'  => ' Wahat',
                'Al Waraq'  => ' Al Waraq',
                'Alex Desert Rd.'  => '   Alex Desert Rd.',
                'Atfeah'    => ' Atfeah',
                'Badrashin'  => ' Badrashin',
                'Bahtem'  => ' Bahtem',
                'Bargiel'  => ' Bargiel',
                'Bolak El Dakrour'  => '  Bolak El Dakrour',
                'Dahshour'  => ' Dahshour',
                'Dokki'  => ' Dokki',
                'El Ayat'  => ' El Ayat',
                'El Hawamdiah'  => ' El Hawamdiah',
                'EL Korimat'  => ' EL Korimat',
                'El Saf'  => ' El Saf',
                'Imbaba'  => ' Imbaba',
                'Manial El Rodah'  => '  Manial El Rodah',
                'Mohandiseen'  => ' Mohandiseen',
                'October City'  => '  October City',
                'Omranya'  => ' Omranya',
                'Saqara'  => ' Saqara',
                'Zamalek'  => ' Zamalek',
    /*cairo*/
                '15 Of May City'  => ' 15  15 Of May City',
                'Abasya'  => ' Abasya',
                'Ain Shams'  => '  Ain Shams',
                'Al Marg'  => ' Al Marg',
                'Al Matarya'  => ' Al Matarya',
                'Al Shorouk'  => ' Al Shorouk',
                'Attaba'  => ' Attaba',
                'Badr City'  => '  Badr City',
                'Cornish El Nile'  => '  Cornish El Nile',
                'Dar El Salam'  => '  Dar El Salam',
                'Down Town'  => '  Down Town',
                'El Maadi'  => ' El Maadi',
                'El Marg'  => ' El Marg',
                'EL rehab'  => ' EL rehab',
                'El Salam City'  => '  El Salam City',
                'EL SAWAH'  => ' EL SAWAH',
                'El Zeitoun'  => ' El Zeitoun',
                'Garden City'  => '  Garden City',
                'Ghamrah'  => ' Ghamrah',
                'Hadayek El Qobah'  => '  Hadayek El Qobah',
                'Heliopolis'  => '  Heliopolis',
                'Helwan'  => ' Helwan',
                'Kasr El Einy'  => '  Kasr El Einy',
                'Katamiah'  => ' Katamiah',
                'Maadi'  => ' Maadi',
                'Madinaty'  => ' Madinaty',
                'Mansheyt Naser'  => '  Mansheyt Naser',
                'Mokattam'  => ' Mokattam',
                'Nasr City'  => '  Nasr City',
                'New Cairo'  => '  New Cairo',
                'New Capital City'  => '   New Capital City',
                'Ramsis'  => ' Ramsis',
                'Shubra'  => ' Shubra',
                'Tebin'  => ' Tebin',
                'Torah'  => ' Torah',
    /*Beheira*/
                'Al Nobariah'  => ' Al Nobariah',
                'Damanhour'  => ' Damanhour',
                'Wadi El Natroun'  => '  Wadi El Natroun',
    /*Sharqia*/
                '10Th Of Ramadan City'  => '   10Th Of Ramadan City',
    /*Aswan*/    
                'ABOU SOMBO'  => '  ABOU SOMBO',
                'Aswan'  => ' Aswan',
                'High Dam'  => '  High Dam',
    /*Qaliubia*/    
                'Abu Zaabal'  => '  Abu Zaabal',
                'Al Obour City'  => '  Al Obour City',
                'AL Qanater'  => ' AL Qanater',
                'Beigam'  => ' Beigam',
                'Benha'  => '',
    /*Red Sea*/
                'Al Arish'  => ' Al Arish',
                'EL GOUNA'  => ' EL GOUNA',
                'Hurghada'  => ' Hurghada',
                'Marsa Alam'  => '  Marsa Alam',
                'RAS GHAREB'  => '  RAS GHAREB',
                'Ras Shoqeir'  => '  Ras Shoqeir',
                'Safaga'  => ' Safaga',
    /*Gharbia*/
                'Al Mahala'  => ' Al Mahala',
                'Tanta'  => ' Tanta',
    /*Al Menofiah*/
                'Al Menofiah'  => ' Al Menofiah',
                'Berkeit Sabb'  => '  Berkeit Sabb',
                'Quesna'  => ' Quesna',
                'Sadat City'  => '  Sadat City',
                'Shebin El Koum'  => '  Shebin El Koum',
    /*Bani Swif*/    
                'Bani Swif'  => '  Bani Swif',
    /*Daqahlia*/                
                'Belqas'  => ' Belqas',
                'Mansoura'  => ' Mansoura',
                'Meet Ghamr'  => '  Meet Ghamr',
    /*Kafr Al Sheikh*/
                'Kafr Al Sheikh'  => '  Kafr Al Sheikh',
                'Desouk'  => ' Desouk',
    /*Dumiatta*/            
                'Dumiatta'  => ' Dumiatta',
    /*Suez*/
                'Suez'  => ' Suez',
                'Ein Al Sukhna'  => '  Ein Al Sukhna',
                'El Qantara Sharq'  => '  El Qantara Sharq',
    /*New Valley*/
                'El Wadi El Gadid'  => '  El Wadi El Gadid',
                'Toshka'  => ' Toshka',
    /*Ismailia*/
                'Fayid'  => ' Fayid',
                'Ismailia'  => ' Ismailia',
    /*Fayoum*/
                'Fayoum'  => '',
    /*Luxour*/            
                'Luxour'  => ' Luxour',
    /*Marsa Matrouh*/    
                'Marabella'  => ' Marabella',
                'Maraqia'  => ' Maraqia',
                'Marinah'  => ' Marinah',
                'Marsa Matrouh'  => '  Marsa Matrouh',
                'Siwa'  => ' Siwa',
    /*Menia*/    
                'Menia City'  => '  Menia City',
    /*Qena*/
                'Qena'  => ' Qena',
                'Nag Hamadi'  => '  Nag Hamadi',
    /*Port Said*/
                'Port Said'  => ' Port Said',
    /*South Sinai*/
                'Al Tour City'  => '  Al Tour City',
                'Dahab City'  => '  Dahab City',
                'Nuwibaa'  => ' Nuwibaa',
                'Ras Seidr'  => '  Ras Seidr',
                'Sharm El Sheikh'  => '  Sharm El Sheikh',
                'Taba City'  => '  Taba City',
    /*North Sinai*/
                'Rafah'  => ' Rafah',
    /*Sohag*/
                'Sohag City'  => '  Sohag City',
    /*Assiut*/
                'Assiut'  => ' Assiut',
                
            ),
            'input_class' => array(
                'wc-enhanced-select',
            )
        ), $fields['shipping']['shipping_city'] );
    
        $fields['shipping']['shipping_city'] = $city_args;
        $fields['billing']['billing_city'] = $city_args; // Also change for billing field
    
        wc_enqueue_js( "
        jQuery( ':input.wc-enhanced-select' ).filter( ':not(.enhanced)' ).each( function() {
            var select2_args = { minimumResultsForSearch: 5 };
            jQuery( this ).select2( select2_args ).addClass( 'enhanced' );
        });" );
    
        return $fields;
    
    }
    add_filter( 'woocommerce_checkout_fields', 'jeroen_sormani_change_city_to_dropdown' );
    ------------------------------------------------------------------------
    Rise Company for Engineering & Technology
    ------------------------------------------------------------------------
    Web Hosting | Web Designing | E-Marketing

    # 1 Business Services

    Web Hosting - Business Emails

    Web Design - Google Adwords

    www.rise.company | www.rise.company/emails

    :
    ! .



  1. : 0
    : 12-03-2022, 00:31
  2. WordPress WooCommerce Plugin
    Rise Company WordPress
    : 0
    : 08-03-2022, 14:59
  3. : 0
    : 01-01-2022, 08:18
  4. : 0
    : 04-05-2021, 05:23
  5. : 0
    : 20-04-2021, 04:15