Globetrotting

Someone who had travelled the world was asked to name the most interesting things he had seen on his voyages. The traveller replied, ‘Sorry I can’t tell you until I collect the photos I took from the…

Smartphone

独家优惠奖金 100% 高达 1 BTC + 180 免费旋转




Create custom address attribute programmatically Magento 2

There are only a few things we need to know before starting. All customer addresses have the same attribute sets — this means that the field you add will show in both shipping and billing addresses by default. We will look into how you can work around this in future articles.

As always we will create a data patch to create our attribute.

<?php /* * @category Techflarestudio * @author Wasalu Duckworth <info@magebit.com> * @copyright Copyright (c) 2021 Techflarestudio, Ltd. (https://techflarestudio.com) * @license http://opensource.org/licenses/OSL-3.0 The Open Software License 3.0 (OSL-3.0) * */

namespace Techflarestudio\Checkout\Setup\Patch\Data;

use Magento\Customer\Setup\CustomerSetupFactory; use Magento\Eav\Model\Entity\Attribute\SetFactory as AttributeSetFactory; use Magento\Framework\Setup\ModuleDataSetupInterface; use Magento\Framework\Setup\Patch\DataPatchInterface; use Magento\Customer\Model\ResourceModel\Attribute;

/**

In the following articles we will show you how to include this field in checkout shipping and billing addresses, how to validate and save it.

Add a comment

Related posts:

Break Your App Like a Server

Give users the real-time experience they expect, by using Elixir and Phoenix Channels to build applications that instantly react to changes and reflect the application's true state. Learn how Elixir and Phoenix make it easy and enjoyable to create real-time applications that scale to a large number of users. Apply system design

On North Korea 20180306

Biggest news this morning is that North and South Korean leaders agree to direct talks, possibly as early as next month. This is just the third time that leaders from both Korea hold direct talk…

Positivity Policing

Whole picture poetry. “Positivity Policing” is published by Danielle Diew.