1) First of all, Let’s assume that you have created a simple module. After that, You need to create di.xml to create plugin at app/code/Module/Helloworld/etc/frontend/ and paste the below code :
<?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="Magento\Checkout\Block\Checkout\AttributeMerger">
<plugin name="add_placeholder_to_checkout"
type="Module\Helloworld\Plugin\Block\Checkout\AttributeMerger"
sortOrder="10"/>
</type>
</config>
2) Then, You need to create AttributeMerger.php file at app/code/Module/Helloworld/Plugin/Block/Checkout/ to add placeholder code and paste the below code :
<?php namespace
Module\Helloworld\Plugin\Block\Checkout\;
/** * Class AttributeMerger * @package Module\Helloworld\Plugin\Block\Checkout\AttributeMerger
*/ class AttributeMerger
{ /** * @param \Magento\Checkout\Block\Checkout\AttributeMerger $subject * @param $result * @return mixed */
public function afterMerge( \Magento\Checkout\Block\Checkout\AttributeMerger $subject, $result )
{ $result['firstname']['placeholder'] = __('Enter First Name'); $result['lastname']['placeholder'] = __('Enter Last Name');
$result['street']['children'][0]['placeholder'] = __('Line no 1'); $result['street']['children'][1]['placeholder'] = __('Line no 2'); $result['city']['placeholder'] = __('Enter City');
$result['postcode']['placeholder'] = __('Enter Zip/Postal Code'); $result['telephone']['placeholder'] = __('Enter Phone Number');
return $result;
} }
Now, Just clean cache and check it on your checkout page