I have only one country in country dropdown and I want to add static country code in Phone Number field in shipping and billing address in checkout.
How Can I add this in checkout shipping and billing address?
Question Updated:
I want to add a div before phone number field to manage the static country code like this:- enter image description here
1 Answer 1
You can show the value using below code in,
/app/code/Vendor/Module/etc/frontend/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">
<type name="Magento\Checkout\Block\Checkout\LayoutProcessor">
<plugin name="ProcessReferrerConfiguration" type="Vendor\Module\Plugin\Block\Checkout\LayoutProcessor"/>
</type>
</config>
app/code/Vendor/Module/Plugin/Block/Checkout/LayoutProcessor.php
<?php
namespace Vendor\Module\Plugin\Block\Checkout;
class LayoutProcessor
{
/**
* Checkout LayoutProcessor after process plugin.
*
* @param \Magento\Checkout\Block\Checkout\LayoutProcessor $processor
* @param array $jsLayout
* @return array
*/
public function afterProcess(\Magento\Checkout\Block\Checkout\LayoutProcessor $processor, $jsLayout)
{
$jsLayout['components']['checkout']['children']['steps']
['children']['shipping-step']['children']['shippingAddress']['children']['shipping-address-fieldset']['children']['telephone']['value'] = '+91';
return $jsLayout;
}
}
-
Is it tested? because I am not able to get desired resultPurushotam Sharma– Purushotam Sharma2020年02月28日 08:44:38 +00:00Commented Feb 28, 2020 at 8:44
-
Try my updated answer..Remove checkout_index_index.xmlaravind– aravind2020年02月28日 09:08:14 +00:00Commented Feb 28, 2020 at 9:08
-
Not working , Please also review My updated questionPurushotam Sharma– Purushotam Sharma2020年02月28日 09:25:45 +00:00Commented Feb 28, 2020 at 9:25
-
My updated answer is working one. I have tested, but it will be displayed directly inside telephone number field and not in separate box.aravind– aravind2020年02月28日 09:28:52 +00:00Commented Feb 28, 2020 at 9:28
-
I need in separate box So I set this with css before Phone number fieldPurushotam Sharma– Purushotam Sharma2020年02月28日 09:30:59 +00:00Commented Feb 28, 2020 at 9:30
Explore related questions
See similar questions with these tags.