0

I want to set the limitation for count of address list on the checkout page.

can we restrict it or not, if yes then How to do that.

Thanks in advance.

1

1 Answer 1

2

Copy the file in your local theme from

vendor\magento\module-checkout\view\frontend\web\js\view\shipping-address\list.js 

Modify the function ,

/** @inheritdoc */ 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; }, 

To hide New Address button,

Copy the html template from

vendor\magento\module-checkout\view\frontend\web\template\shipping.html 

To the local theme and comment the below code

<if args="!isFormInline"> <button type="button" class="action action-show-popup" click="showFormPopUp" visible="!isNewAddressAdded()"> <span translate="'New Address'" /> </button> <div id="opc-new-shipping-address" visible="isFormPopUpVisible()" render="shippingFormTemplate" /> </if> 
7
  • But I want to show the address count 5 Commented Sep 19, 2019 at 4:19
  • You can do it via for loop change @ManoM Commented Sep 19, 2019 at 4:29
  • Inside the if condition : var addressCount = (addressList().length <= 5) ? addressList().length :5; for(var i=0; i < addressCount; i++) { this.createRendererComponent(addressList()[i], i); } Commented Sep 19, 2019 at 4:31
  • Is it correct ? Commented Sep 19, 2019 at 4:31
  • I did not try for 5 but please check from your side. @ManoM Commented Sep 19, 2019 at 4:33

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.