How To

How to set Address Limitation for Logged In Customer on Checkout page of Magento 2

Ecommerce checkout is a crucial part of any Magento store. Because keeping your checkout process smooth and interactive helps you to boost your store conversion rate drastically. While having a complicated checkout process can increase your store cart abandon rate. If you see the whole checkout process is divided into many steps where your customer has to add their shipping address first then select the shipping method and payment option to complete an order.
By default, your store customer can add several addresses inside your Magento 2 store. Also, they can easily manage all the addresses from their My Account section. But having multiple addresses makes a cumbersome task for your customers to select a particular address even if they don’t use all the addresses too frequently. Instead, we can display only last used 4 or 5 addresses in checkout options. Also, hiding adds address option while checkout reduces your conversation time. But there is no such option in Magento 2 backend so the only way it overrides your default theme checkout page.
To do the same. First copy the following file in your local theme.
Vendor\magento\module-checkout\view\frontend\web\js\view\shipping-address\list.js
Now find and modify the following function.
initChildren: function () {

 if(addressList().length > 0){
        this.createRendererComponent(addressList()[0],this); /* It always set the first shipping address. Change the logic as per your requirement */ }
 else{
     _.each(addressList(), this.createRendererComponent, this);
 }
 return this;
},

Now, to hide New Address button and copy the html template from…
Vendor\magento\module-checkout\view\frontend\web\template\shipping.html
To your local theme and comment the below code

         
     

That’s it. You are free to manipulate this code according to your need of adjusting the number of addresses that you want to display in frontend checkout. Also, install Custom Checkout Fields which helps the store admin customize the checkout page by adding extra fields.
Lastly, if you found this blog helpful, don’t forget to share it with your colleagues and Magento Friends and Let us know if you are facing any issue while implementing this code.
Happy Coding!

Click to rate this post!
[Total: 7 Average: 5]
Dhiren Vasoya

Dhiren Vasoya is a Director and Co-founder at MageComp, Passionate 🎖️ Certified Magento Developer👨‍💻. He has more than 9 years of experience in Magento Development and completed 850+ projects to solve the most important E-commerce challenges. He is fond❤️ of coding and if he is not busy developing then you can find him at the cricket ground, hitting boundaries.🏏

View Comments

  • How can i filter the record based on any column from customer_address_entity table in magento 2

    • The collection filter you can do from where that collection create, this is just view files of that one

Recent Posts

6 Innovative Tools Revolutionizing E-Commerce Operations

E-commerce has transformed the way consumers shop for products and services and interact with businesses.…

1 day ago

How Upcoming Cookie Changes Will Affect Your E-commerce Website?

The e-commerce world is constantly in flux. New tech and strategies emerge daily to help…

1 day ago

Magento 2: How to Add Header and Footer in Checkout

Hello Magento Friends, In today’s blog, we will discuss adding a header and footer to…

2 days ago

Understanding Flexbox Layout in React Native

Hello React Native Friends, Building a visually appealing and responsive mobile app is crucial in…

4 days ago

HYVÄ Themes Releases: 1.3.6 & 1.3.7 – What’s New

We're thrilled to announce the release of Hyvä Themes 1.3.6 and 1.3.7! These latest updates…

4 days ago

How Modern E-Commerce Platforms Leverage Docker & Kubernetes for Scalability

Your e-commerce platform is surging - orders are rolling in, traffic spikes are becoming the…

5 days ago