I tried to add an Upload file attribute to the Checkout form, I am now able to add custom field, but still, I am unable to save values to database -

I used add Plugin -

added Below code


<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="file_upload" type="Amit\Fileupload\Model\Plugin\Checkout\LayoutProcessor" sortOrder="100"/>        


namespace Amit\Fileupload\Model\Plugin\Checkout;
class LayoutProcessor
     * @param \Magento\Checkout\Block\Checkout\LayoutProcessor $subject
     * @param array $jsLayout
     * @return array
    public function afterProcess(
        \Magento\Checkout\Block\Checkout\LayoutProcessor $subject,
        array  $jsLayout
    ) {

            $fileupload = 'file_upload';
            $datascope = 'shippingAddress.custom_attributes';

            ['shippingAddress']['children']['shipping-address-fieldset']['children'][$fileupload] = [
                'component' => 'Magento_Ui/js/form/element/media',
                'config' => [
                    'customScope' => 'shippingAddress.custom_attributes',
                    'customEntry' => null,
                    'template' => 'ui/form/field',
                    'elementTmpl' => 'ui/form/element/media',
                    'tooltip' => ['description' => 'Field to Upload File'],                 
                    'id' => $fileupload
                'dataScope' => $datascope,
                'label' => 'File Upload',
                'provider' => 'checkoutProvider',
                'visible' => true,
                'validation' => ['required-entry' => true],
                'options' => [],
                'sortOrder' => 250,
                'id' => $fileupload

        return $jsLayout;

enter image description here

Now, further how to save the data of this field, looking for help on this thanks

  • where (in which table) do you want to save the custom field value. Do you want to save it in any custom table? – Pritam Info 24 Dec 7 '18 at 12:47

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Browse other questions tagged or ask your own question.