We sacrifice by not doing any other technology, so that you get the best of Magento.

We sacrifice by not doing any other technology, so that you get the best of Magento.

    Please follow the below steps to set static value for shipping address fields and set default values on checkout page.

    Step 1: Create a module and in app/code/Magemonkeys/Customfield/di.xml put the below code in it.

    <?xml version="1.0"?>
    <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
            xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
        <type name="MagentoCheckoutBlockCheckoutLayoutProcessor">
            <plugin name="room_number" type="MagemonkeysCustomfieldPluginCheckoutModelLayoutProcessor" sortOrder="100"/>
        </type>
    </config>

    Step 2: Create a LayoutProcessor.php at this location app/code/Magemonkeys/Customfield/Plugin/Checkout/Model.

    <?php
    
    namespace MagemonkeysCustomfieldPluginCheckoutModel;
    
    use MagentoCheckoutBlockCheckoutLayoutProcessor as ChekcoutLayerprocessor;
    
    class LayoutProcessor
    {
    
        public function afterProcess(ChekcoutLayerprocessor $subject, array $jsLayout)
        {
    		
    		
    
    		$jsLayout['components']['checkout']['children']['steps']['children']['shipping-step']
                ['children']['shippingAddress']['children']['shipping-address-fieldset']['children']['street']['children'][0]['value'] = 'Street Name';
    			
    			
    			$jsLayout['components']['checkout']['children']['steps']['children']['shipping-step']
                ['children']['shippingAddress']['children']['shipping-address-fieldset']['children']['city']['value'] = 'City Name';
    			
    			$jsLayout['components']['checkout']['children']['steps']['children']['shipping-step']
                ['children']['shippingAddress']['children']['shipping-address-fieldset']['children']['postcode']['value'] = '12345';
    			
    			$jsLayout['components']['checkout']['children']['steps']['children']['shipping-step']
                ['children']['shippingAddress']['children']['shipping-address-fieldset']['children']['region_id']['value'] = 14;
    			
    		
    
            $jsLayout['components']['checkout']['children']['steps']['children']['shipping-step']['children']
            ['shippingAddress']['children']['shipping-address-fieldset']['children']['room_number'] = [
                'component' => 'Magento_Ui/js/form/element/abstract',
                'config' => [
                    'customScope' => 'shippingAddress',
                    'template' => 'ui/form/field',
                    'elementTmpl' => 'Magemonkeys_Customfield/form/room_button',
                    'options' => [],
                    'id' => 'room_number'
                ],
                'dataScope' => 'shippingAddress.room_number',
                'label' => 'Room Number if known',
                'provider' => 'checkoutProvider',
                'visible' => true,
                'validation' => [],
                'sortOrder' => 50,
                'id' => 'room_number'
            ];
    
            return $jsLayout;
        }
    }

     

    Fill the below form if you need any Magento relate help/advise/consulting.

    With Only Agency that provides a 24/7 emergency support.

      Get a Free Quote