1

I have created mobile number as customer attribute by this code

    $customerSetup -> addAttribute(\Magento\Customer\Model\Customer::ENTITY,
        'mobile',
        [
        'label' => 'Mobile Number',
        'system' => 0,
        'position' => 100,
        'sort_order' =>100,
        'visible' =>  true,
        'note' => 'this item used for login',


                    'type' => 'varchar',
                    'input' => 'text',

        ]
        );

    $customerSetup -> getEavConfig() -> getAttribute('customer', 'mobile')->setData('is_user_defined',1)->setData('is_required',1)->setData('default_value','')->setData('used_in_forms', ['adminhtml_customer', 'checkout_register', 'customer_account_create', 'customer_account_edit', 'adminhtml_checkout']) -> save();

But I cannot see the mobile number in checkout.

Where am I going wrong ?

4
  • have you checked this attribute in eav_attribute table and admin end customer section? Dec 16, 2017 at 9:03
  • yeah ... i see it and i use for login by mobile but in checkout i can not see @NagarajuKasa Dec 16, 2017 at 9:05
  • are you needed checkout page under shipping and billing address right?
    – Abdul
    Dec 16, 2017 at 9:15
  • yes ... i need show mobile if customer are guest or registered Dec 16, 2017 at 9:32

1 Answer 1

1

Here you find information how to add new custom field into checkout shipping address. In similar way you can do it for Billing Address.

Unfortunately devdocs doesn't have information how to save new field from checkout in database.

Shipping address is saved in Quote when you switch from step 1 to step 2. Billing address is saved in Quote when you make a order. Then addresses from Quote details are saved in Customer object.

You have to check the core and override some methods (or use plugins for it)

There are many ways to do it, but remember that all datas are saved in Quote first, so you have to extend also the Quote.

2
  • thanks ...my problem for now is The customer attribute could shown on shipping address ? Dec 17, 2017 at 7:14
  • In link what I paste here you have a info how to show a new field on shipping address Dec 17, 2017 at 12:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.