Can any one help me how to edit the checkout page street address label in magento2.
-
You can translate by adding to i18n Csv – Suresh Chikani May 11 '18 at 5:36
-
ok i will try it , get back to you, – shivashankar m May 11 '18 at 5:37
There are two ways, you can change the label.
The first way is use translation at theme level and it is the Best way.
app/design/frontend/{Themevendorname}/{ThemeName}/i18n/
That changes will reflect all over you're the current theme.Like customer address page at My account Section etc.
Create {Langauecode}.csv
if it does not exist at there
and add the text
"Street Address","Road Address"
Then do static content deploy to apply the translation.
Second-way, to use Plugin
Create a plugin for the class
Magento\Checkout\Block\Checkout\LayoutProcessor
Create after method afterProcess()
on process()
and change the label. This way the label only change at the checkout page. not all over the theme.
Plugin class:
<?php
/**
* Created by Amit Bera.
* User: Amit Kumar Bera
* Email: dev.amitbera@gmail.com
*/
namespace StackExchange\Works\Plugin;
class LayoutProcessorPlugin
{
public function afterprocess(
\Magento\Checkout\Block\Checkout\LayoutProcessor $subject,
$jsLayout
)
{
if (isset($jsLayout['components']['checkout']['children']['steps']['children']['shipping-step']
['children']['shippingAddress']['children']['shipping-address-fieldset']['children']['street'])) {
$fields = $jsLayout['components']['checkout']['children']['steps']['children']['shipping-step']
['children']['shippingAddress']['children']['shipping-address-fieldset']['children']['street'];
$jsLayout['components']['checkout']['children']['steps']['children']['shipping-step']
['children']['shippingAddress']['children']['shipping-address-fieldset']['children']['street']['label']
='my label';
}
return $jsLayout;
}
}
di.xml
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
<!--
https://magento.stackexchange.com/questions/225561/magento2-checkout-page-changes
-->
<type name="Magento\Checkout\Block\Checkout\LayoutProcessor">
<plugin name="magento-checkout-page-changes" type="StackExchange\Works\Plugin\LayoutProcessorPlugin" />
</type>
</config>