0

I need to get rid of this company text field and Country drop down since the store serves locally.

Important : How I can overide the city (text area) to a drop down with my own custom city list.?

enter image description here

1

Extension1: you can install this free extension for display city

visit this link for how to install composer require php-cuong/magento2-city-dropdown

For more details how to set up check this link

Extension2: https://github.com/EaDesgin/Magento2-City-Dropdown

  • There isnt any code in this github repo?!? – sv3n Nov 15 '18 at 7:54
  • please run composer require php-cuong/magento2-city-dropdown command from magento root, you will get extension in vendor – Rohit Nov 15 '18 at 7:56
1

In your block \Magento\Directory\Model\ResourceModel\Country\CollectionFactory $countryCollectionFactory

public function getCountries()
{
    $collection = $this->countryCollectionFactory->create()->loadByStore()->toOptionArray(false);
        return $collection;

}

In your template file

<div class="field name required">
                <label class="label" for="customer_country"><span>Country</span></label>
                <div class="control">
                <?php
                    $countryList=$block->getCountries();
                    ?>
                    <div class="field country">

                        <select class="required-entry" id="country" name="country"> 
                            <option value="">Please Select</option>        
                             <?php foreach ($countryList as $key => $country) {?>
                             <option value="<?php echo $country['value']; ?>"><?php echo $country['label']; ?></option>
                             <?php } ?>
                        </select>

                    </div>

                </div>
</div>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.