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

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!

Previous Article

Useful Tips That Will Enable You to Stretch Your E-Commerce Marketing Budget Further

Next Article

How to add a Custom Parameter in Customer Order Email of Magento 2

Write a Comment
  1. How can i filter the record based on any column from customer_address_entity table in magento 2

Leave a Comment

Your email address will not be published. Required fields are marked *

Get Connect With Us

Subscribe to our email newsletter to get the latest posts delivered right to your email.
Pure inspiration, zero spam ✨