I am using Magento 2.3. I am trying to pre-fill fields in Magento checkout form.
I have done following. I followed this article.
First I defined dependency injection at vendor/module/etc/frontend/di.xml
.
I believe it is working.
After that, I created layoutprocessor at Vendor/Module/Plugin/Magento/Checkout/Block/Checkout/LayoutProcessor.php
with following contents:
<?php
namespace Vendor\Module\Plugin\Magento\Checkout\Block\Checkout;
class LayoutProcessor
{
public function afterProcess(
\Magento\Checkout\Block\Checkout\LayoutProcessor $subject,
array $jsLayout
) {
$jsLayout['components']['checkout']['children']['steps']['children']['shipping-step']['children']['shippingAddress']['children']['shipping-address-fieldset']['children']['firstname']['value'] = 'First Name';
$jsLayout['components']['checkout']['children']['steps']['children']['shipping-step']['children']['shippingAddress']['children']['customer-email']['value'] = 'default@example.com';
$jsLayout['components']['checkout']['children']['steps']['children']['shipping-step']['children']['shippingAddress']['children']['shipping-address-fieldset']['children']['street']['children'][0]['value'] = 'Street Line one';
return $jsLayout;
}
}
My problem is that, the firstname
field gets filled with the value, while customer-email
field does not get filled with the supplied value. Where am I doing wrong?
$jsLayout['components']['checkout']['children']['steps']['children']['shipping-step']['children']['shippingAddress']['children']['shipping-address-fieldset']['children']['customer-email']['value'] = 'default@example.com'
– fmsthird Mar 14 '19 at 3:22