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 () {
1 2 3 4 5 6 7 8 |
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
1 2 3 |
<button class="action action-show-popup" type="button"> </button> |
1 |
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!
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