0

I have a module with which I create my attribute. I can get it and show it in the admin panel, but not when the data is recibed on checkout process.

enter image description here

This is my installer code:

    public function install(
    ModuleDataSetupInterface $setup,
    ModuleContextInterface $context
) {
    $customerSetup = $this->customerSetupFactory->create(['setup' => $setup]);

    $customerSetup->addAttribute('customer_address', 'dnicif', [
        'label' => 'DNI',
        'input' => 'text',
        'type' => 'varchar',
        'source' => '',
        'required' => true,
        'position' => 45,
        'visible' => true,
        'sort_order' => 45,
        'system' => false,
        'is_used_in_grid' => true,
        'is_visible_in_grid' => true,
        'is_filterable_in_grid' => true,
        'is_searchable_in_grid' => true,
        'backend' => ''
    ]);



    $attribute = $customerSetup->getEavConfig()->getAttribute('customer_address', 'dnicif')
        ->addData(['used_in_forms' => [
            'adminhtml_customer_address',
            'customer_address_edit',
            'customer_register_address'
        ]]);

    $attribute->save();


    $installer = $setup;

    $installer->getConnection()->addColumn(
        $installer->getTable('quote_address'),
        'dnicif',
        [
            'comment' => 'DNI',
            'type' => Table::TYPE_TEXT,
            'length' => 255
        ]
    );

    $installer->getConnection()->addColumn(
        $installer->getTable('sales_order_address'),
        'dnicif',
        [
            'comment' => 'DNI',
            'type' => Table::TYPE_TEXT,
            'length' => 255
        ]
    );

    /** @var QuoteSetup $quoteInstaller */
    $quoteInstaller = $this->quoteSetupFactory->create(
        ['resourceName' => 'quote_setup', 'setup' => $setup]
    );

    /** @var SalesSetup $salesInstaller */
    $salesInstaller = $this->salesSetupFactory->create(
        ['resourceName' => 'sales_setup', 'setup' => $setup]
    );

    $quoteInstaller->addAttribute(
        'quote',
        'dnicif',
        ['type' => Table::TYPE_TEXT, 'length' => '255', 'nullable' => true]
    );

    $salesInstaller->addAttribute(
        'order',
        'dnicif',
        ['type' => Table::TYPE_TEXT, 'length' => '255', 'nullable' => true, 'grid' => true]
    );

I need recibe this data on email confirmation and/or the order data on admin panel. enter image description here

Im using magento 2.1

¿Any ideas?

Thank you very much guys.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.