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
    – Mahi M
    Sep 19, 2019 at 4:19
  • You can do it via for loop change @ManoM
    – Mayur
    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); }
    – Mahi M
    Sep 19, 2019 at 4:31
  • Is it correct ?
    – Mahi M
    Sep 19, 2019 at 4:31
  • I did not try for 5 but please check from your side. @ManoM
    – Mayur
    Sep 19, 2019 at 4:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.