I want to add city drop down in checkout page instead of text field. Searching online couldn't get any solution. Also use this extension https://github.com/EaDesgin/Magento2-City-Dropdown ,but this module is not working properly. SO any other solution??
1 Answer
For Frontend:
In layout file checkout_index_index call the template file which has your dropdown html code.it will be displayed on you checkout page.
Code: file name has checkout_index_index.xml
<?xml version="1.0"?>
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" layout="checkout" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
<body>
<referenceContainer name="content">
<block class="Test\CommunityCommerce\Block\Checkoutmod\Checkoutmod" name="Checkoutmod_Checkoutmod" after="checkout.cart.coupon" template="Sundial_CommunityCommerce::checkout/cart/Checkoutmod.phtml">
</block>
</referenceContainer>
</body>
In Template file consists :
file name has Checkoutmod.phtml
<div class="content" data-role="content" aria-labelledby="block-Checkoutmod-heading">
<form id="Checkoutmod-form"
action="#"
method="post"
value="0" />
<?php //echo $block->getBlockHtml('formkey') ?>
<div class="field">
<div class="control">
<select id="Checkoutmod_id" name="Checkoutmod_id">
<option value="test1">test1</option>
<option value="test2">test2</option>
</select>
</div>
</div>
</form>
</div>
</div>
Create column in quote table and sales table using setup scripts using "InstallSchema" it will create column into table.
After that using sales_convert_quote and fieldset.xml it will move to quote value to sales table.
-
Thanks @Hamendra Sunthwal. But will drop down created for city in address from in checkout page by this code? or it will reate just an extra filed in checkout form? Aug 7, 2020 at 6:46
-
This example shows how select field can be created, you can use the method & implement in existing field. Aug 7, 2020 at 7:34